@open-pioneer/vite-plugin-pioneer 0.6.0 → 0.6.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.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +137 -108
- package/dist/index.js.map +4 -4
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,21 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
pioneer: () => pioneer
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
|
|
1
37
|
// src/codegenPlugin.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
38
|
+
var import_node_fs = require("node:fs");
|
|
39
|
+
var import_node_path3 = require("node:path");
|
|
40
|
+
var import_vite3 = require("vite");
|
|
5
41
|
|
|
6
42
|
// src/utils/debug.ts
|
|
7
|
-
|
|
43
|
+
var import_debug = require("debug");
|
|
8
44
|
function createDebugger(namespace) {
|
|
9
|
-
const logger = debug(namespace);
|
|
45
|
+
const logger = (0, import_debug.debug)(namespace);
|
|
10
46
|
return function debugFunction(...args) {
|
|
11
47
|
logger(...args);
|
|
12
48
|
};
|
|
13
49
|
}
|
|
14
50
|
|
|
15
51
|
// src/codegen/generatePackagesMetadata.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
52
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
53
|
+
var import_template = __toESM(require("@babel/template"));
|
|
54
|
+
var nodes = __toESM(require("@babel/types"));
|
|
19
55
|
|
|
20
56
|
// src/ReportableError.ts
|
|
21
57
|
var ReportableError = class extends Error {
|
|
@@ -45,10 +81,10 @@ function cleanName(input) {
|
|
|
45
81
|
}
|
|
46
82
|
|
|
47
83
|
// src/codegen/generatePackagesMetadata.ts
|
|
48
|
-
var SERVICE_IMPORT =
|
|
84
|
+
var SERVICE_IMPORT = import_template.default.statement(`
|
|
49
85
|
import { %%SERVICE_NAME%% as %%IMPORT_NAME%% } from %%IMPORT_SOURCE%%;
|
|
50
86
|
`);
|
|
51
|
-
var PKG_OBJECT =
|
|
87
|
+
var PKG_OBJECT = import_template.default.expression(`
|
|
52
88
|
{
|
|
53
89
|
name: %%PACKAGE_NAME%%,
|
|
54
90
|
services: %%PACKAGE_SERVICES%%,
|
|
@@ -56,7 +92,7 @@ var PKG_OBJECT = template.expression(`
|
|
|
56
92
|
properties: %%PROPERTIES%%
|
|
57
93
|
}
|
|
58
94
|
`);
|
|
59
|
-
var SERVICE_OBJECT =
|
|
95
|
+
var SERVICE_OBJECT = import_template.default.expression(`
|
|
60
96
|
{
|
|
61
97
|
name: %%SERVICE_NAME%%,
|
|
62
98
|
clazz: %%SERVICE_IMPORT%%,
|
|
@@ -64,25 +100,25 @@ var SERVICE_OBJECT = template.expression(`
|
|
|
64
100
|
references: %%SERVICE_REFERENCES%%
|
|
65
101
|
}
|
|
66
102
|
`);
|
|
67
|
-
var INTERFACE_OBJECT =
|
|
103
|
+
var INTERFACE_OBJECT = import_template.default.expression(`
|
|
68
104
|
{
|
|
69
105
|
name: %%INTERFACE_NAME%%,
|
|
70
106
|
qualifier: %%QUALIFIER%%
|
|
71
107
|
}
|
|
72
108
|
`);
|
|
73
|
-
var REFERENCE_OBJECT =
|
|
109
|
+
var REFERENCE_OBJECT = import_template.default.expression(`
|
|
74
110
|
{
|
|
75
111
|
name: %%INTERFACE_NAME%%,
|
|
76
112
|
qualifier: %%QUALIFIER%%,
|
|
77
113
|
all: %%ALL%%
|
|
78
114
|
}
|
|
79
115
|
`);
|
|
80
|
-
var UI_OBJECT =
|
|
116
|
+
var UI_OBJECT = import_template.default.expression(`
|
|
81
117
|
{
|
|
82
118
|
references: %%UI_REFERENCES%%
|
|
83
119
|
}
|
|
84
120
|
`);
|
|
85
|
-
var PROPERTY_OBJECT =
|
|
121
|
+
var PROPERTY_OBJECT = import_template.default.expression(`
|
|
86
122
|
{
|
|
87
123
|
value: %%VALUE%%,
|
|
88
124
|
required: %%REQUIRED%%
|
|
@@ -125,7 +161,7 @@ function generatePackagesMetadata({ appName, packages }) {
|
|
|
125
161
|
);
|
|
126
162
|
}
|
|
127
163
|
const program2 = nodes.program([...imports, nodes.exportDefaultDeclaration(packagesMetadata)]);
|
|
128
|
-
return
|
|
164
|
+
return (0, import_generator.default)(program2).code;
|
|
129
165
|
}
|
|
130
166
|
function generatePackageMetadata(pkg, options) {
|
|
131
167
|
const servicesObject = nodes.objectExpression([]);
|
|
@@ -228,19 +264,19 @@ function undefinedNode() {
|
|
|
228
264
|
}
|
|
229
265
|
|
|
230
266
|
// src/metadata/MetadataRepository.ts
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
267
|
+
var import_promises2 = require("fs/promises");
|
|
268
|
+
var import_path = require("path");
|
|
269
|
+
var import_vite = require("vite");
|
|
234
270
|
|
|
235
271
|
// src/utils/fileUtils.ts
|
|
236
|
-
|
|
237
|
-
|
|
272
|
+
var fs = __toESM(require("node:fs"));
|
|
273
|
+
var import_node_path = require("node:path");
|
|
238
274
|
function fileExists(file) {
|
|
239
275
|
return fs.promises.access(file, fs.constants.F_OK).then(() => true).catch(() => false);
|
|
240
276
|
}
|
|
241
277
|
function isInDirectory(candidate, directory) {
|
|
242
|
-
const rel = relative(directory, candidate);
|
|
243
|
-
const isChild = rel && !rel.startsWith("..") && !isAbsolute(rel);
|
|
278
|
+
const rel = (0, import_node_path.relative)(directory, candidate);
|
|
279
|
+
const isChild = rel && !rel.startsWith("..") && !(0, import_node_path.isAbsolute)(rel);
|
|
244
280
|
return !!isChild;
|
|
245
281
|
}
|
|
246
282
|
|
|
@@ -310,37 +346,32 @@ var Cache = class {
|
|
|
310
346
|
};
|
|
311
347
|
|
|
312
348
|
// src/metadata/parseBuildConfig.ts
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
createPackageConfigFromBuildConfig,
|
|
316
|
-
loadBuildConfig as loadBuildConfigCommon,
|
|
317
|
-
verifyBuildConfig
|
|
318
|
-
} from "@open-pioneer/build-common";
|
|
319
|
-
import { basename } from "node:path";
|
|
349
|
+
var import_build_common = require("@open-pioneer/build-common");
|
|
350
|
+
var import_node_path2 = require("node:path");
|
|
320
351
|
async function loadBuildConfig(path) {
|
|
321
|
-
const rawConfig = await
|
|
322
|
-
return createPackageConfigFromBuildConfig(rawConfig);
|
|
352
|
+
const rawConfig = await (0, import_build_common.loadBuildConfig)(path);
|
|
353
|
+
return (0, import_build_common.createPackageConfigFromBuildConfig)(rawConfig);
|
|
323
354
|
}
|
|
324
355
|
function isBuildConfig(file) {
|
|
325
|
-
return basename(file) === BUILD_CONFIG_NAME;
|
|
356
|
+
return (0, import_node_path2.basename)(file) === import_build_common.BUILD_CONFIG_NAME;
|
|
326
357
|
}
|
|
327
358
|
|
|
328
359
|
// src/metadata/parseI18nYaml.ts
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var MESSAGES_SCHEMA = z.lazy(
|
|
334
|
-
() => z.record(z.union([z.string(), MESSAGES_SCHEMA])).nullish()
|
|
360
|
+
var import_promises = require("fs/promises");
|
|
361
|
+
var import_js_yaml = require("js-yaml");
|
|
362
|
+
var import_zod = require("zod");
|
|
363
|
+
var import_zod_validation_error = require("zod-validation-error");
|
|
364
|
+
var MESSAGES_SCHEMA = import_zod.z.lazy(
|
|
365
|
+
() => import_zod.z.record(import_zod.z.union([import_zod.z.string(), MESSAGES_SCHEMA])).nullish()
|
|
335
366
|
);
|
|
336
|
-
var I18N_SCHEMA = z.strictObject({
|
|
367
|
+
var I18N_SCHEMA = import_zod.z.strictObject({
|
|
337
368
|
messages: MESSAGES_SCHEMA.nullish().optional(),
|
|
338
|
-
overrides: z.record(MESSAGES_SCHEMA).nullish().optional()
|
|
369
|
+
overrides: import_zod.z.record(MESSAGES_SCHEMA).nullish().optional()
|
|
339
370
|
}).nullish();
|
|
340
371
|
async function loadI18nFile(path) {
|
|
341
372
|
let content;
|
|
342
373
|
try {
|
|
343
|
-
content = await readFile(path, "utf-8");
|
|
374
|
+
content = await (0, import_promises.readFile)(path, "utf-8");
|
|
344
375
|
} catch (e) {
|
|
345
376
|
throw new ReportableError(`Failed to read ${path}`, { cause: e });
|
|
346
377
|
}
|
|
@@ -351,13 +382,13 @@ async function loadI18nFile(path) {
|
|
|
351
382
|
}
|
|
352
383
|
}
|
|
353
384
|
function parseI18nYaml(yaml) {
|
|
354
|
-
const data =
|
|
385
|
+
const data = (0, import_js_yaml.load)(yaml);
|
|
355
386
|
return parseI18nFile(data);
|
|
356
387
|
}
|
|
357
388
|
function parseI18nFile(data) {
|
|
358
389
|
const result = I18N_SCHEMA.safeParse(data);
|
|
359
390
|
if (!result.success) {
|
|
360
|
-
throw fromZodError(result.error);
|
|
391
|
+
throw (0, import_zod_validation_error.fromZodError)(result.error);
|
|
361
392
|
}
|
|
362
393
|
const rawI18n = result.data;
|
|
363
394
|
return {
|
|
@@ -403,11 +434,7 @@ function gatherOverrides(data) {
|
|
|
403
434
|
}
|
|
404
435
|
|
|
405
436
|
// src/metadata/MetadataRepository.ts
|
|
406
|
-
|
|
407
|
-
BUILD_CONFIG_NAME as BUILD_CONFIG_NAME2,
|
|
408
|
-
PackageMetadataV1,
|
|
409
|
-
createPackageConfigFromPackageMetadata
|
|
410
|
-
} from "@open-pioneer/build-common";
|
|
437
|
+
var import_build_common2 = require("@open-pioneer/build-common");
|
|
411
438
|
|
|
412
439
|
// src/utils/package.ts
|
|
413
440
|
var PACKAGE_NAME = "@open-pioneer/vite-plugin-pioneer";
|
|
@@ -443,7 +470,7 @@ var MetadataRepository = class {
|
|
|
443
470
|
*/
|
|
444
471
|
onFileChanged(path) {
|
|
445
472
|
if (isPackageJson(path) || isBuildConfig(path)) {
|
|
446
|
-
this.packageMetadataCache.invalidate(dirname(path));
|
|
473
|
+
this.packageMetadataCache.invalidate((0, import_path.dirname)(path));
|
|
447
474
|
}
|
|
448
475
|
this.i18nCache.invalidate(path);
|
|
449
476
|
}
|
|
@@ -530,9 +557,10 @@ var MetadataRepository = class {
|
|
|
530
557
|
}
|
|
531
558
|
async resolvePackageLocation(loc) {
|
|
532
559
|
if (loc.type === "absolute") {
|
|
533
|
-
return await realpath(loc.directory);
|
|
560
|
+
return await (0, import_promises2.realpath)(loc.directory);
|
|
534
561
|
}
|
|
535
562
|
const { packageName, optional } = loc.dependency;
|
|
563
|
+
const { resolvePackageData } = await import("vite");
|
|
536
564
|
const packageData = await resolvePackageData(
|
|
537
565
|
packageName,
|
|
538
566
|
loc.importedFrom,
|
|
@@ -548,14 +576,14 @@ var MetadataRepository = class {
|
|
|
548
576
|
`Failed to find package '${packageName}' (from '${loc.importedFrom}'), is the dependency installed correctly?`
|
|
549
577
|
);
|
|
550
578
|
}
|
|
551
|
-
const packageDir = await realpath(packageData.dir);
|
|
579
|
+
const packageDir = await (0, import_promises2.realpath)(packageData.dir);
|
|
552
580
|
isDebug && debug2(`Found package '${packageName}' at ${packageDir}`);
|
|
553
581
|
return packageDir;
|
|
554
582
|
}
|
|
555
583
|
createI18nCache() {
|
|
556
584
|
return new Cache({
|
|
557
585
|
getId(path) {
|
|
558
|
-
return normalizePath(path);
|
|
586
|
+
return (0, import_vite.normalizePath)(path);
|
|
559
587
|
},
|
|
560
588
|
async getValue(path, ctx) {
|
|
561
589
|
isDebug && debug2(`Loading i18n file ${path}`);
|
|
@@ -579,7 +607,7 @@ var MetadataRepository = class {
|
|
|
579
607
|
const provider = {
|
|
580
608
|
_byName: /* @__PURE__ */ new Map(),
|
|
581
609
|
getId(directory) {
|
|
582
|
-
return normalizePath(directory);
|
|
610
|
+
return (0, import_vite.normalizePath)(directory);
|
|
583
611
|
},
|
|
584
612
|
async getValue(directory, ctx) {
|
|
585
613
|
isDebug && debug2(`Loading metadata for package at ${directory}`);
|
|
@@ -599,7 +627,7 @@ var MetadataRepository = class {
|
|
|
599
627
|
isDebug && debug2(`Metadata for '${metadata.name}': %O`, metadata);
|
|
600
628
|
if (metadata.type === "pioneer-package") {
|
|
601
629
|
const existingMetadata = this._byName.get(metadata.name);
|
|
602
|
-
if (existingMetadata && normalizePath(existingMetadata.directory) !== normalizePath(metadata.directory)) {
|
|
630
|
+
if (existingMetadata && (0, import_vite.normalizePath)(existingMetadata.directory) !== (0, import_vite.normalizePath)(metadata.directory)) {
|
|
603
631
|
throw new ReportableError(
|
|
604
632
|
`Found package '${metadata.name}' at two different locations ${existingMetadata.directory} and ${metadata.directory}`
|
|
605
633
|
);
|
|
@@ -631,7 +659,7 @@ function propagateWatchFiles(watchFiles, ctx) {
|
|
|
631
659
|
async function parsePackageMetadata(ctx, packageDir, sourceRoot) {
|
|
632
660
|
const mode = isLocalPackage(packageDir, sourceRoot) ? "local" : "external";
|
|
633
661
|
isDebug && debug2(`Visiting package directory ${packageDir} in mode ${mode}.`);
|
|
634
|
-
const packageJsonPath = join(packageDir, "package.json");
|
|
662
|
+
const packageJsonPath = (0, import_path.join)(packageDir, "package.json");
|
|
635
663
|
ctx.addWatchFile(packageJsonPath);
|
|
636
664
|
const {
|
|
637
665
|
name: packageName,
|
|
@@ -689,12 +717,12 @@ async function parsePackageMetadata(ctx, packageDir, sourceRoot) {
|
|
|
689
717
|
if (i18nPaths.has(locale)) {
|
|
690
718
|
throw new ReportableError(`Locale '${locale}' was defined twice in ${configPath}`);
|
|
691
719
|
}
|
|
692
|
-
const path = join(packageDir, "i18n", `${locale}.yaml`);
|
|
720
|
+
const path = (0, import_path.join)(packageDir, "i18n", `${locale}.yaml`);
|
|
693
721
|
ctx.addWatchFile(path);
|
|
694
722
|
if (!await fileExists(path)) {
|
|
695
723
|
throw new ReportableError(`i18n file '${path}' does not exist.`);
|
|
696
724
|
}
|
|
697
|
-
i18nPaths.set(locale, normalizePath(path));
|
|
725
|
+
i18nPaths.set(locale, (0, import_vite.normalizePath)(path));
|
|
698
726
|
}
|
|
699
727
|
return {
|
|
700
728
|
type: "pioneer-package",
|
|
@@ -711,9 +739,9 @@ async function parsePackageMetadata(ctx, packageDir, sourceRoot) {
|
|
|
711
739
|
async function readConfig(ctx, packageDir, mode, frameworkMetadata, packageName, packageJsonPath) {
|
|
712
740
|
switch (mode) {
|
|
713
741
|
case "local": {
|
|
714
|
-
const buildConfigPath = join(packageDir,
|
|
742
|
+
const buildConfigPath = (0, import_path.join)(packageDir, import_build_common2.BUILD_CONFIG_NAME);
|
|
715
743
|
let buildConfig;
|
|
716
|
-
ctx.addWatchFile(normalizePath(buildConfigPath));
|
|
744
|
+
ctx.addWatchFile((0, import_vite.normalizePath)(buildConfigPath));
|
|
717
745
|
if (await fileExists(buildConfigPath)) {
|
|
718
746
|
try {
|
|
719
747
|
buildConfig = await loadBuildConfig(buildConfigPath);
|
|
@@ -723,7 +751,7 @@ async function readConfig(ctx, packageDir, mode, frameworkMetadata, packageName,
|
|
|
723
751
|
});
|
|
724
752
|
}
|
|
725
753
|
} else {
|
|
726
|
-
throw new ReportableError(`Expected a ${
|
|
754
|
+
throw new ReportableError(`Expected a ${import_build_common2.BUILD_CONFIG_NAME} in ${packageDir}`);
|
|
727
755
|
}
|
|
728
756
|
return { configPath: buildConfigPath, config: buildConfig };
|
|
729
757
|
}
|
|
@@ -731,7 +759,7 @@ async function readConfig(ctx, packageDir, mode, frameworkMetadata, packageName,
|
|
|
731
759
|
if (!frameworkMetadata) {
|
|
732
760
|
return void 0;
|
|
733
761
|
}
|
|
734
|
-
const metadataResult = PackageMetadataV1.parsePackageMetadata(frameworkMetadata);
|
|
762
|
+
const metadataResult = import_build_common2.PackageMetadataV1.parsePackageMetadata(frameworkMetadata);
|
|
735
763
|
if (metadataResult.type === "error") {
|
|
736
764
|
if (metadataResult.code === "unsupported-version") {
|
|
737
765
|
throw new ReportableError(
|
|
@@ -748,7 +776,7 @@ async function readConfig(ctx, packageDir, mode, frameworkMetadata, packageName,
|
|
|
748
776
|
}
|
|
749
777
|
return {
|
|
750
778
|
configPath: packageJsonPath,
|
|
751
|
-
config: createPackageConfigFromPackageMetadata(metadataResult.value)
|
|
779
|
+
config: (0, import_build_common2.createPackageConfigFromPackageMetadata)(metadataResult.value)
|
|
752
780
|
};
|
|
753
781
|
}
|
|
754
782
|
}
|
|
@@ -759,7 +787,7 @@ async function parsePackageJson(ctx, packageJsonPath) {
|
|
|
759
787
|
}
|
|
760
788
|
let packageJsonContent;
|
|
761
789
|
try {
|
|
762
|
-
packageJsonContent = JSON.parse(await
|
|
790
|
+
packageJsonContent = JSON.parse(await (0, import_promises2.readFile)(packageJsonPath, "utf-8"));
|
|
763
791
|
} catch (e) {
|
|
764
792
|
throw new ReportableError(`Failed to read ${packageJsonPath}`, { cause: e });
|
|
765
793
|
}
|
|
@@ -794,7 +822,7 @@ async function parsePackageJson(ctx, packageJsonPath) {
|
|
|
794
822
|
}),
|
|
795
823
|
...Object.keys(optionalDependencies).map((packageName2) => ({ packageName: packageName2, optional: true }))
|
|
796
824
|
];
|
|
797
|
-
const frameworkMetadata = packageJsonContent[PackageMetadataV1.PACKAGE_JSON_KEY] ?? void 0;
|
|
825
|
+
const frameworkMetadata = packageJsonContent[import_build_common2.PackageMetadataV1.PACKAGE_JSON_KEY] ?? void 0;
|
|
798
826
|
return {
|
|
799
827
|
name: packageName,
|
|
800
828
|
dependencies: allDependencies,
|
|
@@ -836,8 +864,8 @@ function generateCombinedCss(packages) {
|
|
|
836
864
|
}
|
|
837
865
|
|
|
838
866
|
// src/codegen/shared.ts
|
|
839
|
-
|
|
840
|
-
|
|
867
|
+
var import_posix = require("node:path/posix");
|
|
868
|
+
var import_vite2 = require("vite");
|
|
841
869
|
var APP_MODULE = "@@open-pioneer-app";
|
|
842
870
|
var APP_META_QUERY = "open-pioneer-app";
|
|
843
871
|
var APP_META_RE = /[?&]open-pioneer-app(?:$|&)/;
|
|
@@ -853,7 +881,7 @@ var APP_I18N_LOCALE_RE = /[?&]locale=(?<locale>.*?)(?:$|&)/;
|
|
|
853
881
|
var PACKAGE_HOOKS_MODULE = "@@open-pioneer-react-hooks";
|
|
854
882
|
var SOURCE_FILE_RE = /^(.*?)(?:\?|$)/;
|
|
855
883
|
function parseVirtualModuleId(inputModuleId) {
|
|
856
|
-
const moduleId =
|
|
884
|
+
const moduleId = (0, import_vite2.normalizePath)(inputModuleId);
|
|
857
885
|
if (!moduleId || moduleId.includes("\\0")) {
|
|
858
886
|
return void 0;
|
|
859
887
|
}
|
|
@@ -861,11 +889,11 @@ function parseVirtualModuleId(inputModuleId) {
|
|
|
861
889
|
if (!sourceFile) {
|
|
862
890
|
return void 0;
|
|
863
891
|
}
|
|
864
|
-
const base =
|
|
892
|
+
const base = (0, import_posix.basename)(sourceFile);
|
|
865
893
|
if (base === PACKAGE_HOOKS_MODULE) {
|
|
866
894
|
return {
|
|
867
895
|
type: "package-hooks",
|
|
868
|
-
packageDirectory:
|
|
896
|
+
packageDirectory: (0, import_posix.dirname)(sourceFile)
|
|
869
897
|
};
|
|
870
898
|
}
|
|
871
899
|
if (base === APP_MODULE) {
|
|
@@ -875,7 +903,7 @@ function parseVirtualModuleId(inputModuleId) {
|
|
|
875
903
|
}
|
|
876
904
|
function parseAppModuleId(sourceFile, moduleId) {
|
|
877
905
|
var _a, _b;
|
|
878
|
-
const packageDirectory =
|
|
906
|
+
const packageDirectory = (0, import_posix.dirname)(sourceFile);
|
|
879
907
|
if (moduleId.match(APP_META_RE)) {
|
|
880
908
|
const type = "app-meta";
|
|
881
909
|
return { type, packageDirectory };
|
|
@@ -958,7 +986,7 @@ export {
|
|
|
958
986
|
}
|
|
959
987
|
|
|
960
988
|
// src/codegenPlugin.ts
|
|
961
|
-
|
|
989
|
+
var import_promises3 = require("node:fs/promises");
|
|
962
990
|
|
|
963
991
|
// src/codegen/generateReactHooks.ts
|
|
964
992
|
function generateReactHooks(packageName, runtimeModuleId) {
|
|
@@ -976,10 +1004,10 @@ export const useIntl = /*@__PURE__*/ useIntlInternal.bind(undefined, PACKAGE_NAM
|
|
|
976
1004
|
}
|
|
977
1005
|
|
|
978
1006
|
// src/codegen/generateI18n.ts
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
var INDEX_TEMPLATE =
|
|
1007
|
+
var nodes2 = __toESM(require("@babel/types"));
|
|
1008
|
+
var import_template2 = __toESM(require("@babel/template"));
|
|
1009
|
+
var import_generator2 = __toESM(require("@babel/generator"));
|
|
1010
|
+
var INDEX_TEMPLATE = import_template2.default.program(`
|
|
983
1011
|
export const locales = %%LOCALES_ARRAY%%;
|
|
984
1012
|
|
|
985
1013
|
export function loadMessages(locale) {
|
|
@@ -987,10 +1015,10 @@ var INDEX_TEMPLATE = template2.program(`
|
|
|
987
1015
|
throw new Error(\`Unsupported locale: '\${locale}'\`);
|
|
988
1016
|
}
|
|
989
1017
|
`);
|
|
990
|
-
var IMPORT_TEMPLATE =
|
|
1018
|
+
var IMPORT_TEMPLATE = import_template2.default.statement(`
|
|
991
1019
|
return import(%%MODULE_ID%%).then(mod => mod.default);
|
|
992
1020
|
`);
|
|
993
|
-
var MESSAGES_TEMPLATE =
|
|
1021
|
+
var MESSAGES_TEMPLATE = import_template2.default.program(`
|
|
994
1022
|
const messages = JSON.parse(%%SERIALIZED%%);
|
|
995
1023
|
export default messages;
|
|
996
1024
|
`);
|
|
@@ -1016,7 +1044,7 @@ function generateI18nIndex(packageDirectory, locales) {
|
|
|
1016
1044
|
LOCALES_ARRAY: localesArray,
|
|
1017
1045
|
LOCALE_SWITCH: switchStmt
|
|
1018
1046
|
});
|
|
1019
|
-
return
|
|
1047
|
+
return (0, import_generator2.default)(program2).code;
|
|
1020
1048
|
}
|
|
1021
1049
|
async function generateI18nMessages(options) {
|
|
1022
1050
|
const { locale, appName, packages, loadI18n } = options;
|
|
@@ -1068,7 +1096,7 @@ async function generateI18nMessages(options) {
|
|
|
1068
1096
|
const program2 = MESSAGES_TEMPLATE({
|
|
1069
1097
|
SERIALIZED: nodes2.stringLiteral(serialized)
|
|
1070
1098
|
});
|
|
1071
|
-
return
|
|
1099
|
+
return (0, import_generator2.default)(program2).code;
|
|
1072
1100
|
}
|
|
1073
1101
|
|
|
1074
1102
|
// src/codegenPlugin.ts
|
|
@@ -1103,7 +1131,7 @@ function codegenPlugin() {
|
|
|
1103
1131
|
configureServer(server) {
|
|
1104
1132
|
devServer = server;
|
|
1105
1133
|
server.watcher.on("all", (_, path) => {
|
|
1106
|
-
const moduleIds = manualDeps.get(
|
|
1134
|
+
const moduleIds = manualDeps.get((0, import_vite3.normalizePath)(path));
|
|
1107
1135
|
if (!moduleIds) {
|
|
1108
1136
|
return;
|
|
1109
1137
|
}
|
|
@@ -1129,14 +1157,14 @@ function codegenPlugin() {
|
|
|
1129
1157
|
return moduleId;
|
|
1130
1158
|
}
|
|
1131
1159
|
const getPackageDirectory = () => {
|
|
1132
|
-
const packageJsonPath = findPackageJson(
|
|
1160
|
+
const packageJsonPath = findPackageJson((0, import_node_path3.dirname)(importer), config.root);
|
|
1133
1161
|
if (!packageJsonPath) {
|
|
1134
1162
|
throw new ReportableError(
|
|
1135
1163
|
`Failed to find package.json for package from '${importer}'.`
|
|
1136
1164
|
);
|
|
1137
1165
|
}
|
|
1138
|
-
const packageDir =
|
|
1139
|
-
return
|
|
1166
|
+
const packageDir = (0, import_node_path3.dirname)(packageJsonPath);
|
|
1167
|
+
return (0, import_vite3.normalizePath)(packageDir);
|
|
1140
1168
|
};
|
|
1141
1169
|
if (moduleId === "open-pioneer:app") {
|
|
1142
1170
|
return serializeModuleId({
|
|
@@ -1185,7 +1213,7 @@ function codegenPlugin() {
|
|
|
1185
1213
|
const context = buildMetadataContext(this, moduleId, devServer, manualDeps);
|
|
1186
1214
|
const appMetadata = await repository.getAppMetadata(
|
|
1187
1215
|
context,
|
|
1188
|
-
|
|
1216
|
+
(0, import_node_path3.dirname)(packageJsonPath)
|
|
1189
1217
|
);
|
|
1190
1218
|
switch (mod.type) {
|
|
1191
1219
|
case "app-packages": {
|
|
@@ -1253,7 +1281,7 @@ function reportError(ctx, error) {
|
|
|
1253
1281
|
});
|
|
1254
1282
|
}
|
|
1255
1283
|
function addManualDep(manualDeps, file, moduleId) {
|
|
1256
|
-
const normalizedPath =
|
|
1284
|
+
const normalizedPath = (0, import_vite3.normalizePath)(file);
|
|
1257
1285
|
let moduleIds = manualDeps.get(normalizedPath);
|
|
1258
1286
|
if (!moduleIds) {
|
|
1259
1287
|
moduleIds = /* @__PURE__ */ new Set();
|
|
@@ -1264,14 +1292,14 @@ function addManualDep(manualDeps, file, moduleId) {
|
|
|
1264
1292
|
function findPackageJson(startDir, rootDir) {
|
|
1265
1293
|
let dir = startDir;
|
|
1266
1294
|
while (dir) {
|
|
1267
|
-
const candidate =
|
|
1268
|
-
if (existsSync(candidate)) {
|
|
1295
|
+
const candidate = (0, import_node_path3.join)(dir, "package.json");
|
|
1296
|
+
if ((0, import_node_fs.existsSync)(candidate)) {
|
|
1269
1297
|
return candidate;
|
|
1270
1298
|
}
|
|
1271
|
-
if (
|
|
1299
|
+
if ((0, import_vite3.normalizePath)(dir) == (0, import_vite3.normalizePath)(rootDir)) {
|
|
1272
1300
|
return void 0;
|
|
1273
1301
|
}
|
|
1274
|
-
const parent =
|
|
1302
|
+
const parent = (0, import_node_path3.dirname)(dir);
|
|
1275
1303
|
dir = parent === dir || parent === "." ? "" : parent;
|
|
1276
1304
|
}
|
|
1277
1305
|
return void 0;
|
|
@@ -1279,7 +1307,7 @@ function findPackageJson(startDir, rootDir) {
|
|
|
1279
1307
|
async function getPackageName(ctx, packageJsonPath) {
|
|
1280
1308
|
let name;
|
|
1281
1309
|
try {
|
|
1282
|
-
const content = await
|
|
1310
|
+
const content = await (0, import_promises3.readFile)(packageJsonPath, "utf-8");
|
|
1283
1311
|
name = JSON.parse(content).name;
|
|
1284
1312
|
} catch (e) {
|
|
1285
1313
|
throw new ReportableError(`Failed to read package.json file`, { cause: e });
|
|
@@ -1291,10 +1319,10 @@ async function getPackageName(ctx, packageJsonPath) {
|
|
|
1291
1319
|
}
|
|
1292
1320
|
|
|
1293
1321
|
// src/mpaPlugin.ts
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1322
|
+
var import_node_fs2 = require("node:fs");
|
|
1323
|
+
var import_node_path4 = require("node:path");
|
|
1324
|
+
var import_node_path5 = require("node:path");
|
|
1325
|
+
var import_node_process = require("node:process");
|
|
1298
1326
|
function mpaPlugin(options) {
|
|
1299
1327
|
const rootSite = (options == null ? void 0 : options.rootSite) ?? false;
|
|
1300
1328
|
const apps = (options == null ? void 0 : options.apps) || [];
|
|
@@ -1303,7 +1331,7 @@ function mpaPlugin(options) {
|
|
|
1303
1331
|
return {
|
|
1304
1332
|
name: "pioneer:mpa",
|
|
1305
1333
|
config(config) {
|
|
1306
|
-
const sourceRoot = config.root ?? cwd();
|
|
1334
|
+
const sourceRoot = config.root ?? (0, import_node_process.cwd)();
|
|
1307
1335
|
const { entryPoints, appNames } = gatherEntryPoints({
|
|
1308
1336
|
apps,
|
|
1309
1337
|
sites,
|
|
@@ -1317,10 +1345,10 @@ function mpaPlugin(options) {
|
|
|
1317
1345
|
if (appNames.includes(chunk.name)) {
|
|
1318
1346
|
return "[name].js";
|
|
1319
1347
|
}
|
|
1320
|
-
return posix.join(resolvedConfig.build.assetsDir, "[hash:12].js");
|
|
1348
|
+
return import_node_path5.posix.join(resolvedConfig.build.assetsDir, "[hash:12].js");
|
|
1321
1349
|
},
|
|
1322
1350
|
chunkFileNames(chunk) {
|
|
1323
|
-
return posix.join(resolvedConfig.build.assetsDir, "[hash:12].js");
|
|
1351
|
+
return import_node_path5.posix.join(resolvedConfig.build.assetsDir, "[hash:12].js");
|
|
1324
1352
|
}
|
|
1325
1353
|
}
|
|
1326
1354
|
};
|
|
@@ -1339,7 +1367,7 @@ function gatherEntryPoints(options) {
|
|
|
1339
1367
|
let apps;
|
|
1340
1368
|
if (Array.isArray(options.apps)) {
|
|
1341
1369
|
apps = options.apps.map((appName) => {
|
|
1342
|
-
const prefix = resolve(options.sourceRoot, "apps", appName, "app");
|
|
1370
|
+
const prefix = (0, import_node_path4.resolve)(options.sourceRoot, "apps", appName, "app");
|
|
1343
1371
|
const path = findMatchingEntryPointFile(appName, prefix);
|
|
1344
1372
|
return {
|
|
1345
1373
|
name: appName,
|
|
@@ -1348,8 +1376,8 @@ function gatherEntryPoints(options) {
|
|
|
1348
1376
|
});
|
|
1349
1377
|
} else {
|
|
1350
1378
|
apps = Object.entries(options.apps).map(([name, appPath]) => {
|
|
1351
|
-
const path = resolve(options.sourceRoot, appPath);
|
|
1352
|
-
if (!
|
|
1379
|
+
const path = (0, import_node_path4.resolve)(options.sourceRoot, appPath);
|
|
1380
|
+
if (!(0, import_node_fs2.existsSync)(path)) {
|
|
1353
1381
|
throw new Error(
|
|
1354
1382
|
`Failed to find app '${name}' at ${path}. Ensure that the path is spelled correctly.`
|
|
1355
1383
|
);
|
|
@@ -1358,8 +1386,8 @@ function gatherEntryPoints(options) {
|
|
|
1358
1386
|
});
|
|
1359
1387
|
}
|
|
1360
1388
|
const sites = options.sites.map((sitePath) => {
|
|
1361
|
-
const path = resolve(options.sourceRoot, sitePath, "index.html");
|
|
1362
|
-
if (!
|
|
1389
|
+
const path = (0, import_node_path4.resolve)(options.sourceRoot, sitePath, "index.html");
|
|
1390
|
+
if (!(0, import_node_fs2.existsSync)(path)) {
|
|
1363
1391
|
throw new Error(
|
|
1364
1392
|
`Failed to find site at ${path}. Ensure that the site name in your vite configuration is spelled correctly.`
|
|
1365
1393
|
);
|
|
@@ -1370,8 +1398,8 @@ function gatherEntryPoints(options) {
|
|
|
1370
1398
|
};
|
|
1371
1399
|
});
|
|
1372
1400
|
if (options.rootSite) {
|
|
1373
|
-
const path = resolve(options.sourceRoot, "index.html");
|
|
1374
|
-
if (!
|
|
1401
|
+
const path = (0, import_node_path4.resolve)(options.sourceRoot, "index.html");
|
|
1402
|
+
if (!(0, import_node_fs2.existsSync)(path)) {
|
|
1375
1403
|
throw new Error(
|
|
1376
1404
|
`Failed to find root site at ${path}. Create the missing file or set 'rootSite' to false.`
|
|
1377
1405
|
);
|
|
@@ -1408,7 +1436,7 @@ var EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
|
|
|
1408
1436
|
function findMatchingEntryPointFile(appName, prefix) {
|
|
1409
1437
|
for (const ext of EXTENSIONS) {
|
|
1410
1438
|
const candidate = prefix + ext;
|
|
1411
|
-
if (
|
|
1439
|
+
if ((0, import_node_fs2.existsSync)(candidate)) {
|
|
1412
1440
|
return candidate;
|
|
1413
1441
|
}
|
|
1414
1442
|
}
|
|
@@ -1422,7 +1450,8 @@ function findMatchingEntryPointFile(appName, prefix) {
|
|
|
1422
1450
|
function pioneer(options) {
|
|
1423
1451
|
return [mpaPlugin(options), codegenPlugin()];
|
|
1424
1452
|
}
|
|
1425
|
-
export
|
|
1453
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1454
|
+
0 && (module.exports = {
|
|
1426
1455
|
pioneer
|
|
1427
|
-
};
|
|
1456
|
+
});
|
|
1428
1457
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/codegenPlugin.ts", "../src/utils/debug.ts", "../src/codegen/generatePackagesMetadata.ts", "../src/ReportableError.ts", "../src/codegen/IdGenerator.ts", "../src/metadata/MetadataRepository.ts", "../src/utils/fileUtils.ts", "../src/utils/Cache.ts", "../src/metadata/parseBuildConfig.ts", "../src/metadata/parseI18nYaml.ts", "../src/utils/package.ts", "../src/codegen/generateCombinedCss.ts", "../src/codegen/shared.ts", "../src/codegen/generateAppMetadata.ts", "../src/codegen/generateReactHooks.ts", "../src/codegen/generateI18n.ts", "../src/mpaPlugin.ts"
|
|
4
|
-
"sourcesContent": ["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { PluginContext } from \"rollup\";\nimport { normalizePath, Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport { createDebugger } from \"./utils/debug\";\nimport { generatePackagesMetadata } from \"./codegen/generatePackagesMetadata\";\nimport { MetadataContext, MetadataRepository } from \"./metadata/MetadataRepository\";\nimport { generateCombinedCss } from \"./codegen/generateCombinedCss\";\nimport { generateAppMetadata } from \"./codegen/generateAppMetadata\";\nimport { parseVirtualModuleId, serializeModuleId } from \"./codegen/shared\";\nimport { readFile } from \"node:fs/promises\";\nimport { generateReactHooks } from \"./codegen/generateReactHooks\";\nimport { ReportableError } from \"./ReportableError\";\nimport { generateI18nIndex, generateI18nMessages } from \"./codegen/generateI18n\";\n\nconst isDebug = !!process.env.DEBUG;\nconst debug = createDebugger(\"open-pioneer:codegen\");\n\nexport function codegenPlugin(): Plugin {\n // key: normalized path to package json.\n // value: set of module ids that must be invalidated.\n const manualDeps = new Map<string, Set<string>>();\n\n let config!: ResolvedConfig;\n let repository!: MetadataRepository;\n let devServer: ViteDevServer | undefined;\n\n let reactIntegrationId!: string;\n let metadataId!: string;\n return {\n name: \"pioneer:codegen\",\n\n async buildStart(this: PluginContext) {\n manualDeps.clear();\n repository?.reset();\n\n // TODO: use require.resolve instead (requires built js?).\n const resolve = async (rawModuleId: string) => {\n const resolvedResult = await this.resolve(rawModuleId, __filename);\n if (!resolvedResult) {\n this.error(`Failed to find '${rawModuleId}'.`);\n }\n return resolvedResult.id;\n };\n\n reactIntegrationId = await resolve(\"@open-pioneer/runtime/react-integration\");\n metadataId = await resolve(\"@open-pioneer/runtime/metadata\");\n },\n\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n repository = new MetadataRepository(config.root);\n },\n\n configureServer(server) {\n devServer = server;\n\n // Trigger manual module reload when a watched file changes.\n server.watcher.on(\"all\", (_, path) => {\n const moduleIds = manualDeps.get(normalizePath(path));\n if (!moduleIds) {\n return;\n }\n\n isDebug && debug(`File changed: ${path}`);\n repository.onFileChanged(path);\n for (const moduleId of moduleIds) {\n const mod = server.moduleGraph.getModuleById(moduleId);\n if (mod) {\n isDebug && debug(`Triggering hmr of ${moduleId}`);\n server.reloadModule(mod).catch((err) => {\n config.logger.error(`Failed to trigger hmr`, { error: err });\n });\n }\n }\n });\n },\n\n async resolveId(this: PluginContext, moduleId, importer) {\n try {\n if (!importer) {\n return undefined;\n }\n\n if (parseVirtualModuleId(moduleId)) {\n return moduleId;\n }\n\n const getPackageDirectory = () => {\n const packageJsonPath = findPackageJson(dirname(importer), config.root);\n if (!packageJsonPath) {\n throw new ReportableError(\n `Failed to find package.json for package from '${importer}'.`\n );\n }\n\n const packageDir = dirname(packageJsonPath);\n return normalizePath(packageDir);\n };\n\n if (moduleId === \"open-pioneer:app\") {\n return serializeModuleId({\n type: \"app-meta\",\n packageDirectory: getPackageDirectory()\n });\n }\n if (moduleId === \"open-pioneer:react-hooks\") {\n return serializeModuleId({\n type: \"package-hooks\",\n packageDirectory: getPackageDirectory()\n });\n }\n } catch (e) {\n reportError(this, e);\n }\n },\n\n async load(this: PluginContext, moduleId) {\n try {\n const mod = parseVirtualModuleId(moduleId);\n if (!mod) {\n return undefined;\n }\n\n isDebug && debug(\"Loading virtual module %O\", mod);\n\n // During development we will observe directories like \"/packages/foo\" (i.e. not fully resolved).\n // This uses the dev server to attempt to resolve the directory back to a complete path.\n // Hit me up if you know a better way to do this.\n const packageJsonPath = (await this.resolve(mod.packageDirectory + \"/package.json\"))\n ?.id;\n if (!packageJsonPath) {\n throw new ReportableError(\n `Failed to resolve package.json in ${mod.packageDirectory}`\n );\n }\n\n if (mod.type === \"package-hooks\") {\n const directory = mod.packageDirectory;\n // use forward slashes instead of platform separator\n const packageJsonPath = (await this.resolve(directory + \"/package.json\"))?.id;\n if (!packageJsonPath) {\n throw new ReportableError(`Failed to resolve package.json in ${directory}`);\n }\n\n const packageName = await getPackageName(this, packageJsonPath);\n const generatedSourceCode = generateReactHooks(packageName, reactIntegrationId);\n isDebug && debug(\"Generated hooks code: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n\n if (mod.type === \"app-meta\") {\n return generateAppMetadata(mod.packageDirectory, metadataId);\n }\n\n const context = buildMetadataContext(this, moduleId, devServer, manualDeps);\n const appMetadata = await repository.getAppMetadata(\n context,\n dirname(packageJsonPath)\n );\n switch (mod.type) {\n case \"app-packages\": {\n const generatedSourceCode = generatePackagesMetadata({\n appName: appMetadata.name,\n packages: appMetadata.packages\n });\n isDebug && debug(\"Generated app metadata: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n case \"app-css\": {\n const generatedSourceCode = generateCombinedCss(appMetadata.packages);\n isDebug && debug(\"Generated app css: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n case \"app-i18n-index\": {\n const generatedSourceCode = generateI18nIndex(\n mod.packageDirectory,\n appMetadata.locales\n );\n isDebug && debug(\"Generated i18n lookup: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n case \"app-i18n\": {\n const generatedSourceCode = await generateI18nMessages({\n locale: mod.locale,\n appName: appMetadata.name,\n packages: appMetadata.packages,\n loadI18n(path) {\n return repository.getI18nFile(context, path);\n }\n });\n isDebug && debug(\"Generated i18n messages: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n }\n } catch (e) {\n reportError(this, e);\n }\n }\n };\n}\n\n// Patches the addWatchFile function for manual watching\nfunction buildMetadataContext(\n ctx: PluginContext,\n moduleId: string,\n devServer: ViteDevServer | undefined,\n manualDeps: Map<string, Set<string>>\n): MetadataContext {\n return {\n warn: ctx.warn,\n resolve: ctx.resolve,\n addWatchFile: (id) => {\n if (devServer) {\n // TODO: Is there a better way? We want to trigger a hot reload when\n // one of the build.config files or package.json files change!\n isDebug && debug(`Adding manual watch for ${id}`);\n devServer.watcher.add(id);\n addManualDep(manualDeps, id, moduleId);\n }\n ctx.addWatchFile(id);\n }\n };\n}\n\nfunction reportError(ctx: PluginContext, error: unknown) {\n if (error instanceof ReportableError) {\n ctx.error(error);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const message = String((error as any).message) || \"Unknown error\";\n ctx.error({\n message: \"Internal error: \" + message,\n cause: error\n });\n}\n\nfunction addManualDep(manualDeps: Map<string, Set<string>>, file: string, moduleId: string) {\n const normalizedPath = normalizePath(file);\n let moduleIds = manualDeps.get(normalizedPath);\n if (!moduleIds) {\n moduleIds = new Set();\n manualDeps.set(normalizedPath, moduleIds);\n }\n moduleIds.add(moduleId);\n}\n\nfunction findPackageJson(startDir: string, rootDir: string) {\n let dir = startDir;\n while (dir) {\n const candidate = join(dir, \"package.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n\n if (normalizePath(dir) == normalizePath(rootDir)) {\n return undefined;\n }\n\n const parent = dirname(dir);\n dir = parent === dir || parent === \".\" ? \"\" : parent;\n }\n return undefined;\n}\n\nasync function getPackageName(ctx: PluginContext, packageJsonPath: string) {\n let name: string;\n try {\n const content = await readFile(packageJsonPath, \"utf-8\");\n name = JSON.parse(content).name;\n } catch (e) {\n throw new ReportableError(`Failed to read package.json file`, { cause: e });\n }\n if (!name) {\n throw new ReportableError(`Failed to read package name from ${packageJsonPath}.`);\n }\n return name;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { debug } from \"debug\";\n\nexport interface Debugger {\n (msg: string, ...args: unknown[]): void;\n}\n\nexport function createDebugger(namespace: string): Debugger {\n const logger = debug(namespace);\n return function debugFunction(...args) {\n logger(...args);\n };\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport generate from \"@babel/generator\";\nimport template from \"@babel/template\";\nimport * as nodes from \"@babel/types\";\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\nimport { ReportableError } from \"../ReportableError\";\nimport { IdGenerator } from \"./IdGenerator\";\nimport { PackageOverrides, Reference, UiReference } from \"@open-pioneer/build-common\";\n\nconst SERVICE_IMPORT = template.statement(`\n import { %%SERVICE_NAME%% as %%IMPORT_NAME%% } from %%IMPORT_SOURCE%%;\n`);\n\nconst PKG_OBJECT = template.expression(`\n {\n name: %%PACKAGE_NAME%%,\n services: %%PACKAGE_SERVICES%%,\n ui: %%PACKAGE_UI%%,\n properties: %%PROPERTIES%%\n }\n`);\n\nconst SERVICE_OBJECT = template.expression(`\n {\n name: %%SERVICE_NAME%%,\n clazz: %%SERVICE_IMPORT%%,\n provides: %%SERVICE_INTERFACES%%,\n references: %%SERVICE_REFERENCES%%\n }\n`);\n\nconst INTERFACE_OBJECT = template.expression(`\n {\n name: %%INTERFACE_NAME%%,\n qualifier: %%QUALIFIER%%\n }\n`);\n\nconst REFERENCE_OBJECT = template.expression(`\n {\n name: %%INTERFACE_NAME%%,\n qualifier: %%QUALIFIER%%,\n all: %%ALL%%\n }\n`);\n\nconst UI_OBJECT = template.expression(`\n {\n references: %%UI_REFERENCES%%\n }\n`);\n\nconst PROPERTY_OBJECT = template.expression(`\n {\n value: %%VALUE%%,\n required: %%REQUIRED%%\n }\n`);\n\nexport type PackageMetadataInput = Pick<PackageMetadata, \"name\" | \"config\" | \"servicesModulePath\">;\n\nexport interface PackageMetadataOptions {\n /**\n * The name of the current application.\n * Used to detect the application page for overrides.\n */\n appName: string;\n\n /**\n * Set of packages to generate code for.\n */\n packages: PackageMetadataInput[];\n}\n\n/**\n * Generates a combined metadata structure that is essentially a Record<string, metadata.PackageMetadata>.\n * The object contents must match the shape required by the runtime (declared in runtime/metadata/index.ts).\n */\nexport function generatePackagesMetadata({ appName, packages }: PackageMetadataOptions): string {\n const idGenerator = new IdGenerator();\n const packagesMetadata = nodes.objectExpression([]);\n const imports: nodes.Statement[] = [];\n\n let overrides: Map<string, PackageOverrides> | undefined;\n for (const pkg of packages) {\n if (pkg.name === appName) {\n overrides = pkg.config.overrides;\n } else if (pkg.config.overrides.size > 0) {\n throw new ReportableError(\n `Unexpected 'overrides' in package '${pkg.name}'. Overrides are only supported in the app.`\n );\n }\n }\n\n for (const pkg of packages) {\n const packageOverrides = overrides?.get(pkg.name);\n const packageMetadata = generatePackageMetadata(pkg, {\n enableService(serviceName) {\n return packageOverrides?.services?.get(serviceName)?.enabled ?? true;\n },\n importServiceClass(variableName, className, moduleId) {\n const id = idGenerator.generate(variableName);\n const renderedImporter = SERVICE_IMPORT({\n SERVICE_NAME: nodes.identifier(className),\n IMPORT_NAME: nodes.identifier(id),\n IMPORT_SOURCE: nodes.stringLiteral(moduleId)\n });\n imports.push(renderedImporter);\n return id;\n }\n });\n packagesMetadata.properties.push(\n nodes.objectProperty(nodes.stringLiteral(pkg.name), packageMetadata)\n );\n }\n\n const program = nodes.program([...imports, nodes.exportDefaultDeclaration(packagesMetadata)]);\n return generate(program).code;\n}\n\n/**\n * Generates the metadata object for a single package.\n * As a side effect, service imports for required service classes will be emitted through a callback.\n */\nfunction generatePackageMetadata(\n pkg: PackageMetadataInput,\n options: {\n /**\n * Adds an import to the containing module.\n * Returns the actual variable name associated with the service.\n */\n importServiceClass(variableName: string, className: string, entryPoint: string): string;\n\n /**\n * Returns true if the service shall be included in the generated code, false otherwise.\n */\n enableService(serviceName: string): boolean;\n }\n): nodes.Expression {\n const servicesObject = nodes.objectExpression([]);\n for (const service of pkg.config.services.values()) {\n if (!options.enableService(service.serviceName)) {\n continue;\n }\n\n if (!pkg.servicesModulePath) {\n throw new ReportableError(\n `Package '${pkg.name}' must have a valid services module (typically 'services.ts' or 'services.js').\\n` +\n \"The entry point can be configured by setting the 'servicesModule' property in the build.config.mjs.\"\n );\n }\n\n const importName = options.importServiceClass(\n pkg.name + \"_\" + service.serviceName,\n service.serviceName,\n pkg.servicesModulePath\n );\n const serviceObject = SERVICE_OBJECT({\n SERVICE_NAME: nodes.stringLiteral(service.serviceName),\n SERVICE_IMPORT: nodes.identifier(importName),\n SERVICE_INTERFACES: nodes.arrayExpression(\n service.provides.map((p) =>\n INTERFACE_OBJECT({\n INTERFACE_NAME: nodes.stringLiteral(p.interfaceName),\n QUALIFIER:\n p.qualifier == null ? undefinedNode() : nodes.stringLiteral(p.qualifier)\n })\n )\n ),\n SERVICE_REFERENCES: nodes.objectExpression(\n Array.from(service.references.entries()).map(([referenceName, referenceConfig]) =>\n nodes.objectProperty(\n nodes.stringLiteral(referenceName),\n referenceObject(referenceConfig)\n )\n )\n )\n });\n\n servicesObject.properties.push(\n nodes.objectProperty(nodes.stringLiteral(service.serviceName), serviceObject)\n );\n }\n\n const uiObject = UI_OBJECT({\n UI_REFERENCES: nodes.arrayExpression(pkg.config.uiReferences.map((r) => referenceObject(r)))\n });\n\n const propertiesObject = nodes.objectExpression(\n Array.from(pkg.config.properties.values()).map((prop) =>\n nodes.objectProperty(\n nodes.stringLiteral(prop.propertyName),\n PROPERTY_OBJECT({\n VALUE: jsonToExpression(prop.defaultValue),\n REQUIRED: nodes.booleanLiteral(prop.required)\n })\n )\n )\n );\n\n const pkgObject = PKG_OBJECT({\n PACKAGE_NAME: nodes.stringLiteral(pkg.name),\n PACKAGE_SERVICES: servicesObject,\n PACKAGE_UI: uiObject,\n PROPERTIES: propertiesObject\n });\n return pkgObject;\n}\n\nfunction jsonToExpression(json: unknown): nodes.Expression {\n if (json == null) {\n return nodes.nullLiteral();\n }\n if (typeof json === \"string\") {\n return nodes.stringLiteral(json);\n }\n if (typeof json === \"number\") {\n return nodes.numericLiteral(json);\n }\n if (typeof json === \"boolean\") {\n return nodes.booleanLiteral(json);\n }\n if (Array.isArray(json)) {\n return nodes.arrayExpression(json.map((item) => jsonToExpression(item)));\n }\n if (typeof json === \"object\") {\n return nodes.objectExpression(\n Object.entries(json).map(([name, value]) =>\n nodes.objectProperty(nodes.stringLiteral(name), jsonToExpression(value))\n )\n );\n }\n throw new Error(`Unexpected value while serializing JSON: ${json}.`);\n}\n\nfunction referenceObject(ref: Reference | UiReference): nodes.Expression {\n return REFERENCE_OBJECT({\n INTERFACE_NAME: nodes.stringLiteral(ref.interfaceName),\n QUALIFIER: ref.qualifier ? nodes.stringLiteral(ref.qualifier) : undefinedNode(),\n ALL: nodes.booleanLiteral(ref.type === \"all\" ? true : false) // TODO: Rework internal app format\n });\n}\n\nfunction undefinedNode() {\n return nodes.unaryExpression(\"void\", nodes.numericLiteral(0));\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport class ReportableError extends Error {}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport class IdGenerator {\n private existing = new Map<string, number>();\n\n /**\n * Returns a unique identifier (in the context of this instance) that resembles the input value.\n */\n generate(input: string): string {\n const clean = cleanName(input);\n\n const existing = this.existing;\n const count = existing.get(clean) ?? 0;\n existing.set(clean, count + 1);\n return count === 0 ? clean : `${clean}_${count}`;\n }\n}\n\nfunction cleanName(input: string) {\n let clean = input.replace(/[^A-Za-z0-9_]+/g, \"_\"); // remove non-alphanumeric\n clean = clean.replace(/[\\d_]+$/, \"\"); // strip trailing numbers / underscore to prevent conflicts\n if (/^\\d/.test(clean)) {\n clean = \"_\" + clean; // ensure variable name does not start with a number\n }\n return clean || \"var\";\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { readFile, realpath } from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { PluginContext, RollupWarning } from \"rollup\";\nimport { PackageData, normalizePath, resolvePackageData } from \"vite\";\nimport { ReportableError } from \"../ReportableError\";\nimport { createDebugger } from \"../utils/debug\";\nimport { fileExists, isInDirectory } from \"../utils/fileUtils\";\nimport { Cache } from \"../utils/Cache\";\nimport { isBuildConfig, loadBuildConfig } from \"./parseBuildConfig\";\nimport { I18nFile, loadI18nFile } from \"./parseI18nYaml\";\nimport {\n BUILD_CONFIG_NAME,\n PackageConfig,\n PackageMetadataV1,\n createPackageConfigFromPackageMetadata\n} from \"@open-pioneer/build-common\";\nimport { PACKAGE_NAME } from \"../utils/package\";\n\nconst isDebug = !!process.env.DEBUG;\nconst debug = createDebugger(\"open-pioneer:metadata\");\n\n/**\n * Contains build-time information about an app.\n */\nexport interface AppMetadata {\n /** App name. */\n name: string;\n\n /** Directory on disk. */\n directory: string;\n\n /** Path to package.json file. */\n packageJsonPath: string;\n\n /** Locales required by the application. */\n locales: string[];\n\n /**\n * Packages used by the app.\n * Includes the app package itself!\n */\n packages: PackageMetadata[];\n}\n\n/**\n * Contains build-time information about a package.\n */\nexport interface PackageMetadata {\n /** */\n type: \"pioneer-package\";\n\n /** Package name. */\n name: string;\n\n /** Directory on disk. */\n directory: string;\n\n /** Path to package.json file. */\n packageJsonPath: string;\n\n /** Path to entry point (contains service exports). */\n servicesModulePath: string | undefined;\n\n /** Path to the resolved css file (if any). */\n cssFilePath: string | undefined;\n\n /**\n * Paths to i18n yaml config for any defined lang in build config.\n * Key: locale, value: file path\n */\n i18nPaths: Map<string, string>;\n\n /** Runtime dependencies (from package.json). */\n dependencies: PackageDependency[];\n\n /** Parsed metadata (from build config file). */\n config: PackageConfig;\n}\n\nexport interface PackageDependency {\n packageName: string;\n optional: boolean;\n}\n\n/**\n * Package that was discovered during dependency analysis which does not have open-pioneer metadata.\n * We cache such objects to remember the result of the analysis.\n */\ninterface PlainPackageMetadata {\n type: \"plain\";\n\n /** Package name. */\n name: string;\n\n /** Directory on disk. */\n directory: string;\n}\n\ntype InternalPackageMetadata = PackageMetadata | PlainPackageMetadata;\n\nexport type MetadataContext = Pick<PluginContext, \"addWatchFile\" | \"resolve\" | \"warn\">;\n\nexport interface ResolvedPackageLocation {\n type: \"absolute\";\n directory: string;\n}\n\nexport interface UnresolvedDependency {\n type: \"unresolved\";\n dependency: PackageDependency;\n importedFrom: string;\n}\n\nexport type PackageLocation = ResolvedPackageLocation | UnresolvedDependency;\n\n/**\n * Tracks metadata and the files that were used to parse that metadata.\n * watchFiles should be propagated when a caller receives a cached result,\n * otherwise hot reloading may not be triggered correctly on file changes.\n */\ninterface MetadataEntry {\n metadata: InternalPackageMetadata;\n watchFiles: ReadonlySet<string>;\n warnings: RollupWarning[];\n}\n\ninterface I18nEntry {\n i18n: I18nFile;\n watchFiles: ReadonlySet<string>;\n}\n\n/**\n * Provides metadata about apps and packages.\n * Metadata is read from disk on demand and will then be cached\n * until one of the file dependencies has changed.\n */\nexport class MetadataRepository {\n private sourceRoot: string;\n\n // Key: package directory on disk, value: existing metadata\n private packageMetadataCache: Cache<string, MetadataEntry, [ctx: MetadataContext]>;\n\n // Cache for the contents of i18n files.\n // Key: path on disk.\n private i18nCache: Cache<string, I18nEntry, [ctx: MetadataContext]>;\n\n // Cache for package locations & package.json contents\n private packageDataCache = new Map<string, PackageData>();\n\n /**\n * @param sourceRoot Source folder on disk, needed to detect 'local' packages\n */\n constructor(sourceRoot: string) {\n this.sourceRoot = sourceRoot;\n this.packageMetadataCache = this.createPackageMetadataCache();\n this.i18nCache = this.createI18nCache();\n }\n\n reset() {\n this.packageMetadataCache = this.createPackageMetadataCache();\n this.i18nCache = this.createI18nCache();\n this.packageDataCache.clear();\n }\n\n /**\n * Called by the plugin when a file has been changed.\n * The cached data associated with that file (if any) will be removed.\n */\n onFileChanged(path: string) {\n if (isPackageJson(path) || isBuildConfig(path)) {\n this.packageMetadataCache.invalidate(dirname(path));\n }\n this.i18nCache.invalidate(path);\n }\n\n /**\n * Returns the combined application metadata of the app in `appDirectory`.\n * Starting from the app's package.json, dependencies will be visited recursively.\n *\n * For packages that use our package extensions (services etc.), metadata will be gathered and\n * will be returned here.\n */\n async getAppMetadata(ctx: MetadataContext, appDirectory: string): Promise<AppMetadata> {\n isDebug && debug(`Request for app metadata of ${appDirectory}`);\n\n const appPackageMetadata = await this.getPackageMetadata(ctx, {\n type: \"absolute\",\n directory: appDirectory\n });\n if (!appPackageMetadata) {\n throw new ReportableError(\n `Failed to parse app metadata in ${appDirectory}. Ensure that the app is a valid local package.`\n );\n }\n\n // App's locales define which locales must be supported.\n const appLocales = Array.from(appPackageMetadata.i18nPaths.keys());\n\n // Map to ensure that we don't return duplicates. Key: package name\n const packageMetadataByName = new Map<string, PackageMetadata>();\n packageMetadataByName.set(appPackageMetadata.name, appPackageMetadata);\n\n // Recursively visit all dependencies.\n // Detected metadata is placed into `packageMetadata`.\n const visitDependencies = async (\n dependencies: PackageDependency[],\n importedFrom: string\n ) => {\n const jobs = dependencies.map(async (dependency) => {\n const packageMetadata = await this.getPackageMetadata(ctx, {\n type: \"unresolved\",\n dependency,\n importedFrom\n });\n if (packageMetadata) {\n if (!packageMetadataByName.has(packageMetadata.name)) {\n packageMetadataByName.set(packageMetadata.name, packageMetadata);\n }\n await visitDependencies(\n packageMetadata.dependencies,\n packageMetadata.packageJsonPath\n );\n }\n });\n return await Promise.all(jobs);\n };\n await visitDependencies(\n appPackageMetadata.dependencies,\n appPackageMetadata.packageJsonPath\n );\n\n const appMetadata: AppMetadata = {\n name: appPackageMetadata.name,\n directory: appPackageMetadata.directory,\n locales: appLocales,\n packageJsonPath: appPackageMetadata.packageJsonPath,\n packages: Array.from(packageMetadataByName.values())\n };\n return appMetadata;\n }\n\n /**\n * Returns package metadata associated with the given package.\n */\n private async getPackageMetadata(\n ctx: MetadataContext,\n loc: PackageLocation\n ): Promise<PackageMetadata | undefined> {\n isDebug && debug(`Request for package metadata of ${formatPackageLocation(loc)}`);\n\n const packageDir = await this.resolvePackageLocation(loc);\n if (!packageDir) {\n // Optional package does not exist\n return undefined;\n }\n\n const entry = await this.packageMetadataCache.get(packageDir, ctx);\n propagateWatchFiles(entry.watchFiles, ctx);\n for (const warning of entry.warnings) {\n ctx.warn(warning);\n }\n\n if (entry.metadata.type === \"plain\") {\n isDebug && debug(`Skipping package '${packageDir}'.`);\n return undefined;\n }\n\n return entry.metadata;\n }\n\n /**\n * Returns the parsed contents of the given i18n file.\n */\n async getI18nFile(ctx: MetadataContext, path: string): Promise<I18nFile> {\n const { i18n, watchFiles } = await this.i18nCache.get(path, ctx);\n propagateWatchFiles(watchFiles, ctx);\n return i18n;\n }\n\n private async resolvePackageLocation(loc: PackageLocation) {\n if (loc.type === \"absolute\") {\n return await realpath(loc.directory);\n }\n\n const { packageName, optional } = loc.dependency;\n const packageData = await resolvePackageData(\n packageName,\n loc.importedFrom,\n false,\n this.packageDataCache\n );\n if (!packageData) {\n if (optional) {\n isDebug && debug(`Optional package '${packageName}' was not found.`);\n return undefined;\n }\n\n throw new ReportableError(\n `Failed to find package '${packageName}' (from '${loc.importedFrom}'), is the dependency installed correctly?`\n );\n }\n\n const packageDir = await realpath(packageData.dir);\n isDebug && debug(`Found package '${packageName}' at ${packageDir}`);\n return packageDir;\n }\n\n private createI18nCache(): Cache<string, I18nEntry, [ctx: MetadataContext]> {\n return new Cache({\n getId(path) {\n return normalizePath(path);\n },\n async getValue(path, ctx) {\n isDebug && debug(`Loading i18n file ${path}`);\n\n // watch before loading. this protects against rare race conditions\n // caused by our manual watch workaround in the codegen plugin.\n // essentially, we must watch for changes BEFORE the files are loaded\n // to get reliable notifications.\n ctx.addWatchFile(path);\n const entry: I18nEntry = {\n i18n: await loadI18nFile(path),\n watchFiles: new Set([path])\n };\n return entry;\n },\n onInvalidate(path) {\n isDebug && debug(`Removed cache entry for i18n file ${path}`);\n },\n onCachedReturn(path) {\n isDebug && debug(`Returning cached entry for i18n file ${path}`);\n }\n });\n }\n\n private createPackageMetadataCache(): Cache<string, MetadataEntry, [ctx: MetadataContext]> {\n const sourceRoot = this.sourceRoot;\n const provider = {\n _byName: new Map<string, PackageMetadata>(),\n\n getId(directory: string) {\n return normalizePath(directory);\n },\n async getValue(directory: string, ctx: MetadataContext): Promise<MetadataEntry> {\n isDebug && debug(`Loading metadata for package at ${directory}`);\n\n const watchFiles = new Set<string>();\n const warnings: RollupWarning[] = [];\n const trackingCtx: MetadataContext = {\n resolve: ctx.resolve,\n addWatchFile(id) {\n ctx.addWatchFile(id);\n watchFiles.add(id);\n },\n warn(msg: string | RollupWarning) {\n warnings.push(typeof msg === \"string\" ? { message: msg } : msg);\n }\n };\n\n const metadata = await parsePackageMetadata(trackingCtx, directory, sourceRoot);\n isDebug && debug(`Metadata for '${metadata.name}': %O`, metadata);\n\n // Ensure only one version of a package exists in the app\n if (metadata.type === \"pioneer-package\") {\n const existingMetadata = this._byName.get(metadata.name);\n if (\n existingMetadata &&\n normalizePath(existingMetadata.directory) !==\n normalizePath(metadata.directory)\n ) {\n throw new ReportableError(\n `Found package '${metadata.name}' at two different locations ${existingMetadata.directory} and ${metadata.directory}`\n );\n }\n this._byName.set(metadata.name, metadata);\n }\n\n return {\n metadata,\n watchFiles,\n warnings\n };\n },\n onInvalidate(directory: string, entry: MetadataEntry) {\n isDebug && debug(`Removed cache entry for '${entry.metadata.name}'`);\n this._byName.delete(entry.metadata.name);\n },\n onCachedReturn(directory: string, entry: MetadataEntry) {\n isDebug && debug(`Returning cached metadata for '${entry.metadata.name}'`);\n }\n };\n return new Cache(provider);\n }\n}\n\nfunction propagateWatchFiles(watchFiles: Iterable<string>, ctx: MetadataContext) {\n for (const file of watchFiles) {\n ctx.addWatchFile(file);\n }\n}\n\n/**\n * Is called if package metadata of a package are parsed\n * (for internal and external packages).\n * Depending on the location of the package either reads build config (source package)\n * or serialized metadata from package.json.\n */\nexport async function parsePackageMetadata(\n ctx: MetadataContext,\n packageDir: string,\n sourceRoot: string\n): Promise<InternalPackageMetadata> {\n const mode = isLocalPackage(packageDir, sourceRoot) ? \"local\" : \"external\";\n\n isDebug && debug(`Visiting package directory ${packageDir} in mode ${mode}.`);\n\n const packageJsonPath = join(packageDir, \"package.json\");\n\n ctx.addWatchFile(packageJsonPath);\n const {\n name: packageName,\n dependencies,\n frameworkMetadata\n } = await parsePackageJson(ctx, packageJsonPath);\n\n const configResult = await readConfig(\n ctx,\n packageDir,\n mode,\n frameworkMetadata,\n packageName,\n packageJsonPath\n );\n if (!configResult) {\n return {\n type: \"plain\",\n name: packageName,\n directory: packageDir\n };\n }\n\n const { config, configPath } = configResult;\n\n let servicesModule: string | undefined;\n if (config.services.size) {\n try {\n servicesModule = await resolveLocalFile(\n ctx,\n packageDir,\n config.servicesModule ?? \"./services\"\n );\n } catch (e) {\n ctx.warn({\n message: `Failed to resolve entry point for package ${packageDir}`,\n cause: e\n });\n }\n }\n\n let cssFile: string | undefined;\n if (config.styles) {\n try {\n cssFile = await resolveLocalFile(ctx, packageDir, config.styles);\n } catch (e) {\n throw new ReportableError(`Failed to resolve css file for package ${packageDir}`, {\n cause: e\n });\n }\n if (!cssFile) {\n throw new ReportableError(\n `Failed to find css file '${config.styles}' in ${packageDir}`\n );\n }\n }\n\n const i18nPaths = new Map<string, string>();\n for (const locale of config.languages) {\n if (i18nPaths.has(locale)) {\n throw new ReportableError(`Locale '${locale}' was defined twice in ${configPath}`);\n }\n\n const path = join(packageDir, \"i18n\", `${locale}.yaml`);\n ctx.addWatchFile(path);\n if (!(await fileExists(path))) {\n throw new ReportableError(`i18n file '${path}' does not exist.`);\n }\n\n i18nPaths.set(locale, normalizePath(path));\n }\n\n return {\n type: \"pioneer-package\",\n name: packageName,\n directory: packageDir,\n packageJsonPath: packageJsonPath,\n servicesModulePath: servicesModule,\n cssFilePath: cssFile,\n i18nPaths,\n dependencies,\n config: config\n };\n}\n\nasync function readConfig(\n ctx: MetadataContext,\n packageDir: string,\n mode: \"local\" | \"external\",\n frameworkMetadata: unknown,\n packageName: string,\n packageJsonPath: string\n) {\n switch (mode) {\n case \"local\": {\n const buildConfigPath = join(packageDir, BUILD_CONFIG_NAME);\n let buildConfig: PackageConfig | undefined;\n ctx.addWatchFile(normalizePath(buildConfigPath));\n if (await fileExists(buildConfigPath)) {\n try {\n buildConfig = await loadBuildConfig(buildConfigPath);\n } catch (e) {\n throw new ReportableError(`Failed to load build config ${buildConfigPath}`, {\n cause: e\n });\n }\n } else {\n throw new ReportableError(`Expected a ${BUILD_CONFIG_NAME} in ${packageDir}`);\n }\n return { configPath: buildConfigPath, config: buildConfig };\n }\n case \"external\": {\n if (!frameworkMetadata) {\n return undefined;\n }\n\n const metadataResult = PackageMetadataV1.parsePackageMetadata(frameworkMetadata);\n if (metadataResult.type === \"error\") {\n if (metadataResult.code === \"unsupported-version\") {\n throw new ReportableError(\n `Package '${packageName}' in ${packageDir} uses an unsupported metadata version.` +\n ` You will likely have to update ${PACKAGE_NAME}.\\n\\n` +\n metadataResult.message,\n { cause: metadataResult.cause }\n );\n }\n\n throw new ReportableError(\n `Failed to parse metadata of package '${packageName}' in ${packageDir}: ${metadataResult.message}`,\n { cause: metadataResult.cause }\n );\n }\n\n return {\n configPath: packageJsonPath,\n config: createPackageConfigFromPackageMetadata(metadataResult.value)\n };\n }\n }\n}\n\nasync function parsePackageJson(ctx: MetadataContext, packageJsonPath: string) {\n if (!(await fileExists(packageJsonPath))) {\n throw new ReportableError(`Expected a 'package.json' file at ${packageJsonPath}`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let packageJsonContent: any;\n try {\n packageJsonContent = JSON.parse(await readFile(packageJsonPath, \"utf-8\"));\n } catch (e) {\n throw new ReportableError(`Failed to read ${packageJsonPath}`, { cause: e });\n }\n\n const packageName = packageJsonContent.name;\n if (typeof packageName !== \"string\") {\n throw new ReportableError(`Expected 'name' to be a string in ${packageJsonPath}`);\n }\n\n // TODO handle peer dependencies\n const dependencies = packageJsonContent.dependencies ?? {};\n if (typeof dependencies !== \"object\") {\n throw new ReportableError(`Expected a valid 'dependencies' object in ${packageJsonPath}`);\n }\n\n const peerDependencies = packageJsonContent.peerDependencies ?? {};\n if (typeof peerDependencies !== \"object\") {\n throw new ReportableError(\n `Expected a valid 'peerDependencies' object in ${packageJsonPath}`\n );\n }\n\n const optionalDependencies = packageJsonContent.optionalDependencies ?? {};\n if (typeof optionalDependencies !== \"object\") {\n throw new ReportableError(\n `Expected a valid 'optionalDependencies' object in ${packageJsonPath}`\n );\n }\n\n const allDependencies: PackageDependency[] = [\n ...Object.keys(dependencies).map((packageName) => ({ packageName, optional: false })),\n ...Object.keys(peerDependencies).map((packageName) => ({\n packageName,\n optional: packageJsonContent?.peerDependenciesMeta?.[packageName]?.optional ?? false\n })),\n ...Object.keys(optionalDependencies).map((packageName) => ({ packageName, optional: true }))\n ];\n\n const frameworkMetadata = packageJsonContent[PackageMetadataV1.PACKAGE_JSON_KEY] ?? undefined;\n return {\n name: packageName,\n dependencies: allDependencies,\n frameworkMetadata: frameworkMetadata\n };\n}\n\nasync function resolveLocalFile(ctx: MetadataContext, packageDir: string, localModuleId: string) {\n const result = await ctx.resolve(`./${localModuleId}`, `${packageDir}/package.json`, {\n skipSelf: true\n });\n return result?.id;\n}\n\nfunction formatPackageLocation(loc: PackageLocation) {\n switch (loc.type) {\n case \"absolute\":\n return `${loc.directory}`;\n case \"unresolved\": {\n let name = `'${loc.dependency.packageName}'`;\n if (loc.dependency.optional) {\n name += \" (optional)\";\n }\n return `${name} required by ${loc.importedFrom}`;\n }\n }\n}\n\nconst NODE_MODULES_RE = /[\\\\/]node_modules[\\\\/]/;\n\nfunction isLocalPackage(file: string, sourceDir: string) {\n return isInDirectory(file, sourceDir) && !NODE_MODULES_RE.test(file);\n}\n\nconst PACKAGE_JSON_RE = /[\\\\/]package\\.json($|\\?)/;\n\nfunction isPackageJson(file: string) {\n return PACKAGE_JSON_RE.test(file);\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport * as fs from \"node:fs\";\nimport { isAbsolute, relative } from \"node:path\";\n\n/**\n * Asynchronously checks for the existence of `file`.\n */\nexport function fileExists(file: string): Promise<boolean> {\n return fs.promises\n .access(file, fs.constants.F_OK)\n .then(() => true)\n .catch(() => false);\n}\n\n/**\n * Returns true if `candidate` is a child of `directory`.\n */\nexport function isInDirectory(candidate: string, directory: string): boolean {\n const rel = relative(directory, candidate);\n const isChild = rel && !rel.startsWith(\"..\") && !isAbsolute(rel);\n return !!isChild;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * A simple cache implementing read-through semantics.\n *\n * The {@link CacheProvider} passed to the cache's constructor\n * implements the actual computation of values.\n *\n * The cache deduplicates computations and caches their results\n * until they are invalidated.\n */\nexport class Cache<Key, Value, Context extends unknown[] = []> {\n private values = new Map<string, Value>();\n private jobs = new Map<string, Promise<Value>>();\n private provider: CacheProvider<Key, Value, Context>;\n\n constructor(provider: CacheProvider<Key, Value, Context>) {\n this.provider = provider;\n }\n\n /**\n * Removes an entry associated with the given key.\n */\n invalidate(key: Key): void {\n const id = this.provider.getId(key);\n const oldValue = this.values.get(id);\n this.values.delete(id);\n this.jobs.delete(id);\n if (oldValue) {\n this.provider.onInvalidate?.(key, oldValue);\n }\n }\n\n /**\n * Retrieves the value associated with `key`.\n * A cached result will be used if present, otherwise the\n * cache provider will be called.\n *\n * Note: computations may throw errors.\n * Errors will not be cached.\n *\n * @param key the lookup key\n * @param context an arbitrary set of values that will be forwarded to the provider\n * should be provider be called.\n * @returns the value associated with `key`\n */\n async get(key: Key, ...context: Context): Promise<Value> {\n const provider = this.provider;\n const id = provider.getId(key);\n\n const values = this.values;\n const existingValue = values.get(id);\n if (existingValue) {\n provider.onCachedReturn?.(key, existingValue);\n return Promise.resolve(existingValue);\n }\n\n const jobs = this.jobs;\n const existingJob = jobs.get(id);\n if (existingJob) {\n return existingJob;\n }\n\n const job = provider.getValue(key, ...context);\n jobs.set(id, job);\n try {\n const value = await job;\n if (jobs.get(id) === job) {\n values.set(id, value);\n }\n return value;\n } finally {\n if (jobs.get(id) === job) {\n jobs.delete(id);\n }\n }\n }\n}\n\nexport interface CacheProvider<Key, Value, Context extends unknown[] = []> {\n /**\n * Maps the `key` to a unique id.\n * The id is used internally to store the result values.\n *\n * Keys mapping to the same `id` are treated as equivalent.\n */\n getId(key: Key): string;\n\n /**\n * Given a `key`, compute its associated `value`.\n * Only one computation for each `key` is started at a time.\n */\n getValue(key: Key, ...context: Context): Promise<Value>;\n\n /**\n * Called when the cache successfully invalidated an old value.\n */\n onInvalidate?(key: Key, oldValue: Value): void;\n\n /**\n * Called when the cache successfully returns a cached result.\n */\n onCachedReturn?(key: Key, value: Value): void;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport {\n BUILD_CONFIG_NAME,\n PackageConfig,\n createPackageConfigFromBuildConfig,\n loadBuildConfig as loadBuildConfigCommon,\n verifyBuildConfig\n} from \"@open-pioneer/build-common\";\nimport { basename } from \"node:path\";\n\n/**\n * Loads and parses a build configuration file from the given path on disk.\n */\nexport async function loadBuildConfig(path: string): Promise<PackageConfig> {\n const rawConfig = await loadBuildConfigCommon(path);\n return createPackageConfigFromBuildConfig(rawConfig);\n}\n\n/**\n * Parses a build configuration object and validates it.\n */\nexport function parseBuildConfig(object: unknown): PackageConfig {\n const rawConfig = verifyBuildConfig(object);\n return createPackageConfigFromBuildConfig(rawConfig);\n}\n\nexport function isBuildConfig(file: string) {\n return basename(file) === BUILD_CONFIG_NAME;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { readFile } from \"fs/promises\";\nimport { load as loadYaml } from \"js-yaml\";\nimport { z } from \"zod\";\nimport { fromZodError } from \"zod-validation-error\";\nimport { ReportableError } from \"../ReportableError\";\n\nexport interface I18nFile {\n /**\n * Direct messages for the current package.\n *\n * Key: message id, Value: message template string\n */\n messages: Map<string, string>;\n\n /**\n * Overrides for other packages.\n * Can be used from an app.\n *\n * Key: package name, Value: message record as in {@link messages}.\n */\n overrides: Map<string, Map<string, string>>;\n}\n\ninterface RawI18nFile {\n messages?: RecursiveMessages | null | undefined;\n overrides?: Record<string, RecursiveMessages | null | undefined> | null | undefined;\n}\n\ninterface RecursiveMessages {\n [key: string]: null | undefined | string | RecursiveMessages;\n}\n\nconst MESSAGES_SCHEMA: z.ZodType<RecursiveMessages | null | undefined> = z.lazy(() =>\n z.record(z.union([z.string(), MESSAGES_SCHEMA])).nullish()\n);\n\n// allow null for empty yaml objects\nconst I18N_SCHEMA: z.ZodType<RawI18nFile | null | undefined> = z\n .strictObject({\n messages: MESSAGES_SCHEMA.nullish().optional(),\n overrides: z.record(MESSAGES_SCHEMA).nullish().optional()\n })\n .nullish();\n\n/**\n * Loads an i18n.yaml file from the file system and parses it.\n */\nexport async function loadI18nFile(path: string): Promise<I18nFile> {\n let content;\n try {\n content = await readFile(path, \"utf-8\");\n } catch (e) {\n throw new ReportableError(`Failed to read ${path}`, { cause: e });\n }\n\n try {\n return parseI18nYaml(content);\n } catch (e) {\n throw new ReportableError(`Failed to parse ${path}`, { cause: e });\n }\n}\n\n/**\n * Parses an i18n yaml document.\n */\nexport function parseI18nYaml(yaml: string): I18nFile {\n const data = loadYaml(yaml);\n return parseI18nFile(data);\n}\n\n/**\n * Parses the JavaScript object representing an i18n file.\n */\nexport function parseI18nFile(data: unknown): I18nFile {\n const result = I18N_SCHEMA.safeParse(data);\n if (!result.success) {\n throw fromZodError(result.error);\n }\n\n const rawI18n = result.data;\n return {\n messages: gatherMessages(rawI18n?.messages ?? undefined),\n overrides: gatherOverrides(rawI18n?.overrides ?? undefined)\n };\n}\n\nfunction gatherMessages(data: RecursiveMessages | undefined): Map<string, string> {\n const messages = new Map<string, string>();\n const prefix: string[] = [];\n const visitChildren = (record: RecursiveMessages) => {\n for (const [key, value] of Object.entries(record)) {\n if (typeof value === \"string\") {\n visitMessage(key, value);\n } else if (value) {\n prefix.push(key);\n visitChildren(value);\n prefix.pop();\n }\n }\n };\n const visitMessage = (key: string, message: string) => {\n const id = [...prefix, key].join(\".\");\n if (messages.has(id)) {\n throw new Error(`Message '${id}' was already defined.`);\n }\n messages.set(id, message);\n };\n\n if (data) {\n visitChildren(data);\n }\n return messages;\n}\n\nfunction gatherOverrides(\n data: Record<string, RecursiveMessages | null | undefined> | undefined\n): Map<string, Map<string, string>> {\n const overrides = new Map<string, Map<string, string>>();\n if (data) {\n for (const [key, value] of Object.entries(data)) {\n const messages = gatherMessages(value ?? undefined);\n overrides.set(key, messages);\n }\n }\n return overrides;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport const PACKAGE_NAME = \"@open-pioneer/vite-plugin-pioneer\";\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\n\nexport type PackageMetadataInput = Pick<PackageMetadata, \"cssFilePath\">;\n\n/**\n * Generates a css file that imports the css file defined by the packages.\n */\nexport function generateCombinedCss(packages: PackageMetadataInput[]) {\n const cssImport = (file: string) => `@import ${JSON.stringify(file)};`;\n return packages\n .filter((pkg) => !!pkg.cssFilePath)\n .map((pkg) => cssImport(pkg.cssFilePath!)) // eslint-disable-line @typescript-eslint/no-non-null-assertion\n .join(\"\\n\");\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { dirname, basename } from \"node:path/posix\";\nimport { normalizePath } from \"vite\";\n\nconst APP_MODULE = \"@@open-pioneer-app\";\n\nconst APP_META_QUERY = \"open-pioneer-app\";\nconst APP_META_RE = /[?&]open-pioneer-app(?:$|&)/;\n\nconst APP_PACKAGES_QUERY = \"open-pioneer-packages\";\nconst APP_PACKAGES_RE = /[?&]open-pioneer-packages(?:$|&)/;\n\nconst APP_CSS_QUERY = \"open-pioneer-styles\";\nconst APP_CSS_RE = /[?&]open-pioneer-styles(?:$|&)/;\n\nconst APP_I18N_INDEX_QUERY = \"open-pioneer-i18n-index\";\nconst APP_I18N_INDEX_RE = /[?&]open-pioneer-i18n-index(?:$|&)/;\n\nconst APP_I18N_QUERY = \"open-pioneer-i18n\";\nconst APP_I18N_RE = /[?&]open-pioneer-i18n(?:$|&)/;\nconst APP_I18N_LOCALE_RE = /[?&]locale=(?<locale>.*?)(?:$|&)/;\n\nconst PACKAGE_HOOKS_MODULE = \"@@open-pioneer-react-hooks\";\n\nconst SOURCE_FILE_RE = /^(.*?)(?:\\?|$)/;\n\nexport type VirtualModule = VirtualAppModule | VirtualI18nMessages | VirtualPackageModule;\n\nexport interface VirtualAppModule {\n type: \"app-meta\" | \"app-packages\" | \"app-css\" | \"app-i18n-index\";\n packageDirectory: string;\n}\n\nexport interface VirtualI18nMessages {\n type: \"app-i18n\";\n packageDirectory: string;\n locale: string;\n}\n\nexport interface VirtualPackageModule {\n type: \"package-hooks\";\n packageDirectory: string;\n}\n\n/**\n * Takes a module id as input and parses it.\n * If this plugin is not responsible to load the module id, this function returns `undefined`.\n *\n * Otherwise, the module is parsed into an object and returned.\n */\nexport function parseVirtualModuleId(inputModuleId: string): VirtualModule | undefined {\n const moduleId = normalizePath(inputModuleId);\n if (!moduleId || moduleId.includes(\"\\\\0\")) {\n return undefined;\n }\n\n const sourceFile = getSourceFile(moduleId); // module id with out query\n if (!sourceFile) {\n return undefined;\n }\n\n const base = basename(sourceFile);\n if (base === PACKAGE_HOOKS_MODULE) {\n return {\n type: \"package-hooks\",\n packageDirectory: dirname(sourceFile)\n };\n }\n if (base === APP_MODULE) {\n return parseAppModuleId(sourceFile, moduleId);\n }\n return undefined;\n}\n\nfunction parseAppModuleId(sourceFile: string, moduleId: string): VirtualModule | undefined {\n const packageDirectory = dirname(sourceFile);\n if (moduleId.match(APP_META_RE)) {\n const type = \"app-meta\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_PACKAGES_RE)) {\n const type = \"app-packages\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_CSS_RE)) {\n const type = \"app-css\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_I18N_INDEX_RE)) {\n const type = \"app-i18n-index\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_I18N_RE)) {\n const type = \"app-i18n\";\n const locale = moduleId.match(APP_I18N_LOCALE_RE)?.groups?.[\"locale\"];\n if (!locale) {\n throw new Error(\"Missing locale name in i18n module request\");\n }\n return { type, packageDirectory, locale };\n }\n throw new Error(`Unexpected module id: ${moduleId}`);\n}\n\n/**\n * Serializes the given virtual module descriptor into a module id string.\n */\nexport function serializeModuleId(mod: VirtualModule): string {\n switch (mod.type) {\n case \"package-hooks\":\n return `${mod.packageDirectory}/${PACKAGE_HOOKS_MODULE}`;\n case \"app-meta\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_META_QUERY}`;\n case \"app-packages\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_PACKAGES_QUERY}`;\n case \"app-css\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_CSS_QUERY}`;\n case \"app-i18n-index\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_I18N_INDEX_QUERY}`;\n case \"app-i18n\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_I18N_QUERY}&locale=${mod.locale}`;\n }\n}\n\nfunction getSourceFile(moduleId: string) {\n const sourceFile = moduleId.match(SOURCE_FILE_RE)?.[1];\n if (!sourceFile || moduleId[0] == \"\\0\") {\n return undefined;\n }\n return sourceFile;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { serializeModuleId } from \"./shared\";\n\n/**\n * Generates the main app metadata module.\n * It delegates the actual metadata generation to auxiliary modules.\n */\nexport function generateAppMetadata(packageDirectory: string, metadataModuleId: string) {\n /*\n CSS loading: \n - 'inline' loads the (s)css as a string literal.\n - the suffix (e.g. '.scss') at the very end is important to trigger the correct vite plugin!\n using .scss supports both .css and .scss, since .css files can be imported from .scss when using vite.\n - I would like to import css as an url instead (separate file),\n but that currently hinges on https://github.com/vitejs/vite/pull/11084\n\n Hot reloading:\n - See https://vitejs.dev/guide/api-hmr.html for vite's HMR API\n - When a css string changes, the module exporting the `stylesString` below changes.\n We accept those changes through the `import.meta.hot.accept` mechanism by\n calling the `setValue` method on the old observable box value.\n The runtime has a reference to the box and watches for changes (only during development!)\n - The code below takes care to use the _correct_ `styles` box (every module has its own, even the new version).\n `import.meta.hot.data` is shared between all versions of the module, so we always use the first box.\n */\n const packagesModule = serializeModuleId({ type: \"app-packages\", packageDirectory });\n const cssModule =\n serializeModuleId({ type: \"app-css\", packageDirectory }) + \"&inline&lang.scss\";\n const i18nModule = serializeModuleId({ type: \"app-i18n-index\", packageDirectory });\n return `\nimport { createBox } from ${JSON.stringify(metadataModuleId)};\nimport packages from ${JSON.stringify(packagesModule)};\nimport stylesString from ${JSON.stringify(cssModule)};\nimport { locales, loadMessages } from ${JSON.stringify(i18nModule)};\n\nconst styles = createBox(stylesString);\nif (import.meta.hot) {\n import.meta.hot.data.styles ??= styles;\n import.meta.hot.accept((mod) => {\n if (mod && mod.packages === packages && mod.locales === locales && mod.loadMessages === loadMessages) {\n import.meta.hot.data.styles.setValue(mod.styles.value);\n return;\n }\n \n // Cannot handle all other changes the moment; trigger reload.\n import.meta.hot.invalidate();\n });\n}\n\nexport {\n packages,\n styles,\n locales,\n loadMessages\n};\n`.trim();\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport function generateReactHooks(packageName: string, runtimeModuleId: string) {\n return `\nimport { useServiceInternal, useServicesInternal, usePropertiesInternal, useIntlInternal } from ${JSON.stringify(\n runtimeModuleId\n )};\n\nconst PACKAGE_NAME = ${JSON.stringify(packageName)};\nexport const useService = /*@__PURE__*/ useServiceInternal.bind(undefined, PACKAGE_NAME);\nexport const useServices = /*@__PURE__*/ useServicesInternal.bind(undefined, PACKAGE_NAME);\nexport const useProperties = /*@__PURE__*/ usePropertiesInternal.bind(undefined, PACKAGE_NAME);\nexport const useIntl = /*@__PURE__*/ useIntlInternal.bind(undefined, PACKAGE_NAME);\n `.trim();\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport * as nodes from \"@babel/types\";\nimport template from \"@babel/template\";\nimport { serializeModuleId } from \"./shared\";\nimport generate from \"@babel/generator\";\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\nimport { ReportableError } from \"../ReportableError\";\nimport { I18nFile } from \"../metadata/parseI18nYaml\";\n\nconst INDEX_TEMPLATE = template.program(`\n export const locales = %%LOCALES_ARRAY%%;\n\n export function loadMessages(locale) {\n %%LOCALE_SWITCH%%\n throw new Error(\\`Unsupported locale: '\\${locale}'\\`);\n }\n`);\n\nconst IMPORT_TEMPLATE = template.statement(`\n return import(%%MODULE_ID%%).then(mod => mod.default);\n`);\n\nconst MESSAGES_TEMPLATE = template.program(`\n const messages = JSON.parse(%%SERIALIZED%%);\n export default messages;\n`);\n\n/**\n * Generates a lookup table for the languages supported by the given application.\n */\nexport function generateI18nIndex(packageDirectory: string, locales: string[]): string {\n const localesArray = nodes.arrayExpression(\n locales.map((locale) => nodes.stringLiteral(locale))\n );\n const switchStmt = nodes.switchStatement(\n nodes.identifier(\"locale\"),\n locales.map((locale) => {\n const localeModuleId = serializeModuleId({\n type: \"app-i18n\",\n packageDirectory,\n locale\n });\n const importStatement = IMPORT_TEMPLATE({\n MODULE_ID: nodes.stringLiteral(localeModuleId)\n });\n return nodes.switchCase(nodes.stringLiteral(locale), [importStatement]);\n })\n );\n\n const program = INDEX_TEMPLATE({\n LOCALES_ARRAY: localesArray,\n LOCALE_SWITCH: switchStmt\n });\n return generate(program).code;\n}\n\nexport interface I18nMessageOptions {\n /** The locale to generate. */\n locale: string;\n\n /**\n * The name of the current application.\n * Used to detect the application page for overrides.\n */\n appName: string;\n\n /** All packages in the application (including the app). */\n packages: Pick<PackageMetadata, \"name\" | \"i18nPaths\">[];\n\n /** Called by the function when the contents of an i18n file (in i18nPaths) is required. */\n loadI18n: (path: string) => Promise<I18nFile>;\n}\n\n/**\n * Generates a messages module containing a single default export: the messages record.\n *\n * Messages are taken from the given packages (for the specified locale).\n */\nexport async function generateI18nMessages(options: I18nMessageOptions): Promise<string> {\n const { locale, appName, packages, loadI18n } = options;\n const packageMessages = new Map<string, Map<string, string>>();\n const packagesNeedingMessages = new Set<string>();\n let packageOverrides: Map<string, Map<string, string>> | undefined;\n for (const pkg of packages) {\n if (pkg.i18nPaths.size !== 0) {\n // Remember packages that have i18n settings. If they are not supported\n // in a given language, and the app does not specify custom messages for this package, an error is emitted.\n packagesNeedingMessages.add(pkg.name);\n }\n\n const filePath = pkg.i18nPaths.get(locale);\n if (!filePath) {\n continue;\n }\n\n const { messages, overrides } = await loadI18n(filePath);\n if (pkg.name === appName) {\n packageOverrides = overrides;\n } else if (overrides.size !== 0) {\n throw new ReportableError(\n `Unexpected 'overrides' block in '${filePath}'. Overrides are only supported in the app.`\n );\n }\n\n packageMessages.set(pkg.name, messages);\n }\n\n // Override messages\n if (packageOverrides) {\n for (const [packageName, messages] of packageOverrides.entries()) {\n const existingMessages = packageMessages.get(packageName);\n if (!existingMessages) {\n packageMessages.set(packageName, messages);\n continue;\n }\n\n const updatedMessages = new Map([...existingMessages, ...messages]);\n packageMessages.set(packageName, updatedMessages);\n }\n }\n\n // Verify that required messages are present\n for (const packageName of packagesNeedingMessages) {\n const messages = packageMessages.get(packageName);\n if (!messages) {\n throw new ReportableError(\n `Package '${packageName}' requires messages for locale '${locale}'. Either update the package or add messages from the app via 'overrides'.`\n );\n }\n }\n\n // Translate to json for codegen. Package name -> key -> i18n message template\n const allMessages: Record<string, Record<string, string>> = {};\n for (const [packageName, messages] of packageMessages.entries()) {\n allMessages[packageName] = Object.fromEntries(messages.entries());\n }\n\n // Transport the object as a json string for improved parsing performance\n const serialized = JSON.stringify(allMessages);\n const program = MESSAGES_TEMPLATE({\n SERIALIZED: nodes.stringLiteral(serialized)\n });\n return generate(program).code;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { Plugin, ResolvedConfig } from \"vite\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { posix } from \"node:path\";\nimport { cwd } from \"node:process\";\nimport { type PioneerPluginOptions } from \".\";\nimport { RollupOptions } from \"rollup\";\nimport { AdvancedAppOptions } from \"../types\";\n\nexport function mpaPlugin(options: PioneerPluginOptions | undefined): Plugin {\n const rootSite = options?.rootSite ?? false;\n const apps = options?.apps || [];\n const sites = options?.sites || [];\n\n let resolvedConfig: ResolvedConfig;\n return {\n name: \"pioneer:mpa\",\n\n config(config) {\n const sourceRoot = config.root ?? cwd();\n const { entryPoints, appNames } = gatherEntryPoints({\n apps,\n sites,\n rootSite,\n sourceRoot\n });\n const rollupOptions: RollupOptions = {\n input: entryPoints,\n output: {\n entryFileNames(chunk) {\n if (appNames.includes(chunk.name)) {\n return \"[name].js\";\n }\n\n // This will rename the .js files that belong to a .html site, they don't need a public name.\n return posix.join(resolvedConfig.build.assetsDir, \"[hash:12].js\");\n },\n chunkFileNames(chunk) {\n void chunk; // ignored\n return posix.join(resolvedConfig.build.assetsDir, \"[hash:12].js\");\n }\n }\n };\n\n return {\n build: {\n rollupOptions\n }\n };\n },\n\n configResolved(config) {\n resolvedConfig = config;\n }\n };\n}\n\nexport interface EntryPointInfo {\n // Parsed rollup entry points\n entryPoints: Record<string, string>;\n\n // All app names used by the project\n appNames: string[];\n}\n\nfunction gatherEntryPoints(options: {\n apps: string[] | AdvancedAppOptions;\n sites: string[];\n rootSite: boolean;\n sourceRoot: string;\n}): EntryPointInfo {\n interface RawEntryPoint {\n name: string;\n path: string;\n }\n\n let apps: RawEntryPoint[];\n if (Array.isArray(options.apps)) {\n apps = options.apps.map((appName) => {\n const prefix = resolve(options.sourceRoot, \"apps\", appName, \"app\");\n const path = findMatchingEntryPointFile(appName, prefix);\n return {\n name: appName,\n path: path\n };\n });\n } else {\n apps = Object.entries(options.apps).map(([name, appPath]) => {\n const path = resolve(options.sourceRoot, appPath);\n if (!existsSync(path)) {\n throw new Error(\n `Failed to find app '${name}' at ${path}. Ensure that the path is spelled correctly.`\n );\n }\n return { name, path };\n });\n }\n\n /*\n * Vite does not respect the entry point name for html files, it\n * put each html site at a location mirroring the source directory structure (e.g. site/<SITE>/index.html\n * instead of SITE.html).\n *\n * There are multiple vite mpa plugins that handle custom html paths which can either be used\n * directly or as inspiration.\n */\n const sites = options.sites.map((sitePath) => {\n const path = resolve(options.sourceRoot, sitePath, \"index.html\");\n if (!existsSync(path)) {\n throw new Error(\n `Failed to find site at ${path}. Ensure that the site name in your vite configuration is spelled correctly.`\n );\n }\n return {\n name: sitePath,\n path: path\n };\n });\n if (options.rootSite) {\n const path = resolve(options.sourceRoot, \"index.html\");\n if (!existsSync(path)) {\n throw new Error(\n `Failed to find root site at ${path}. Create the missing file or set 'rootSite' to false.`\n );\n }\n sites.push({\n name: \"index\",\n path: path\n });\n }\n\n const entryPoints: Record<string, string> = {};\n let entryPointCount = 0;\n for (const { name, path } of [apps, sites].flat()) {\n const existingPath = entryPoints[name];\n if (existingPath) {\n throw new Error(\n `Entry point '${name}' was defined twice (paths ${existingPath} and ${path}). Remove the duplicated entry.`\n );\n }\n entryPoints[name] = path;\n ++entryPointCount;\n }\n if (entryPointCount === 0) {\n throw new Error(\n \"You must configure at least one site or one app in the pioneer plugin options.\"\n );\n }\n\n const appNames = apps.map(({ name }) => name);\n return {\n entryPoints,\n appNames\n };\n}\n\nconst EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\"];\n\nfunction findMatchingEntryPointFile(appName: string, prefix: string) {\n for (const ext of EXTENSIONS) {\n const candidate = prefix + ext;\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const extensions = EXTENSIONS.join(\", \");\n throw new Error(\n `Failed to find a matching entry point file for app '${appName}' at ${prefix}.` +\n ` Supported extensions are ${extensions}.` +\n ` Ensure that the app name is spelled correctly or create the missing file.`\n );\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { Plugin } from \"vite\";\nimport { codegenPlugin } from \"./codegenPlugin\";\nimport { mpaPlugin } from \"./mpaPlugin\";\nimport type { PioneerPluginOptions } from \"../types\";\nexport { type PioneerPluginOptions };\n\nexport function pioneer(options?: PioneerPluginOptions): Plugin[] {\n return [mpaPlugin(options), codegenPlugin()];\n}\n"],
|
|
5
|
-
"mappings": ";AAEA,SAAS,kBAAkB;AAC3B,SAAS,WAAAA,UAAS,QAAAC,aAAY;AAE9B,SAAS,iBAAAC,sBAA4D;;;ACHrE,SAAS,aAAa;AAMf,SAAS,eAAe,WAA6B;AACxD,QAAM,SAAS,MAAM,SAAS;AAC9B,SAAO,SAAS,iBAAiB,MAAM;AACnC,WAAO,GAAG,IAAI;AAAA,EAClB;AACJ;;;ACXA,OAAO,cAAc;AACrB,OAAO,cAAc;AACrB,YAAY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AA,MACnC;AAAA,IACJ;AACA,UAAM,KAAK;AAAA,MACP,MAAM;AAAA,MACN;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,QAAM,cAAsC,CAAC;AAC7C,MAAI,kBAAkB;AACtB,aAAW,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,KAAK,EAAE,KAAK,GAAG;AAC/C,UAAM,eAAe,YAAY,IAAI;AACrC,QAAI,cAAc;AACd,YAAM,IAAI;AAAA,QACN,gBAAgB,kCAAkC,oBAAoB;AAAA,MAC1E;AAAA,IACJ;AACA,gBAAY,IAAI,IAAI;AACpB,MAAE;AAAA,EACN;AACA,MAAI,oBAAoB,GAAG;AACvB,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAEA,QAAM,WAAW,KAAK,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAC5C,SAAO;AAAA,IACH;AAAA,IACA;AAAA,EACJ;AACJ;AAEA,IAAM,aAAa,CAAC,OAAO,QAAQ,OAAO,MAAM;AAEhD,SAAS,2BAA2B,SAAiB,QAAgB;AACjE,aAAW,OAAO,YAAY;AAC1B,UAAM,YAAY,SAAS;AAC3B,QAAIA,YAAW,SAAS,GAAG;AACvB,aAAO;AAAA,IACX;AAAA,EACJ;AAEA,QAAM,aAAa,WAAW,KAAK,IAAI;AACvC,QAAM,IAAI;AAAA,IACN,uDAAuD,eAAe,oCACrC;AAAA,EAErC;AACJ;;;ACtKO,SAAS,QAAQ,SAA0C;AAC9D,SAAO,CAAC,UAAU,OAAO,GAAG,cAAc,CAAC;AAC/C;",
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../src/index.ts", "../src/codegenPlugin.ts", "../src/utils/debug.ts", "../src/codegen/generatePackagesMetadata.ts", "../src/ReportableError.ts", "../src/codegen/IdGenerator.ts", "../src/metadata/MetadataRepository.ts", "../src/utils/fileUtils.ts", "../src/utils/Cache.ts", "../src/metadata/parseBuildConfig.ts", "../src/metadata/parseI18nYaml.ts", "../src/utils/package.ts", "../src/codegen/generateCombinedCss.ts", "../src/codegen/shared.ts", "../src/codegen/generateAppMetadata.ts", "../src/codegen/generateReactHooks.ts", "../src/codegen/generateI18n.ts", "../src/mpaPlugin.ts"],
|
|
4
|
+
"sourcesContent": ["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { Plugin } from \"vite\";\nimport { codegenPlugin } from \"./codegenPlugin\";\nimport { mpaPlugin } from \"./mpaPlugin\";\nimport type { PioneerPluginOptions } from \"../types\";\nexport { type PioneerPluginOptions };\n\nexport function pioneer(options?: PioneerPluginOptions): Plugin[] {\n return [mpaPlugin(options), codegenPlugin()];\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { PluginContext } from \"rollup\";\nimport { normalizePath, Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport { createDebugger } from \"./utils/debug\";\nimport { generatePackagesMetadata } from \"./codegen/generatePackagesMetadata\";\nimport { MetadataContext, MetadataRepository } from \"./metadata/MetadataRepository\";\nimport { generateCombinedCss } from \"./codegen/generateCombinedCss\";\nimport { generateAppMetadata } from \"./codegen/generateAppMetadata\";\nimport { parseVirtualModuleId, serializeModuleId } from \"./codegen/shared\";\nimport { readFile } from \"node:fs/promises\";\nimport { generateReactHooks } from \"./codegen/generateReactHooks\";\nimport { ReportableError } from \"./ReportableError\";\nimport { generateI18nIndex, generateI18nMessages } from \"./codegen/generateI18n\";\n\nconst isDebug = !!process.env.DEBUG;\nconst debug = createDebugger(\"open-pioneer:codegen\");\n\nexport function codegenPlugin(): Plugin {\n // key: normalized path to package json.\n // value: set of module ids that must be invalidated.\n const manualDeps = new Map<string, Set<string>>();\n\n let config!: ResolvedConfig;\n let repository!: MetadataRepository;\n let devServer: ViteDevServer | undefined;\n\n let reactIntegrationId!: string;\n let metadataId!: string;\n return {\n name: \"pioneer:codegen\",\n\n async buildStart(this: PluginContext) {\n manualDeps.clear();\n repository?.reset();\n\n // TODO: use require.resolve instead (requires built js?).\n const resolve = async (rawModuleId: string) => {\n const resolvedResult = await this.resolve(rawModuleId, __filename);\n if (!resolvedResult) {\n this.error(`Failed to find '${rawModuleId}'.`);\n }\n return resolvedResult.id;\n };\n\n reactIntegrationId = await resolve(\"@open-pioneer/runtime/react-integration\");\n metadataId = await resolve(\"@open-pioneer/runtime/metadata\");\n },\n\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n repository = new MetadataRepository(config.root);\n },\n\n configureServer(server) {\n devServer = server;\n\n // Trigger manual module reload when a watched file changes.\n server.watcher.on(\"all\", (_, path) => {\n const moduleIds = manualDeps.get(normalizePath(path));\n if (!moduleIds) {\n return;\n }\n\n isDebug && debug(`File changed: ${path}`);\n repository.onFileChanged(path);\n for (const moduleId of moduleIds) {\n const mod = server.moduleGraph.getModuleById(moduleId);\n if (mod) {\n isDebug && debug(`Triggering hmr of ${moduleId}`);\n server.reloadModule(mod).catch((err) => {\n config.logger.error(`Failed to trigger hmr`, { error: err });\n });\n }\n }\n });\n },\n\n async resolveId(this: PluginContext, moduleId, importer) {\n try {\n if (!importer) {\n return undefined;\n }\n\n if (parseVirtualModuleId(moduleId)) {\n return moduleId;\n }\n\n const getPackageDirectory = () => {\n const packageJsonPath = findPackageJson(dirname(importer), config.root);\n if (!packageJsonPath) {\n throw new ReportableError(\n `Failed to find package.json for package from '${importer}'.`\n );\n }\n\n const packageDir = dirname(packageJsonPath);\n return normalizePath(packageDir);\n };\n\n if (moduleId === \"open-pioneer:app\") {\n return serializeModuleId({\n type: \"app-meta\",\n packageDirectory: getPackageDirectory()\n });\n }\n if (moduleId === \"open-pioneer:react-hooks\") {\n return serializeModuleId({\n type: \"package-hooks\",\n packageDirectory: getPackageDirectory()\n });\n }\n } catch (e) {\n reportError(this, e);\n }\n },\n\n async load(this: PluginContext, moduleId) {\n try {\n const mod = parseVirtualModuleId(moduleId);\n if (!mod) {\n return undefined;\n }\n\n isDebug && debug(\"Loading virtual module %O\", mod);\n\n // During development we will observe directories like \"/packages/foo\" (i.e. not fully resolved).\n // This uses the dev server to attempt to resolve the directory back to a complete path.\n // Hit me up if you know a better way to do this.\n const packageJsonPath = (await this.resolve(mod.packageDirectory + \"/package.json\"))\n ?.id;\n if (!packageJsonPath) {\n throw new ReportableError(\n `Failed to resolve package.json in ${mod.packageDirectory}`\n );\n }\n\n if (mod.type === \"package-hooks\") {\n const directory = mod.packageDirectory;\n // use forward slashes instead of platform separator\n const packageJsonPath = (await this.resolve(directory + \"/package.json\"))?.id;\n if (!packageJsonPath) {\n throw new ReportableError(`Failed to resolve package.json in ${directory}`);\n }\n\n const packageName = await getPackageName(this, packageJsonPath);\n const generatedSourceCode = generateReactHooks(packageName, reactIntegrationId);\n isDebug && debug(\"Generated hooks code: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n\n if (mod.type === \"app-meta\") {\n return generateAppMetadata(mod.packageDirectory, metadataId);\n }\n\n const context = buildMetadataContext(this, moduleId, devServer, manualDeps);\n const appMetadata = await repository.getAppMetadata(\n context,\n dirname(packageJsonPath)\n );\n switch (mod.type) {\n case \"app-packages\": {\n const generatedSourceCode = generatePackagesMetadata({\n appName: appMetadata.name,\n packages: appMetadata.packages\n });\n isDebug && debug(\"Generated app metadata: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n case \"app-css\": {\n const generatedSourceCode = generateCombinedCss(appMetadata.packages);\n isDebug && debug(\"Generated app css: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n case \"app-i18n-index\": {\n const generatedSourceCode = generateI18nIndex(\n mod.packageDirectory,\n appMetadata.locales\n );\n isDebug && debug(\"Generated i18n lookup: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n case \"app-i18n\": {\n const generatedSourceCode = await generateI18nMessages({\n locale: mod.locale,\n appName: appMetadata.name,\n packages: appMetadata.packages,\n loadI18n(path) {\n return repository.getI18nFile(context, path);\n }\n });\n isDebug && debug(\"Generated i18n messages: %O\", generatedSourceCode);\n return generatedSourceCode;\n }\n }\n } catch (e) {\n reportError(this, e);\n }\n }\n };\n}\n\n// Patches the addWatchFile function for manual watching\nfunction buildMetadataContext(\n ctx: PluginContext,\n moduleId: string,\n devServer: ViteDevServer | undefined,\n manualDeps: Map<string, Set<string>>\n): MetadataContext {\n return {\n warn: ctx.warn,\n resolve: ctx.resolve,\n addWatchFile: (id) => {\n if (devServer) {\n // TODO: Is there a better way? We want to trigger a hot reload when\n // one of the build.config files or package.json files change!\n isDebug && debug(`Adding manual watch for ${id}`);\n devServer.watcher.add(id);\n addManualDep(manualDeps, id, moduleId);\n }\n ctx.addWatchFile(id);\n }\n };\n}\n\nfunction reportError(ctx: PluginContext, error: unknown) {\n if (error instanceof ReportableError) {\n ctx.error(error);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const message = String((error as any).message) || \"Unknown error\";\n ctx.error({\n message: \"Internal error: \" + message,\n cause: error\n });\n}\n\nfunction addManualDep(manualDeps: Map<string, Set<string>>, file: string, moduleId: string) {\n const normalizedPath = normalizePath(file);\n let moduleIds = manualDeps.get(normalizedPath);\n if (!moduleIds) {\n moduleIds = new Set();\n manualDeps.set(normalizedPath, moduleIds);\n }\n moduleIds.add(moduleId);\n}\n\nfunction findPackageJson(startDir: string, rootDir: string) {\n let dir = startDir;\n while (dir) {\n const candidate = join(dir, \"package.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n\n if (normalizePath(dir) == normalizePath(rootDir)) {\n return undefined;\n }\n\n const parent = dirname(dir);\n dir = parent === dir || parent === \".\" ? \"\" : parent;\n }\n return undefined;\n}\n\nasync function getPackageName(ctx: PluginContext, packageJsonPath: string) {\n let name: string;\n try {\n const content = await readFile(packageJsonPath, \"utf-8\");\n name = JSON.parse(content).name;\n } catch (e) {\n throw new ReportableError(`Failed to read package.json file`, { cause: e });\n }\n if (!name) {\n throw new ReportableError(`Failed to read package name from ${packageJsonPath}.`);\n }\n return name;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { debug } from \"debug\";\n\nexport interface Debugger {\n (msg: string, ...args: unknown[]): void;\n}\n\nexport function createDebugger(namespace: string): Debugger {\n const logger = debug(namespace);\n return function debugFunction(...args) {\n logger(...args);\n };\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport generate from \"@babel/generator\";\nimport template from \"@babel/template\";\nimport * as nodes from \"@babel/types\";\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\nimport { ReportableError } from \"../ReportableError\";\nimport { IdGenerator } from \"./IdGenerator\";\nimport { PackageOverrides, Reference, UiReference } from \"@open-pioneer/build-common\";\n\nconst SERVICE_IMPORT = template.statement(`\n import { %%SERVICE_NAME%% as %%IMPORT_NAME%% } from %%IMPORT_SOURCE%%;\n`);\n\nconst PKG_OBJECT = template.expression(`\n {\n name: %%PACKAGE_NAME%%,\n services: %%PACKAGE_SERVICES%%,\n ui: %%PACKAGE_UI%%,\n properties: %%PROPERTIES%%\n }\n`);\n\nconst SERVICE_OBJECT = template.expression(`\n {\n name: %%SERVICE_NAME%%,\n clazz: %%SERVICE_IMPORT%%,\n provides: %%SERVICE_INTERFACES%%,\n references: %%SERVICE_REFERENCES%%\n }\n`);\n\nconst INTERFACE_OBJECT = template.expression(`\n {\n name: %%INTERFACE_NAME%%,\n qualifier: %%QUALIFIER%%\n }\n`);\n\nconst REFERENCE_OBJECT = template.expression(`\n {\n name: %%INTERFACE_NAME%%,\n qualifier: %%QUALIFIER%%,\n all: %%ALL%%\n }\n`);\n\nconst UI_OBJECT = template.expression(`\n {\n references: %%UI_REFERENCES%%\n }\n`);\n\nconst PROPERTY_OBJECT = template.expression(`\n {\n value: %%VALUE%%,\n required: %%REQUIRED%%\n }\n`);\n\nexport type PackageMetadataInput = Pick<PackageMetadata, \"name\" | \"config\" | \"servicesModulePath\">;\n\nexport interface PackageMetadataOptions {\n /**\n * The name of the current application.\n * Used to detect the application page for overrides.\n */\n appName: string;\n\n /**\n * Set of packages to generate code for.\n */\n packages: PackageMetadataInput[];\n}\n\n/**\n * Generates a combined metadata structure that is essentially a Record<string, metadata.PackageMetadata>.\n * The object contents must match the shape required by the runtime (declared in runtime/metadata/index.ts).\n */\nexport function generatePackagesMetadata({ appName, packages }: PackageMetadataOptions): string {\n const idGenerator = new IdGenerator();\n const packagesMetadata = nodes.objectExpression([]);\n const imports: nodes.Statement[] = [];\n\n let overrides: Map<string, PackageOverrides> | undefined;\n for (const pkg of packages) {\n if (pkg.name === appName) {\n overrides = pkg.config.overrides;\n } else if (pkg.config.overrides.size > 0) {\n throw new ReportableError(\n `Unexpected 'overrides' in package '${pkg.name}'. Overrides are only supported in the app.`\n );\n }\n }\n\n for (const pkg of packages) {\n const packageOverrides = overrides?.get(pkg.name);\n const packageMetadata = generatePackageMetadata(pkg, {\n enableService(serviceName) {\n return packageOverrides?.services?.get(serviceName)?.enabled ?? true;\n },\n importServiceClass(variableName, className, moduleId) {\n const id = idGenerator.generate(variableName);\n const renderedImporter = SERVICE_IMPORT({\n SERVICE_NAME: nodes.identifier(className),\n IMPORT_NAME: nodes.identifier(id),\n IMPORT_SOURCE: nodes.stringLiteral(moduleId)\n });\n imports.push(renderedImporter);\n return id;\n }\n });\n packagesMetadata.properties.push(\n nodes.objectProperty(nodes.stringLiteral(pkg.name), packageMetadata)\n );\n }\n\n const program = nodes.program([...imports, nodes.exportDefaultDeclaration(packagesMetadata)]);\n return generate(program).code;\n}\n\n/**\n * Generates the metadata object for a single package.\n * As a side effect, service imports for required service classes will be emitted through a callback.\n */\nfunction generatePackageMetadata(\n pkg: PackageMetadataInput,\n options: {\n /**\n * Adds an import to the containing module.\n * Returns the actual variable name associated with the service.\n */\n importServiceClass(variableName: string, className: string, entryPoint: string): string;\n\n /**\n * Returns true if the service shall be included in the generated code, false otherwise.\n */\n enableService(serviceName: string): boolean;\n }\n): nodes.Expression {\n const servicesObject = nodes.objectExpression([]);\n for (const service of pkg.config.services.values()) {\n if (!options.enableService(service.serviceName)) {\n continue;\n }\n\n if (!pkg.servicesModulePath) {\n throw new ReportableError(\n `Package '${pkg.name}' must have a valid services module (typically 'services.ts' or 'services.js').\\n` +\n \"The entry point can be configured by setting the 'servicesModule' property in the build.config.mjs.\"\n );\n }\n\n const importName = options.importServiceClass(\n pkg.name + \"_\" + service.serviceName,\n service.serviceName,\n pkg.servicesModulePath\n );\n const serviceObject = SERVICE_OBJECT({\n SERVICE_NAME: nodes.stringLiteral(service.serviceName),\n SERVICE_IMPORT: nodes.identifier(importName),\n SERVICE_INTERFACES: nodes.arrayExpression(\n service.provides.map((p) =>\n INTERFACE_OBJECT({\n INTERFACE_NAME: nodes.stringLiteral(p.interfaceName),\n QUALIFIER:\n p.qualifier == null ? undefinedNode() : nodes.stringLiteral(p.qualifier)\n })\n )\n ),\n SERVICE_REFERENCES: nodes.objectExpression(\n Array.from(service.references.entries()).map(([referenceName, referenceConfig]) =>\n nodes.objectProperty(\n nodes.stringLiteral(referenceName),\n referenceObject(referenceConfig)\n )\n )\n )\n });\n\n servicesObject.properties.push(\n nodes.objectProperty(nodes.stringLiteral(service.serviceName), serviceObject)\n );\n }\n\n const uiObject = UI_OBJECT({\n UI_REFERENCES: nodes.arrayExpression(pkg.config.uiReferences.map((r) => referenceObject(r)))\n });\n\n const propertiesObject = nodes.objectExpression(\n Array.from(pkg.config.properties.values()).map((prop) =>\n nodes.objectProperty(\n nodes.stringLiteral(prop.propertyName),\n PROPERTY_OBJECT({\n VALUE: jsonToExpression(prop.defaultValue),\n REQUIRED: nodes.booleanLiteral(prop.required)\n })\n )\n )\n );\n\n const pkgObject = PKG_OBJECT({\n PACKAGE_NAME: nodes.stringLiteral(pkg.name),\n PACKAGE_SERVICES: servicesObject,\n PACKAGE_UI: uiObject,\n PROPERTIES: propertiesObject\n });\n return pkgObject;\n}\n\nfunction jsonToExpression(json: unknown): nodes.Expression {\n if (json == null) {\n return nodes.nullLiteral();\n }\n if (typeof json === \"string\") {\n return nodes.stringLiteral(json);\n }\n if (typeof json === \"number\") {\n return nodes.numericLiteral(json);\n }\n if (typeof json === \"boolean\") {\n return nodes.booleanLiteral(json);\n }\n if (Array.isArray(json)) {\n return nodes.arrayExpression(json.map((item) => jsonToExpression(item)));\n }\n if (typeof json === \"object\") {\n return nodes.objectExpression(\n Object.entries(json).map(([name, value]) =>\n nodes.objectProperty(nodes.stringLiteral(name), jsonToExpression(value))\n )\n );\n }\n throw new Error(`Unexpected value while serializing JSON: ${json}.`);\n}\n\nfunction referenceObject(ref: Reference | UiReference): nodes.Expression {\n return REFERENCE_OBJECT({\n INTERFACE_NAME: nodes.stringLiteral(ref.interfaceName),\n QUALIFIER: ref.qualifier ? nodes.stringLiteral(ref.qualifier) : undefinedNode(),\n ALL: nodes.booleanLiteral(ref.type === \"all\" ? true : false) // TODO: Rework internal app format\n });\n}\n\nfunction undefinedNode() {\n return nodes.unaryExpression(\"void\", nodes.numericLiteral(0));\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport class ReportableError extends Error {}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport class IdGenerator {\n private existing = new Map<string, number>();\n\n /**\n * Returns a unique identifier (in the context of this instance) that resembles the input value.\n */\n generate(input: string): string {\n const clean = cleanName(input);\n\n const existing = this.existing;\n const count = existing.get(clean) ?? 0;\n existing.set(clean, count + 1);\n return count === 0 ? clean : `${clean}_${count}`;\n }\n}\n\nfunction cleanName(input: string) {\n let clean = input.replace(/[^A-Za-z0-9_]+/g, \"_\"); // remove non-alphanumeric\n clean = clean.replace(/[\\d_]+$/, \"\"); // strip trailing numbers / underscore to prevent conflicts\n if (/^\\d/.test(clean)) {\n clean = \"_\" + clean; // ensure variable name does not start with a number\n }\n return clean || \"var\";\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { readFile, realpath } from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { PluginContext, RollupWarning } from \"rollup\";\nimport { PackageData, normalizePath } from \"vite\";\nimport { ReportableError } from \"../ReportableError\";\nimport { createDebugger } from \"../utils/debug\";\nimport { fileExists, isInDirectory } from \"../utils/fileUtils\";\nimport { Cache } from \"../utils/Cache\";\nimport { isBuildConfig, loadBuildConfig } from \"./parseBuildConfig\";\nimport { I18nFile, loadI18nFile } from \"./parseI18nYaml\";\nimport {\n BUILD_CONFIG_NAME,\n PackageConfig,\n PackageMetadataV1,\n createPackageConfigFromPackageMetadata\n} from \"@open-pioneer/build-common\";\nimport { PACKAGE_NAME } from \"../utils/package\";\n\nconst isDebug = !!process.env.DEBUG;\nconst debug = createDebugger(\"open-pioneer:metadata\");\n\n/**\n * Contains build-time information about an app.\n */\nexport interface AppMetadata {\n /** App name. */\n name: string;\n\n /** Directory on disk. */\n directory: string;\n\n /** Path to package.json file. */\n packageJsonPath: string;\n\n /** Locales required by the application. */\n locales: string[];\n\n /**\n * Packages used by the app.\n * Includes the app package itself!\n */\n packages: PackageMetadata[];\n}\n\n/**\n * Contains build-time information about a package.\n */\nexport interface PackageMetadata {\n /** */\n type: \"pioneer-package\";\n\n /** Package name. */\n name: string;\n\n /** Directory on disk. */\n directory: string;\n\n /** Path to package.json file. */\n packageJsonPath: string;\n\n /** Path to entry point (contains service exports). */\n servicesModulePath: string | undefined;\n\n /** Path to the resolved css file (if any). */\n cssFilePath: string | undefined;\n\n /**\n * Paths to i18n yaml config for any defined lang in build config.\n * Key: locale, value: file path\n */\n i18nPaths: Map<string, string>;\n\n /** Runtime dependencies (from package.json). */\n dependencies: PackageDependency[];\n\n /** Parsed metadata (from build config file). */\n config: PackageConfig;\n}\n\nexport interface PackageDependency {\n packageName: string;\n optional: boolean;\n}\n\n/**\n * Package that was discovered during dependency analysis which does not have open-pioneer metadata.\n * We cache such objects to remember the result of the analysis.\n */\ninterface PlainPackageMetadata {\n type: \"plain\";\n\n /** Package name. */\n name: string;\n\n /** Directory on disk. */\n directory: string;\n}\n\ntype InternalPackageMetadata = PackageMetadata | PlainPackageMetadata;\n\nexport type MetadataContext = Pick<PluginContext, \"addWatchFile\" | \"resolve\" | \"warn\">;\n\nexport interface ResolvedPackageLocation {\n type: \"absolute\";\n directory: string;\n}\n\nexport interface UnresolvedDependency {\n type: \"unresolved\";\n dependency: PackageDependency;\n importedFrom: string;\n}\n\nexport type PackageLocation = ResolvedPackageLocation | UnresolvedDependency;\n\n/**\n * Tracks metadata and the files that were used to parse that metadata.\n * watchFiles should be propagated when a caller receives a cached result,\n * otherwise hot reloading may not be triggered correctly on file changes.\n */\ninterface MetadataEntry {\n metadata: InternalPackageMetadata;\n watchFiles: ReadonlySet<string>;\n warnings: RollupWarning[];\n}\n\ninterface I18nEntry {\n i18n: I18nFile;\n watchFiles: ReadonlySet<string>;\n}\n\n/**\n * Provides metadata about apps and packages.\n * Metadata is read from disk on demand and will then be cached\n * until one of the file dependencies has changed.\n */\nexport class MetadataRepository {\n private sourceRoot: string;\n\n // Key: package directory on disk, value: existing metadata\n private packageMetadataCache: Cache<string, MetadataEntry, [ctx: MetadataContext]>;\n\n // Cache for the contents of i18n files.\n // Key: path on disk.\n private i18nCache: Cache<string, I18nEntry, [ctx: MetadataContext]>;\n\n // Cache for package locations & package.json contents\n private packageDataCache = new Map<string, PackageData>();\n\n /**\n * @param sourceRoot Source folder on disk, needed to detect 'local' packages\n */\n constructor(sourceRoot: string) {\n this.sourceRoot = sourceRoot;\n this.packageMetadataCache = this.createPackageMetadataCache();\n this.i18nCache = this.createI18nCache();\n }\n\n reset() {\n this.packageMetadataCache = this.createPackageMetadataCache();\n this.i18nCache = this.createI18nCache();\n this.packageDataCache.clear();\n }\n\n /**\n * Called by the plugin when a file has been changed.\n * The cached data associated with that file (if any) will be removed.\n */\n onFileChanged(path: string) {\n if (isPackageJson(path) || isBuildConfig(path)) {\n this.packageMetadataCache.invalidate(dirname(path));\n }\n this.i18nCache.invalidate(path);\n }\n\n /**\n * Returns the combined application metadata of the app in `appDirectory`.\n * Starting from the app's package.json, dependencies will be visited recursively.\n *\n * For packages that use our package extensions (services etc.), metadata will be gathered and\n * will be returned here.\n */\n async getAppMetadata(ctx: MetadataContext, appDirectory: string): Promise<AppMetadata> {\n isDebug && debug(`Request for app metadata of ${appDirectory}`);\n\n const appPackageMetadata = await this.getPackageMetadata(ctx, {\n type: \"absolute\",\n directory: appDirectory\n });\n if (!appPackageMetadata) {\n throw new ReportableError(\n `Failed to parse app metadata in ${appDirectory}. Ensure that the app is a valid local package.`\n );\n }\n\n // App's locales define which locales must be supported.\n const appLocales = Array.from(appPackageMetadata.i18nPaths.keys());\n\n // Map to ensure that we don't return duplicates. Key: package name\n const packageMetadataByName = new Map<string, PackageMetadata>();\n packageMetadataByName.set(appPackageMetadata.name, appPackageMetadata);\n\n // Recursively visit all dependencies.\n // Detected metadata is placed into `packageMetadata`.\n const visitDependencies = async (\n dependencies: PackageDependency[],\n importedFrom: string\n ) => {\n const jobs = dependencies.map(async (dependency) => {\n const packageMetadata = await this.getPackageMetadata(ctx, {\n type: \"unresolved\",\n dependency,\n importedFrom\n });\n if (packageMetadata) {\n if (!packageMetadataByName.has(packageMetadata.name)) {\n packageMetadataByName.set(packageMetadata.name, packageMetadata);\n }\n await visitDependencies(\n packageMetadata.dependencies,\n packageMetadata.packageJsonPath\n );\n }\n });\n return await Promise.all(jobs);\n };\n await visitDependencies(\n appPackageMetadata.dependencies,\n appPackageMetadata.packageJsonPath\n );\n\n const appMetadata: AppMetadata = {\n name: appPackageMetadata.name,\n directory: appPackageMetadata.directory,\n locales: appLocales,\n packageJsonPath: appPackageMetadata.packageJsonPath,\n packages: Array.from(packageMetadataByName.values())\n };\n return appMetadata;\n }\n\n /**\n * Returns package metadata associated with the given package.\n */\n private async getPackageMetadata(\n ctx: MetadataContext,\n loc: PackageLocation\n ): Promise<PackageMetadata | undefined> {\n isDebug && debug(`Request for package metadata of ${formatPackageLocation(loc)}`);\n\n const packageDir = await this.resolvePackageLocation(loc);\n if (!packageDir) {\n // Optional package does not exist\n return undefined;\n }\n\n const entry = await this.packageMetadataCache.get(packageDir, ctx);\n propagateWatchFiles(entry.watchFiles, ctx);\n for (const warning of entry.warnings) {\n ctx.warn(warning);\n }\n\n if (entry.metadata.type === \"plain\") {\n isDebug && debug(`Skipping package '${packageDir}'.`);\n return undefined;\n }\n\n return entry.metadata;\n }\n\n /**\n * Returns the parsed contents of the given i18n file.\n */\n async getI18nFile(ctx: MetadataContext, path: string): Promise<I18nFile> {\n const { i18n, watchFiles } = await this.i18nCache.get(path, ctx);\n propagateWatchFiles(watchFiles, ctx);\n return i18n;\n }\n\n private async resolvePackageLocation(loc: PackageLocation) {\n if (loc.type === \"absolute\") {\n return await realpath(loc.directory);\n }\n\n const { packageName, optional } = loc.dependency;\n const { resolvePackageData } = await import(\"vite\");\n const packageData = await resolvePackageData(\n packageName,\n loc.importedFrom,\n false,\n this.packageDataCache\n );\n if (!packageData) {\n if (optional) {\n isDebug && debug(`Optional package '${packageName}' was not found.`);\n return undefined;\n }\n\n throw new ReportableError(\n `Failed to find package '${packageName}' (from '${loc.importedFrom}'), is the dependency installed correctly?`\n );\n }\n\n const packageDir = await realpath(packageData.dir);\n isDebug && debug(`Found package '${packageName}' at ${packageDir}`);\n return packageDir;\n }\n\n private createI18nCache(): Cache<string, I18nEntry, [ctx: MetadataContext]> {\n return new Cache({\n getId(path) {\n return normalizePath(path);\n },\n async getValue(path, ctx) {\n isDebug && debug(`Loading i18n file ${path}`);\n\n // watch before loading. this protects against rare race conditions\n // caused by our manual watch workaround in the codegen plugin.\n // essentially, we must watch for changes BEFORE the files are loaded\n // to get reliable notifications.\n ctx.addWatchFile(path);\n const entry: I18nEntry = {\n i18n: await loadI18nFile(path),\n watchFiles: new Set([path])\n };\n return entry;\n },\n onInvalidate(path) {\n isDebug && debug(`Removed cache entry for i18n file ${path}`);\n },\n onCachedReturn(path) {\n isDebug && debug(`Returning cached entry for i18n file ${path}`);\n }\n });\n }\n\n private createPackageMetadataCache(): Cache<string, MetadataEntry, [ctx: MetadataContext]> {\n const sourceRoot = this.sourceRoot;\n const provider = {\n _byName: new Map<string, PackageMetadata>(),\n\n getId(directory: string) {\n return normalizePath(directory);\n },\n async getValue(directory: string, ctx: MetadataContext): Promise<MetadataEntry> {\n isDebug && debug(`Loading metadata for package at ${directory}`);\n\n const watchFiles = new Set<string>();\n const warnings: RollupWarning[] = [];\n const trackingCtx: MetadataContext = {\n resolve: ctx.resolve,\n addWatchFile(id) {\n ctx.addWatchFile(id);\n watchFiles.add(id);\n },\n warn(msg: string | RollupWarning) {\n warnings.push(typeof msg === \"string\" ? { message: msg } : msg);\n }\n };\n\n const metadata = await parsePackageMetadata(trackingCtx, directory, sourceRoot);\n isDebug && debug(`Metadata for '${metadata.name}': %O`, metadata);\n\n // Ensure only one version of a package exists in the app\n if (metadata.type === \"pioneer-package\") {\n const existingMetadata = this._byName.get(metadata.name);\n if (\n existingMetadata &&\n normalizePath(existingMetadata.directory) !==\n normalizePath(metadata.directory)\n ) {\n throw new ReportableError(\n `Found package '${metadata.name}' at two different locations ${existingMetadata.directory} and ${metadata.directory}`\n );\n }\n this._byName.set(metadata.name, metadata);\n }\n\n return {\n metadata,\n watchFiles,\n warnings\n };\n },\n onInvalidate(directory: string, entry: MetadataEntry) {\n isDebug && debug(`Removed cache entry for '${entry.metadata.name}'`);\n this._byName.delete(entry.metadata.name);\n },\n onCachedReturn(directory: string, entry: MetadataEntry) {\n isDebug && debug(`Returning cached metadata for '${entry.metadata.name}'`);\n }\n };\n return new Cache(provider);\n }\n}\n\nfunction propagateWatchFiles(watchFiles: Iterable<string>, ctx: MetadataContext) {\n for (const file of watchFiles) {\n ctx.addWatchFile(file);\n }\n}\n\n/**\n * Is called if package metadata of a package are parsed\n * (for internal and external packages).\n * Depending on the location of the package either reads build config (source package)\n * or serialized metadata from package.json.\n */\nexport async function parsePackageMetadata(\n ctx: MetadataContext,\n packageDir: string,\n sourceRoot: string\n): Promise<InternalPackageMetadata> {\n const mode = isLocalPackage(packageDir, sourceRoot) ? \"local\" : \"external\";\n\n isDebug && debug(`Visiting package directory ${packageDir} in mode ${mode}.`);\n\n const packageJsonPath = join(packageDir, \"package.json\");\n\n ctx.addWatchFile(packageJsonPath);\n const {\n name: packageName,\n dependencies,\n frameworkMetadata\n } = await parsePackageJson(ctx, packageJsonPath);\n\n const configResult = await readConfig(\n ctx,\n packageDir,\n mode,\n frameworkMetadata,\n packageName,\n packageJsonPath\n );\n if (!configResult) {\n return {\n type: \"plain\",\n name: packageName,\n directory: packageDir\n };\n }\n\n const { config, configPath } = configResult;\n\n let servicesModule: string | undefined;\n if (config.services.size) {\n try {\n servicesModule = await resolveLocalFile(\n ctx,\n packageDir,\n config.servicesModule ?? \"./services\"\n );\n } catch (e) {\n ctx.warn({\n message: `Failed to resolve entry point for package ${packageDir}`,\n cause: e\n });\n }\n }\n\n let cssFile: string | undefined;\n if (config.styles) {\n try {\n cssFile = await resolveLocalFile(ctx, packageDir, config.styles);\n } catch (e) {\n throw new ReportableError(`Failed to resolve css file for package ${packageDir}`, {\n cause: e\n });\n }\n if (!cssFile) {\n throw new ReportableError(\n `Failed to find css file '${config.styles}' in ${packageDir}`\n );\n }\n }\n\n const i18nPaths = new Map<string, string>();\n for (const locale of config.languages) {\n if (i18nPaths.has(locale)) {\n throw new ReportableError(`Locale '${locale}' was defined twice in ${configPath}`);\n }\n\n const path = join(packageDir, \"i18n\", `${locale}.yaml`);\n ctx.addWatchFile(path);\n if (!(await fileExists(path))) {\n throw new ReportableError(`i18n file '${path}' does not exist.`);\n }\n\n i18nPaths.set(locale, normalizePath(path));\n }\n\n return {\n type: \"pioneer-package\",\n name: packageName,\n directory: packageDir,\n packageJsonPath: packageJsonPath,\n servicesModulePath: servicesModule,\n cssFilePath: cssFile,\n i18nPaths,\n dependencies,\n config: config\n };\n}\n\nasync function readConfig(\n ctx: MetadataContext,\n packageDir: string,\n mode: \"local\" | \"external\",\n frameworkMetadata: unknown,\n packageName: string,\n packageJsonPath: string\n) {\n switch (mode) {\n case \"local\": {\n const buildConfigPath = join(packageDir, BUILD_CONFIG_NAME);\n let buildConfig: PackageConfig | undefined;\n ctx.addWatchFile(normalizePath(buildConfigPath));\n if (await fileExists(buildConfigPath)) {\n try {\n buildConfig = await loadBuildConfig(buildConfigPath);\n } catch (e) {\n throw new ReportableError(`Failed to load build config ${buildConfigPath}`, {\n cause: e\n });\n }\n } else {\n throw new ReportableError(`Expected a ${BUILD_CONFIG_NAME} in ${packageDir}`);\n }\n return { configPath: buildConfigPath, config: buildConfig };\n }\n case \"external\": {\n if (!frameworkMetadata) {\n return undefined;\n }\n\n const metadataResult = PackageMetadataV1.parsePackageMetadata(frameworkMetadata);\n if (metadataResult.type === \"error\") {\n if (metadataResult.code === \"unsupported-version\") {\n throw new ReportableError(\n `Package '${packageName}' in ${packageDir} uses an unsupported metadata version.` +\n ` You will likely have to update ${PACKAGE_NAME}.\\n\\n` +\n metadataResult.message,\n { cause: metadataResult.cause }\n );\n }\n\n throw new ReportableError(\n `Failed to parse metadata of package '${packageName}' in ${packageDir}: ${metadataResult.message}`,\n { cause: metadataResult.cause }\n );\n }\n\n return {\n configPath: packageJsonPath,\n config: createPackageConfigFromPackageMetadata(metadataResult.value)\n };\n }\n }\n}\n\nasync function parsePackageJson(ctx: MetadataContext, packageJsonPath: string) {\n if (!(await fileExists(packageJsonPath))) {\n throw new ReportableError(`Expected a 'package.json' file at ${packageJsonPath}`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let packageJsonContent: any;\n try {\n packageJsonContent = JSON.parse(await readFile(packageJsonPath, \"utf-8\"));\n } catch (e) {\n throw new ReportableError(`Failed to read ${packageJsonPath}`, { cause: e });\n }\n\n const packageName = packageJsonContent.name;\n if (typeof packageName !== \"string\") {\n throw new ReportableError(`Expected 'name' to be a string in ${packageJsonPath}`);\n }\n\n // TODO handle peer dependencies\n const dependencies = packageJsonContent.dependencies ?? {};\n if (typeof dependencies !== \"object\") {\n throw new ReportableError(`Expected a valid 'dependencies' object in ${packageJsonPath}`);\n }\n\n const peerDependencies = packageJsonContent.peerDependencies ?? {};\n if (typeof peerDependencies !== \"object\") {\n throw new ReportableError(\n `Expected a valid 'peerDependencies' object in ${packageJsonPath}`\n );\n }\n\n const optionalDependencies = packageJsonContent.optionalDependencies ?? {};\n if (typeof optionalDependencies !== \"object\") {\n throw new ReportableError(\n `Expected a valid 'optionalDependencies' object in ${packageJsonPath}`\n );\n }\n\n const allDependencies: PackageDependency[] = [\n ...Object.keys(dependencies).map((packageName) => ({ packageName, optional: false })),\n ...Object.keys(peerDependencies).map((packageName) => ({\n packageName,\n optional: packageJsonContent?.peerDependenciesMeta?.[packageName]?.optional ?? false\n })),\n ...Object.keys(optionalDependencies).map((packageName) => ({ packageName, optional: true }))\n ];\n\n const frameworkMetadata = packageJsonContent[PackageMetadataV1.PACKAGE_JSON_KEY] ?? undefined;\n return {\n name: packageName,\n dependencies: allDependencies,\n frameworkMetadata: frameworkMetadata\n };\n}\n\nasync function resolveLocalFile(ctx: MetadataContext, packageDir: string, localModuleId: string) {\n const result = await ctx.resolve(`./${localModuleId}`, `${packageDir}/package.json`, {\n skipSelf: true\n });\n return result?.id;\n}\n\nfunction formatPackageLocation(loc: PackageLocation) {\n switch (loc.type) {\n case \"absolute\":\n return `${loc.directory}`;\n case \"unresolved\": {\n let name = `'${loc.dependency.packageName}'`;\n if (loc.dependency.optional) {\n name += \" (optional)\";\n }\n return `${name} required by ${loc.importedFrom}`;\n }\n }\n}\n\nconst NODE_MODULES_RE = /[\\\\/]node_modules[\\\\/]/;\n\nfunction isLocalPackage(file: string, sourceDir: string) {\n return isInDirectory(file, sourceDir) && !NODE_MODULES_RE.test(file);\n}\n\nconst PACKAGE_JSON_RE = /[\\\\/]package\\.json($|\\?)/;\n\nfunction isPackageJson(file: string) {\n return PACKAGE_JSON_RE.test(file);\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport * as fs from \"node:fs\";\nimport { isAbsolute, relative } from \"node:path\";\n\n/**\n * Asynchronously checks for the existence of `file`.\n */\nexport function fileExists(file: string): Promise<boolean> {\n return fs.promises\n .access(file, fs.constants.F_OK)\n .then(() => true)\n .catch(() => false);\n}\n\n/**\n * Returns true if `candidate` is a child of `directory`.\n */\nexport function isInDirectory(candidate: string, directory: string): boolean {\n const rel = relative(directory, candidate);\n const isChild = rel && !rel.startsWith(\"..\") && !isAbsolute(rel);\n return !!isChild;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * A simple cache implementing read-through semantics.\n *\n * The {@link CacheProvider} passed to the cache's constructor\n * implements the actual computation of values.\n *\n * The cache deduplicates computations and caches their results\n * until they are invalidated.\n */\nexport class Cache<Key, Value, Context extends unknown[] = []> {\n private values = new Map<string, Value>();\n private jobs = new Map<string, Promise<Value>>();\n private provider: CacheProvider<Key, Value, Context>;\n\n constructor(provider: CacheProvider<Key, Value, Context>) {\n this.provider = provider;\n }\n\n /**\n * Removes an entry associated with the given key.\n */\n invalidate(key: Key): void {\n const id = this.provider.getId(key);\n const oldValue = this.values.get(id);\n this.values.delete(id);\n this.jobs.delete(id);\n if (oldValue) {\n this.provider.onInvalidate?.(key, oldValue);\n }\n }\n\n /**\n * Retrieves the value associated with `key`.\n * A cached result will be used if present, otherwise the\n * cache provider will be called.\n *\n * Note: computations may throw errors.\n * Errors will not be cached.\n *\n * @param key the lookup key\n * @param context an arbitrary set of values that will be forwarded to the provider\n * should be provider be called.\n * @returns the value associated with `key`\n */\n async get(key: Key, ...context: Context): Promise<Value> {\n const provider = this.provider;\n const id = provider.getId(key);\n\n const values = this.values;\n const existingValue = values.get(id);\n if (existingValue) {\n provider.onCachedReturn?.(key, existingValue);\n return Promise.resolve(existingValue);\n }\n\n const jobs = this.jobs;\n const existingJob = jobs.get(id);\n if (existingJob) {\n return existingJob;\n }\n\n const job = provider.getValue(key, ...context);\n jobs.set(id, job);\n try {\n const value = await job;\n if (jobs.get(id) === job) {\n values.set(id, value);\n }\n return value;\n } finally {\n if (jobs.get(id) === job) {\n jobs.delete(id);\n }\n }\n }\n}\n\nexport interface CacheProvider<Key, Value, Context extends unknown[] = []> {\n /**\n * Maps the `key` to a unique id.\n * The id is used internally to store the result values.\n *\n * Keys mapping to the same `id` are treated as equivalent.\n */\n getId(key: Key): string;\n\n /**\n * Given a `key`, compute its associated `value`.\n * Only one computation for each `key` is started at a time.\n */\n getValue(key: Key, ...context: Context): Promise<Value>;\n\n /**\n * Called when the cache successfully invalidated an old value.\n */\n onInvalidate?(key: Key, oldValue: Value): void;\n\n /**\n * Called when the cache successfully returns a cached result.\n */\n onCachedReturn?(key: Key, value: Value): void;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport {\n BUILD_CONFIG_NAME,\n PackageConfig,\n createPackageConfigFromBuildConfig,\n loadBuildConfig as loadBuildConfigCommon,\n verifyBuildConfig\n} from \"@open-pioneer/build-common\";\nimport { basename } from \"node:path\";\n\n/**\n * Loads and parses a build configuration file from the given path on disk.\n */\nexport async function loadBuildConfig(path: string): Promise<PackageConfig> {\n const rawConfig = await loadBuildConfigCommon(path);\n return createPackageConfigFromBuildConfig(rawConfig);\n}\n\n/**\n * Parses a build configuration object and validates it.\n */\nexport function parseBuildConfig(object: unknown): PackageConfig {\n const rawConfig = verifyBuildConfig(object);\n return createPackageConfigFromBuildConfig(rawConfig);\n}\n\nexport function isBuildConfig(file: string) {\n return basename(file) === BUILD_CONFIG_NAME;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { readFile } from \"fs/promises\";\nimport { load as loadYaml } from \"js-yaml\";\nimport { z } from \"zod\";\nimport { fromZodError } from \"zod-validation-error\";\nimport { ReportableError } from \"../ReportableError\";\n\nexport interface I18nFile {\n /**\n * Direct messages for the current package.\n *\n * Key: message id, Value: message template string\n */\n messages: Map<string, string>;\n\n /**\n * Overrides for other packages.\n * Can be used from an app.\n *\n * Key: package name, Value: message record as in {@link messages}.\n */\n overrides: Map<string, Map<string, string>>;\n}\n\ninterface RawI18nFile {\n messages?: RecursiveMessages | null | undefined;\n overrides?: Record<string, RecursiveMessages | null | undefined> | null | undefined;\n}\n\ninterface RecursiveMessages {\n [key: string]: null | undefined | string | RecursiveMessages;\n}\n\nconst MESSAGES_SCHEMA: z.ZodType<RecursiveMessages | null | undefined> = z.lazy(() =>\n z.record(z.union([z.string(), MESSAGES_SCHEMA])).nullish()\n);\n\n// allow null for empty yaml objects\nconst I18N_SCHEMA: z.ZodType<RawI18nFile | null | undefined> = z\n .strictObject({\n messages: MESSAGES_SCHEMA.nullish().optional(),\n overrides: z.record(MESSAGES_SCHEMA).nullish().optional()\n })\n .nullish();\n\n/**\n * Loads an i18n.yaml file from the file system and parses it.\n */\nexport async function loadI18nFile(path: string): Promise<I18nFile> {\n let content;\n try {\n content = await readFile(path, \"utf-8\");\n } catch (e) {\n throw new ReportableError(`Failed to read ${path}`, { cause: e });\n }\n\n try {\n return parseI18nYaml(content);\n } catch (e) {\n throw new ReportableError(`Failed to parse ${path}`, { cause: e });\n }\n}\n\n/**\n * Parses an i18n yaml document.\n */\nexport function parseI18nYaml(yaml: string): I18nFile {\n const data = loadYaml(yaml);\n return parseI18nFile(data);\n}\n\n/**\n * Parses the JavaScript object representing an i18n file.\n */\nexport function parseI18nFile(data: unknown): I18nFile {\n const result = I18N_SCHEMA.safeParse(data);\n if (!result.success) {\n throw fromZodError(result.error);\n }\n\n const rawI18n = result.data;\n return {\n messages: gatherMessages(rawI18n?.messages ?? undefined),\n overrides: gatherOverrides(rawI18n?.overrides ?? undefined)\n };\n}\n\nfunction gatherMessages(data: RecursiveMessages | undefined): Map<string, string> {\n const messages = new Map<string, string>();\n const prefix: string[] = [];\n const visitChildren = (record: RecursiveMessages) => {\n for (const [key, value] of Object.entries(record)) {\n if (typeof value === \"string\") {\n visitMessage(key, value);\n } else if (value) {\n prefix.push(key);\n visitChildren(value);\n prefix.pop();\n }\n }\n };\n const visitMessage = (key: string, message: string) => {\n const id = [...prefix, key].join(\".\");\n if (messages.has(id)) {\n throw new Error(`Message '${id}' was already defined.`);\n }\n messages.set(id, message);\n };\n\n if (data) {\n visitChildren(data);\n }\n return messages;\n}\n\nfunction gatherOverrides(\n data: Record<string, RecursiveMessages | null | undefined> | undefined\n): Map<string, Map<string, string>> {\n const overrides = new Map<string, Map<string, string>>();\n if (data) {\n for (const [key, value] of Object.entries(data)) {\n const messages = gatherMessages(value ?? undefined);\n overrides.set(key, messages);\n }\n }\n return overrides;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport const PACKAGE_NAME = \"@open-pioneer/vite-plugin-pioneer\";\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\n\nexport type PackageMetadataInput = Pick<PackageMetadata, \"cssFilePath\">;\n\n/**\n * Generates a css file that imports the css file defined by the packages.\n */\nexport function generateCombinedCss(packages: PackageMetadataInput[]) {\n const cssImport = (file: string) => `@import ${JSON.stringify(file)};`;\n return packages\n .filter((pkg) => !!pkg.cssFilePath)\n .map((pkg) => cssImport(pkg.cssFilePath!)) // eslint-disable-line @typescript-eslint/no-non-null-assertion\n .join(\"\\n\");\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { dirname, basename } from \"node:path/posix\";\nimport { normalizePath } from \"vite\";\n\nconst APP_MODULE = \"@@open-pioneer-app\";\n\nconst APP_META_QUERY = \"open-pioneer-app\";\nconst APP_META_RE = /[?&]open-pioneer-app(?:$|&)/;\n\nconst APP_PACKAGES_QUERY = \"open-pioneer-packages\";\nconst APP_PACKAGES_RE = /[?&]open-pioneer-packages(?:$|&)/;\n\nconst APP_CSS_QUERY = \"open-pioneer-styles\";\nconst APP_CSS_RE = /[?&]open-pioneer-styles(?:$|&)/;\n\nconst APP_I18N_INDEX_QUERY = \"open-pioneer-i18n-index\";\nconst APP_I18N_INDEX_RE = /[?&]open-pioneer-i18n-index(?:$|&)/;\n\nconst APP_I18N_QUERY = \"open-pioneer-i18n\";\nconst APP_I18N_RE = /[?&]open-pioneer-i18n(?:$|&)/;\nconst APP_I18N_LOCALE_RE = /[?&]locale=(?<locale>.*?)(?:$|&)/;\n\nconst PACKAGE_HOOKS_MODULE = \"@@open-pioneer-react-hooks\";\n\nconst SOURCE_FILE_RE = /^(.*?)(?:\\?|$)/;\n\nexport type VirtualModule = VirtualAppModule | VirtualI18nMessages | VirtualPackageModule;\n\nexport interface VirtualAppModule {\n type: \"app-meta\" | \"app-packages\" | \"app-css\" | \"app-i18n-index\";\n packageDirectory: string;\n}\n\nexport interface VirtualI18nMessages {\n type: \"app-i18n\";\n packageDirectory: string;\n locale: string;\n}\n\nexport interface VirtualPackageModule {\n type: \"package-hooks\";\n packageDirectory: string;\n}\n\n/**\n * Takes a module id as input and parses it.\n * If this plugin is not responsible to load the module id, this function returns `undefined`.\n *\n * Otherwise, the module is parsed into an object and returned.\n */\nexport function parseVirtualModuleId(inputModuleId: string): VirtualModule | undefined {\n const moduleId = normalizePath(inputModuleId);\n if (!moduleId || moduleId.includes(\"\\\\0\")) {\n return undefined;\n }\n\n const sourceFile = getSourceFile(moduleId); // module id with out query\n if (!sourceFile) {\n return undefined;\n }\n\n const base = basename(sourceFile);\n if (base === PACKAGE_HOOKS_MODULE) {\n return {\n type: \"package-hooks\",\n packageDirectory: dirname(sourceFile)\n };\n }\n if (base === APP_MODULE) {\n return parseAppModuleId(sourceFile, moduleId);\n }\n return undefined;\n}\n\nfunction parseAppModuleId(sourceFile: string, moduleId: string): VirtualModule | undefined {\n const packageDirectory = dirname(sourceFile);\n if (moduleId.match(APP_META_RE)) {\n const type = \"app-meta\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_PACKAGES_RE)) {\n const type = \"app-packages\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_CSS_RE)) {\n const type = \"app-css\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_I18N_INDEX_RE)) {\n const type = \"app-i18n-index\";\n return { type, packageDirectory };\n } else if (moduleId.match(APP_I18N_RE)) {\n const type = \"app-i18n\";\n const locale = moduleId.match(APP_I18N_LOCALE_RE)?.groups?.[\"locale\"];\n if (!locale) {\n throw new Error(\"Missing locale name in i18n module request\");\n }\n return { type, packageDirectory, locale };\n }\n throw new Error(`Unexpected module id: ${moduleId}`);\n}\n\n/**\n * Serializes the given virtual module descriptor into a module id string.\n */\nexport function serializeModuleId(mod: VirtualModule): string {\n switch (mod.type) {\n case \"package-hooks\":\n return `${mod.packageDirectory}/${PACKAGE_HOOKS_MODULE}`;\n case \"app-meta\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_META_QUERY}`;\n case \"app-packages\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_PACKAGES_QUERY}`;\n case \"app-css\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_CSS_QUERY}`;\n case \"app-i18n-index\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_I18N_INDEX_QUERY}`;\n case \"app-i18n\":\n return `${mod.packageDirectory}/${APP_MODULE}?${APP_I18N_QUERY}&locale=${mod.locale}`;\n }\n}\n\nfunction getSourceFile(moduleId: string) {\n const sourceFile = moduleId.match(SOURCE_FILE_RE)?.[1];\n if (!sourceFile || moduleId[0] == \"\\0\") {\n return undefined;\n }\n return sourceFile;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { serializeModuleId } from \"./shared\";\n\n/**\n * Generates the main app metadata module.\n * It delegates the actual metadata generation to auxiliary modules.\n */\nexport function generateAppMetadata(packageDirectory: string, metadataModuleId: string) {\n /*\n CSS loading: \n - 'inline' loads the (s)css as a string literal.\n - the suffix (e.g. '.scss') at the very end is important to trigger the correct vite plugin!\n using .scss supports both .css and .scss, since .css files can be imported from .scss when using vite.\n - I would like to import css as an url instead (separate file),\n but that currently hinges on https://github.com/vitejs/vite/pull/11084\n\n Hot reloading:\n - See https://vitejs.dev/guide/api-hmr.html for vite's HMR API\n - When a css string changes, the module exporting the `stylesString` below changes.\n We accept those changes through the `import.meta.hot.accept` mechanism by\n calling the `setValue` method on the old observable box value.\n The runtime has a reference to the box and watches for changes (only during development!)\n - The code below takes care to use the _correct_ `styles` box (every module has its own, even the new version).\n `import.meta.hot.data` is shared between all versions of the module, so we always use the first box.\n */\n const packagesModule = serializeModuleId({ type: \"app-packages\", packageDirectory });\n const cssModule =\n serializeModuleId({ type: \"app-css\", packageDirectory }) + \"&inline&lang.scss\";\n const i18nModule = serializeModuleId({ type: \"app-i18n-index\", packageDirectory });\n return `\nimport { createBox } from ${JSON.stringify(metadataModuleId)};\nimport packages from ${JSON.stringify(packagesModule)};\nimport stylesString from ${JSON.stringify(cssModule)};\nimport { locales, loadMessages } from ${JSON.stringify(i18nModule)};\n\nconst styles = createBox(stylesString);\nif (import.meta.hot) {\n import.meta.hot.data.styles ??= styles;\n import.meta.hot.accept((mod) => {\n if (mod && mod.packages === packages && mod.locales === locales && mod.loadMessages === loadMessages) {\n import.meta.hot.data.styles.setValue(mod.styles.value);\n return;\n }\n \n // Cannot handle all other changes the moment; trigger reload.\n import.meta.hot.invalidate();\n });\n}\n\nexport {\n packages,\n styles,\n locales,\n loadMessages\n};\n`.trim();\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport function generateReactHooks(packageName: string, runtimeModuleId: string) {\n return `\nimport { useServiceInternal, useServicesInternal, usePropertiesInternal, useIntlInternal } from ${JSON.stringify(\n runtimeModuleId\n )};\n\nconst PACKAGE_NAME = ${JSON.stringify(packageName)};\nexport const useService = /*@__PURE__*/ useServiceInternal.bind(undefined, PACKAGE_NAME);\nexport const useServices = /*@__PURE__*/ useServicesInternal.bind(undefined, PACKAGE_NAME);\nexport const useProperties = /*@__PURE__*/ usePropertiesInternal.bind(undefined, PACKAGE_NAME);\nexport const useIntl = /*@__PURE__*/ useIntlInternal.bind(undefined, PACKAGE_NAME);\n `.trim();\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport * as nodes from \"@babel/types\";\nimport template from \"@babel/template\";\nimport { serializeModuleId } from \"./shared\";\nimport generate from \"@babel/generator\";\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\nimport { ReportableError } from \"../ReportableError\";\nimport { I18nFile } from \"../metadata/parseI18nYaml\";\n\nconst INDEX_TEMPLATE = template.program(`\n export const locales = %%LOCALES_ARRAY%%;\n\n export function loadMessages(locale) {\n %%LOCALE_SWITCH%%\n throw new Error(\\`Unsupported locale: '\\${locale}'\\`);\n }\n`);\n\nconst IMPORT_TEMPLATE = template.statement(`\n return import(%%MODULE_ID%%).then(mod => mod.default);\n`);\n\nconst MESSAGES_TEMPLATE = template.program(`\n const messages = JSON.parse(%%SERIALIZED%%);\n export default messages;\n`);\n\n/**\n * Generates a lookup table for the languages supported by the given application.\n */\nexport function generateI18nIndex(packageDirectory: string, locales: string[]): string {\n const localesArray = nodes.arrayExpression(\n locales.map((locale) => nodes.stringLiteral(locale))\n );\n const switchStmt = nodes.switchStatement(\n nodes.identifier(\"locale\"),\n locales.map((locale) => {\n const localeModuleId = serializeModuleId({\n type: \"app-i18n\",\n packageDirectory,\n locale\n });\n const importStatement = IMPORT_TEMPLATE({\n MODULE_ID: nodes.stringLiteral(localeModuleId)\n });\n return nodes.switchCase(nodes.stringLiteral(locale), [importStatement]);\n })\n );\n\n const program = INDEX_TEMPLATE({\n LOCALES_ARRAY: localesArray,\n LOCALE_SWITCH: switchStmt\n });\n return generate(program).code;\n}\n\nexport interface I18nMessageOptions {\n /** The locale to generate. */\n locale: string;\n\n /**\n * The name of the current application.\n * Used to detect the application page for overrides.\n */\n appName: string;\n\n /** All packages in the application (including the app). */\n packages: Pick<PackageMetadata, \"name\" | \"i18nPaths\">[];\n\n /** Called by the function when the contents of an i18n file (in i18nPaths) is required. */\n loadI18n: (path: string) => Promise<I18nFile>;\n}\n\n/**\n * Generates a messages module containing a single default export: the messages record.\n *\n * Messages are taken from the given packages (for the specified locale).\n */\nexport async function generateI18nMessages(options: I18nMessageOptions): Promise<string> {\n const { locale, appName, packages, loadI18n } = options;\n const packageMessages = new Map<string, Map<string, string>>();\n const packagesNeedingMessages = new Set<string>();\n let packageOverrides: Map<string, Map<string, string>> | undefined;\n for (const pkg of packages) {\n if (pkg.i18nPaths.size !== 0) {\n // Remember packages that have i18n settings. If they are not supported\n // in a given language, and the app does not specify custom messages for this package, an error is emitted.\n packagesNeedingMessages.add(pkg.name);\n }\n\n const filePath = pkg.i18nPaths.get(locale);\n if (!filePath) {\n continue;\n }\n\n const { messages, overrides } = await loadI18n(filePath);\n if (pkg.name === appName) {\n packageOverrides = overrides;\n } else if (overrides.size !== 0) {\n throw new ReportableError(\n `Unexpected 'overrides' block in '${filePath}'. Overrides are only supported in the app.`\n );\n }\n\n packageMessages.set(pkg.name, messages);\n }\n\n // Override messages\n if (packageOverrides) {\n for (const [packageName, messages] of packageOverrides.entries()) {\n const existingMessages = packageMessages.get(packageName);\n if (!existingMessages) {\n packageMessages.set(packageName, messages);\n continue;\n }\n\n const updatedMessages = new Map([...existingMessages, ...messages]);\n packageMessages.set(packageName, updatedMessages);\n }\n }\n\n // Verify that required messages are present\n for (const packageName of packagesNeedingMessages) {\n const messages = packageMessages.get(packageName);\n if (!messages) {\n throw new ReportableError(\n `Package '${packageName}' requires messages for locale '${locale}'. Either update the package or add messages from the app via 'overrides'.`\n );\n }\n }\n\n // Translate to json for codegen. Package name -> key -> i18n message template\n const allMessages: Record<string, Record<string, string>> = {};\n for (const [packageName, messages] of packageMessages.entries()) {\n allMessages[packageName] = Object.fromEntries(messages.entries());\n }\n\n // Transport the object as a json string for improved parsing performance\n const serialized = JSON.stringify(allMessages);\n const program = MESSAGES_TEMPLATE({\n SERIALIZED: nodes.stringLiteral(serialized)\n });\n return generate(program).code;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { Plugin, ResolvedConfig } from \"vite\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { posix } from \"node:path\";\nimport { cwd } from \"node:process\";\nimport { type PioneerPluginOptions } from \".\";\nimport { RollupOptions } from \"rollup\";\nimport { AdvancedAppOptions } from \"../types\";\n\nexport function mpaPlugin(options: PioneerPluginOptions | undefined): Plugin {\n const rootSite = options?.rootSite ?? false;\n const apps = options?.apps || [];\n const sites = options?.sites || [];\n\n let resolvedConfig: ResolvedConfig;\n return {\n name: \"pioneer:mpa\",\n\n config(config) {\n const sourceRoot = config.root ?? cwd();\n const { entryPoints, appNames } = gatherEntryPoints({\n apps,\n sites,\n rootSite,\n sourceRoot\n });\n const rollupOptions: RollupOptions = {\n input: entryPoints,\n output: {\n entryFileNames(chunk) {\n if (appNames.includes(chunk.name)) {\n return \"[name].js\";\n }\n\n // This will rename the .js files that belong to a .html site, they don't need a public name.\n return posix.join(resolvedConfig.build.assetsDir, \"[hash:12].js\");\n },\n chunkFileNames(chunk) {\n void chunk; // ignored\n return posix.join(resolvedConfig.build.assetsDir, \"[hash:12].js\");\n }\n }\n };\n\n return {\n build: {\n rollupOptions\n }\n };\n },\n\n configResolved(config) {\n resolvedConfig = config;\n }\n };\n}\n\nexport interface EntryPointInfo {\n // Parsed rollup entry points\n entryPoints: Record<string, string>;\n\n // All app names used by the project\n appNames: string[];\n}\n\nfunction gatherEntryPoints(options: {\n apps: string[] | AdvancedAppOptions;\n sites: string[];\n rootSite: boolean;\n sourceRoot: string;\n}): EntryPointInfo {\n interface RawEntryPoint {\n name: string;\n path: string;\n }\n\n let apps: RawEntryPoint[];\n if (Array.isArray(options.apps)) {\n apps = options.apps.map((appName) => {\n const prefix = resolve(options.sourceRoot, \"apps\", appName, \"app\");\n const path = findMatchingEntryPointFile(appName, prefix);\n return {\n name: appName,\n path: path\n };\n });\n } else {\n apps = Object.entries(options.apps).map(([name, appPath]) => {\n const path = resolve(options.sourceRoot, appPath);\n if (!existsSync(path)) {\n throw new Error(\n `Failed to find app '${name}' at ${path}. Ensure that the path is spelled correctly.`\n );\n }\n return { name, path };\n });\n }\n\n /*\n * Vite does not respect the entry point name for html files, it\n * put each html site at a location mirroring the source directory structure (e.g. site/<SITE>/index.html\n * instead of SITE.html).\n *\n * There are multiple vite mpa plugins that handle custom html paths which can either be used\n * directly or as inspiration.\n */\n const sites = options.sites.map((sitePath) => {\n const path = resolve(options.sourceRoot, sitePath, \"index.html\");\n if (!existsSync(path)) {\n throw new Error(\n `Failed to find site at ${path}. Ensure that the site name in your vite configuration is spelled correctly.`\n );\n }\n return {\n name: sitePath,\n path: path\n };\n });\n if (options.rootSite) {\n const path = resolve(options.sourceRoot, \"index.html\");\n if (!existsSync(path)) {\n throw new Error(\n `Failed to find root site at ${path}. Create the missing file or set 'rootSite' to false.`\n );\n }\n sites.push({\n name: \"index\",\n path: path\n });\n }\n\n const entryPoints: Record<string, string> = {};\n let entryPointCount = 0;\n for (const { name, path } of [apps, sites].flat()) {\n const existingPath = entryPoints[name];\n if (existingPath) {\n throw new Error(\n `Entry point '${name}' was defined twice (paths ${existingPath} and ${path}). Remove the duplicated entry.`\n );\n }\n entryPoints[name] = path;\n ++entryPointCount;\n }\n if (entryPointCount === 0) {\n throw new Error(\n \"You must configure at least one site or one app in the pioneer plugin options.\"\n );\n }\n\n const appNames = apps.map(({ name }) => name);\n return {\n entryPoints,\n appNames\n };\n}\n\nconst EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\"];\n\nfunction findMatchingEntryPointFile(appName: string, prefix: string) {\n for (const ext of EXTENSIONS) {\n const candidate = prefix + ext;\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const extensions = EXTENSIONS.join(\", \");\n throw new Error(\n `Failed to find a matching entry point file for app '${appName}' at ${prefix}.` +\n ` Supported extensions are ${extensions}.` +\n ` Ensure that the app name is spelled correctly or create the missing file.`\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,qBAA2B;AAC3B,IAAAA,oBAA8B;AAE9B,IAAAC,eAAqE;;;ACHrE,mBAAsB;AAMf,SAAS,eAAe,WAA6B;AACxD,QAAM,aAAS,oBAAM,SAAS;AAC9B,SAAO,SAAS,iBAAiB,MAAM;AACnC,WAAO,GAAG,IAAI;AAAA,EAClB;AACJ;;;ACXA,uBAAqB;AACrB,sBAAqB;AACrB,YAAuB;;;ACFhB,IAAM,kBAAN,cAA8B,MAAM;AAAC;;;ACArC,IAAM,cAAN,MAAkB;AAAA,EACb,WAAW,oBAAI,IAAoB;AAAA;AAAA;AAAA;AAAA,EAK3C,SAAS,OAAuB;AAC5B,UAAM,QAAQ,UAAU,KAAK;AAE7B,UAAM,WAAW,KAAK;AACtB,UAAM,QAAQ,SAAS,IAAI,KAAK,KAAK;AACrC,aAAS,IAAI,OAAO,QAAQ,CAAC;AAC7B,WAAO,UAAU,IAAI,QAAQ,GAAG,SAAS;AAAA,EAC7C;AACJ;AAEA,SAAS,UAAU,OAAe;AAC9B,MAAI,QAAQ,MAAM,QAAQ,mBAAmB,GAAG;AAChD,UAAQ,MAAM,QAAQ,WAAW,EAAE;AACnC,MAAI,MAAM,KAAK,KAAK,GAAG;AACnB,YAAQ,MAAM;AAAA,EAClB;AACA,SAAO,SAAS;AACpB;;;AFfA,IAAM,iBAAiB,gBAAAC,QAAS,UAAU;AAAA;AAAA,CAEzC;AAED,IAAM,aAAa,gBAAAA,QAAS,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAOtC;AA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AAC3B,YAAI,4BAAW,SAAS,GAAG;AACvB,aAAO;AAAA,IACX;AAAA,EACJ;AAEA,QAAM,aAAa,WAAW,KAAK,IAAI;AACvC,QAAM,IAAI;AAAA,IACN,uDAAuD,eAAe,oCACrC;AAAA,EAErC;AACJ;;;AjBtKO,SAAS,QAAQ,SAA0C;AAC9D,SAAO,CAAC,UAAU,OAAO,GAAG,cAAc,CAAC;AAC/C;",
|
|
6
|
+
"names": ["import_node_path", "import_vite", "template", "program", "generate", "import_promises", "import_node_path", "loadBuildConfigCommon", "loadYaml", "import_build_common", "debug", "packageName", "import_vite", "import_promises", "nodes", "import_template", "import_generator", "template", "program", "generate", "isDebug", "debug", "resolve", "packageJsonPath", "import_node_fs", "import_node_path"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-pioneer/vite-plugin-pioneer",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "types.d.ts",
|
|
6
|
-
"type": "
|
|
6
|
+
"type": "commonjs",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist/**/*.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"js-yaml": "^4.1.0",
|
|
28
28
|
"zod": "^3.21.4",
|
|
29
29
|
"zod-validation-error": "^1.3.0",
|
|
30
|
-
"@open-pioneer/build-common": "^0.3.
|
|
30
|
+
"@open-pioneer/build-common": "^0.3.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/babel__generator": "^7.6.4",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"rollup": "^3.23.0",
|
|
42
42
|
"sass": "^1.62.1",
|
|
43
43
|
"vite": "^4.3.8",
|
|
44
|
-
"@open-pioneer/build-support": "^0.5.
|
|
45
|
-
"@open-pioneer/vite-plugin-pioneer": "^0.6.
|
|
44
|
+
"@open-pioneer/build-support": "^0.5.1",
|
|
45
|
+
"@open-pioneer/vite-plugin-pioneer": "^0.6.1",
|
|
46
46
|
"build-tools": "0.0.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|