@open-pioneer/vite-plugin-pioneer 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog @open-pioneer/vite-plugin-pioneer
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 434cc23: Migrate all tests to vitest.
8
+ - 41399fa: Use new shared package to validate build.config.mjs
9
+ - Updated dependencies [41399fa]
10
+ - @open-pioneer/build-common@0.1.0
11
+
3
12
  ## 0.5.1
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -139,11 +139,7 @@ This plugin internally configures the rollup options inside vite's config to ach
139
139
  To manually build the plugin, run `pnpm run build`.
140
140
  This build does _not_ include tests.
141
141
 
142
- `pnpm run dev` will continuously rebuild the code (including tests files).
143
-
144
- `pnpm run test` will execute all tests using mocha.
145
- If you create a new test file, make sure to list it in `src/all.test.ts`.
146
- It will not run otherwise.
142
+ `pnpm run test` will execute all tests using vitest.
147
143
 
148
144
  ### Debugging the vite plugin
149
145
 
@@ -168,21 +164,6 @@ open-pioneer:codegen Adding manual watch for /home/michael/projects/starter/src/
168
164
 
169
165
  You can also add a `--debug` flag to `vite` to show vite's internal log messages.
170
166
 
171
- ### Snapshots
172
-
173
- We're using an ad-hoc implementation of snapshot tests for some generated files.
174
- Pass the environment variable `SNAPSHOTS=1` to (re-) generate snapshots:
175
-
176
- ```bash
177
- $ SNAPSHOTS=1 pnpm run test
178
- ```
179
-
180
- In your test code, reference the `GENERATE_SNAPSHOTS` constant (which is initialized from the environment variable):
181
-
182
- ```js
183
- import { GENERATE_SNAPSHOTS } from "../utils/testUtils";
184
- ```
185
-
186
167
  ## License
187
168
 
188
169
  ```
package/dist/index.js CHANGED
@@ -1,46 +1,46 @@
1
- "use strict";var Oe=Object.create;var j=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ue=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},X=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of je(t))!Ve.call(e,o)&&o!==n&&j(e,o,{get:()=>t[o],enumerable:!(r=Le(t,o))||r.enumerable});return e};var I=(e,t,n)=>(n=e!=null?Oe(ze(e)):{},X(t||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),Te=e=>X(j({},"__esModule",{value:!0}),e);var qt={};Ue(qt,{pioneer:()=>Kt});module.exports=Te(qt);var Se=require("node:fs"),_=require("node:path"),$=require("vite");var ee=require("debug");function z(e){let t=(0,ee.debug)(e);return function(...r){t(...r)}}var ne=I(require("@babel/generator")),R=I(require("@babel/template")),c=I(require("@babel/types"));var f=class extends Error{};var V=class{existing=new Map;generate(t){let n=De(t),r=this.existing,o=r.get(n)??0;return r.set(n,o+1),o===0?n:`${n}_${o}`}};function De(e){let t=e.replace(/[^A-Za-z0-9_]+/g,"_");return t=t.replace(/[\d_]+$/,""),/^\d/.test(t)&&(t="_"+t),t||"var"}var Je=R.default.statement(`
1
+ "use strict";var Ne=Object.create;var L=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var je=(e,t)=>{for(var n in t)L(e,n,{get:t[n],enumerable:!0})},Z=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of be(t))!Le.call(e,i)&&i!==n&&L(e,i,{get:()=>t[i],enumerable:!(r=Fe(t,i))||r.enumerable});return e};var w=(e,t,n)=>(n=e!=null?Ne(Oe(e)):{},Z(t||!e||!e.__esModule?L(n,"default",{value:e,enumerable:!0}):n,e)),Ve=e=>Z(L({},"__esModule",{value:!0}),e);var jt={};je(jt,{pioneer:()=>Lt});module.exports=Ve(jt);var we=require("node:fs"),A=require("node:path"),_=require("vite");var X=require("debug");function j(e){let t=(0,X.debug)(e);return function(...r){t(...r)}}var te=w(require("@babel/generator")),v=w(require("@babel/template")),c=w(require("@babel/types"));var u=class extends Error{};var V=class{existing=new Map;generate(t){let n=Ue(t),r=this.existing,i=r.get(n)??0;return r.set(n,i+1),i===0?n:`${n}_${i}`}};function Ue(e){let t=e.replace(/[^A-Za-z0-9_]+/g,"_");return t=t.replace(/[\d_]+$/,""),/^\d/.test(t)&&(t="_"+t),t||"var"}var ze=v.default.statement(`
2
2
  import { %%SERVICE_NAME%% as %%IMPORT_NAME%% } from %%IMPORT_SOURCE%%;
3
- `),Ge=R.default.expression(`
3
+ `),De=v.default.expression(`
4
4
  {
5
5
  name: %%PACKAGE_NAME%%,
6
6
  services: %%PACKAGE_SERVICES%%,
7
7
  ui: %%PACKAGE_UI%%,
8
8
  properties: %%PROPERTIES%%
9
9
  }
10
- `),Be=R.default.expression(`
10
+ `),Te=v.default.expression(`
11
11
  {
12
12
  name: %%SERVICE_NAME%%,
13
13
  clazz: %%SERVICE_IMPORT%%,
14
14
  provides: %%SERVICE_INTERFACES%%,
15
15
  references: %%SERVICE_REFERENCES%%
16
16
  }
17
- `),Ke=R.default.expression(`
17
+ `),Je=v.default.expression(`
18
18
  {
19
19
  name: %%INTERFACE_NAME%%,
20
20
  qualifier: %%QUALIFIER%%
21
21
  }
22
- `),qe=R.default.expression(`
22
+ `),Ge=v.default.expression(`
23
23
  {
24
24
  name: %%INTERFACE_NAME%%,
25
25
  qualifier: %%QUALIFIER%%,
26
26
  all: %%ALL%%
27
27
  }
28
- `),We=R.default.expression(`
28
+ `),Ke=v.default.expression(`
29
29
  {
30
30
  references: %%UI_REFERENCES%%
31
31
  }
32
- `),He=R.default.expression(`
32
+ `),Be=v.default.expression(`
33
33
  {
34
34
  value: %%VALUE%%,
35
35
  required: %%REQUIRED%%
36
36
  }
37
- `);function re(e){let t=new V,n=c.objectExpression([]),r=[];for(let i of e){let a=Ze(i,{importServiceClass(s,p,d){let g=t.generate(s),u=Je({SERVICE_NAME:c.identifier(p),IMPORT_NAME:c.identifier(g),IMPORT_SOURCE:c.stringLiteral(d)});return r.push(u),g}});n.properties.push(c.objectProperty(c.stringLiteral(i.name),a))}let o=c.program([...r,c.exportDefaultDeclaration(n)]);return(0,ne.default)(o).code}function Ze(e,t){let n=c.objectExpression([]);for(let a of e.config.services){if(!e.servicesModulePath)throw new f(`Package '${e.name}' must have a valid services module (typically 'services.ts' or 'services.js').
38
- The entry point can be configured by setting the 'servicesModule' property in the build.config.mjs.`);let s=t.importServiceClass(e.name+"_"+a.name,a.name,e.servicesModulePath),p=Be({SERVICE_NAME:c.stringLiteral(a.name),SERVICE_IMPORT:c.identifier(s),SERVICE_INTERFACES:c.arrayExpression(a.provides.map(d=>Ke({INTERFACE_NAME:c.stringLiteral(d.name),QUALIFIER:d.qualifier==null?ae():c.stringLiteral(d.qualifier)}))),SERVICE_REFERENCES:c.objectExpression(Object.entries(a.references).map(([d,g])=>c.objectProperty(c.stringLiteral(d),te(g))))});n.properties.push(c.objectProperty(c.stringLiteral(a.name),p))}let r=We({UI_REFERENCES:c.arrayExpression(e.config.ui.references.map(a=>te(a)))}),o=c.objectExpression(e.config.properties.map(a=>c.objectProperty(c.stringLiteral(a.name),He({VALUE:B(a.defaultValue),REQUIRED:c.booleanLiteral(a.required)}))));return Ge({PACKAGE_NAME:c.stringLiteral(e.name),PACKAGE_SERVICES:n,PACKAGE_UI:r,PROPERTIES:o})}function B(e){if(e==null)return c.nullLiteral();if(typeof e=="string")return c.stringLiteral(e);if(typeof e=="number")return c.numericLiteral(e);if(typeof e=="boolean")return c.booleanLiteral(e);if(Array.isArray(e))return c.arrayExpression(e.map(t=>B(t)));if(typeof e=="object")return c.objectExpression(Object.entries(e).map(([t,n])=>c.objectProperty(c.stringLiteral(t),B(n))));throw new Error(`Unexpected value while serializing JSON: ${e}.`)}function te(e){return qe({INTERFACE_NAME:c.stringLiteral(e.name),QUALIFIER:e.qualifier?c.stringLiteral(e.qualifier):ae(),ALL:c.booleanLiteral(e.all??!1)})}function ae(){return c.unaryExpression("void",c.numericLiteral(0))}var b=require("fs/promises"),S=require("path"),w=require("vite");var U=I(require("node:fs")),T=require("node:path");function D(e){return U.promises.access(e,U.constants.F_OK).then(()=>!0).catch(()=>!1)}function oe(e,t){let n=(0,T.relative)(t,e);return!!(n&&!n.startsWith("..")&&!(0,T.isAbsolute)(n))}var N=class{values=new Map;jobs=new Map;provider;constructor(t){this.provider=t}invalidate(t){var o,i;let n=this.provider.getId(t),r=this.values.get(n);this.values.delete(n),this.jobs.delete(n),r&&((i=(o=this.provider).onInvalidate)==null||i.call(o,t,r))}async get(t,...n){var g;let r=this.provider,o=r.getId(t),i=this.values,a=i.get(o);if(a)return(g=r.onCachedReturn)==null||g.call(r,t,a),Promise.resolve(a);let s=this.jobs,p=s.get(o);if(p)return p;let d=r.getValue(t,...n);s.set(o,d);try{let u=await d;return s.get(o)===d&&i.set(o,u),u}finally{s.get(o)===d&&s.delete(o)}}};var de=require("node:url");var l=require("zod"),ie=require("zod-validation-error"),Ye=l.z.union([l.z.string(),l.z.number(),l.z.boolean(),l.z.null()]),K=l.z.lazy(()=>l.z.union([Ye,l.z.array(K),l.z.record(K)])),Qe=l.z.strictObject({required:l.z.boolean().optional()}),se=l.z.strictObject({name:l.z.string(),qualifier:l.z.string().optional(),all:l.z.boolean().optional()}),Xe=l.z.strictObject({name:l.z.string(),qualifier:l.z.string().optional()}),et=l.z.strictObject({references:l.z.array(l.z.string().or(se)).optional()}),tt=l.z.strictObject({provides:l.z.string().or(l.z.array(l.z.string().or(Xe))).optional(),references:l.z.record(l.z.string(),l.z.string().or(se)).optional()}),nt=l.z.strictObject({styles:l.z.string().optional(),i18n:l.z.array(l.z.string()).optional(),services:l.z.record(l.z.string(),tt).optional(),servicesModule:l.z.string().optional(),ui:et.optional(),properties:l.z.record(l.z.string(),K).optional(),propertiesMeta:l.z.record(l.z.string(),Qe).optional()});function ce(e){let t=nt.safeParse(e);if(t.success)return t.data;throw(0,ie.fromZodError)(t.error)}var q="build.config.mjs",rt=0;async function pe(e){let n=await import(`${(0,de.pathToFileURL)(e)}?id=${++rt}`);if(!n||!n.default)throw new Error("The module must contain a default export.");let r=n.default;return at(r)}function at(e){let t=ce(e);return it(t)}var ot=/[\\/]build\.config\.mjs($|\?)/;function le(e){return ot.test(e)}function it(e){return{styles:e.styles,i18n:e.i18n,services:Object.entries(e.services??{}).map(([t,n])=>st(t,n)),servicesModule:e.servicesModule,ui:pt(e.ui),properties:lt(e.properties,e.propertiesMeta)}}function st(e,t){return{name:e,provides:ct(t.provides),references:dt(t.references)}}function ct(e){return e?typeof e=="string"?[{name:e}]:e.map(t=>typeof t=="string"?{name:t}:t):[]}function dt(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,ge(n)])):{}}function ge(e){return typeof e=="string"?{name:e}:e}function pt(e){var t;return{references:((t=e==null?void 0:e.references)==null?void 0:t.map(ge))??[]}}function lt(e,t){var r;let n=[];for(let[o,i]of Object.entries(e??{})){let a=((r=t==null?void 0:t[o])==null?void 0:r.required)??!1;n.push({name:o,defaultValue:i,required:a})}return n}var ue=require("fs/promises"),fe=require("js-yaml"),x=require("zod"),me=require("zod-validation-error");var W=x.z.lazy(()=>x.z.record(x.z.union([x.z.string(),W])).nullish()),gt=x.z.strictObject({messages:W.nullish().optional(),overrides:x.z.record(W).nullish().optional()}).nullish();async function he(e){let t;try{t=await(0,ue.readFile)(e,"utf-8")}catch(n){throw new f(`Failed to read ${e}: ${n}`)}try{return ut(t)}catch(n){throw new f(`Failed to parse ${e}: ${n}`)}}function ut(e){let t=(0,fe.load)(e);return ft(t)}function ft(e){let t=gt.safeParse(e);if(!t.success)throw(0,me.fromZodError)(t.error);let n=t.data;return{messages:Ee((n==null?void 0:n.messages)??void 0),overrides:mt((n==null?void 0:n.overrides)??void 0)}}function Ee(e){let t=new Map,n=[],r=i=>{for(let[a,s]of Object.entries(i))typeof s=="string"?o(a,s):s&&(n.push(a),r(s),n.pop())},o=(i,a)=>{let s=[...n,i].join(".");if(t.has(s))throw new Error(`Message '${s}' was already defined.`);t.set(s,a)};return e&&r(e),t}function mt(e){let t=new Map;if(e)for(let[n,r]of Object.entries(e)){let o=Ee(r??void 0);t.set(n,o)}return t}var y=!!process.env.DEBUG,P=z("open-pioneer:metadata"),J=class{sourceRoot;packageMetadataCache;i18nCache;constructor(t){this.sourceRoot=t,this.packageMetadataCache=this.createPackageMetadataCache(),this.i18nCache=this.createI18nCache()}reset(){this.packageMetadataCache=this.createPackageMetadataCache(),this.i18nCache=this.createI18nCache()}onFileChanged(t){(vt(t)||le(t))&&this.packageMetadataCache.invalidate((0,S.dirname)(t)),this.i18nCache.invalidate(t)}async getAppMetadata(t,n){y&&P(`Request for app metadata of ${n}`);let r=await this.getPackageMetadata(t,{type:"absolute",directory:n});if(!r)throw new f(`Failed to parse app metadata in ${n}. Ensure that the app is a valid local package.`);let o=Array.from(r.i18nPaths.keys()),i=new Map;i.set(r.name,r);let a=async(p,d)=>{let g=p.map(async u=>{let m=await this.getPackageMetadata(t,{type:"unresolved",packageName:u,importedFrom:d});m&&(i.has(m.name)||i.set(m.name,m),await a(m.dependencies,m.packageJsonPath))});return await Promise.all(g)};return await a(r.dependencies,r.packageJsonPath),{name:r.name,directory:r.directory,locales:o,packageJsonPath:r.packageJsonPath,packages:Array.from(i.values())}}async getPackageMetadata(t,n){y&&P(`Request for package metadata of ${yt(n)}`);let r=await this.resolvePackageLocation(t,n);if(!Mt(r,this.sourceRoot)){y&&P(`Skipping non-local package '${r}'.`);return}let o=await this.packageMetadataCache.get(r,t);ye(o.watchFiles,t);for(let i of o.warnings)t.warn(i);return o.metadata}async getI18nFile(t,n){let{i18n:r,watchFiles:o}=await this.i18nCache.get(n,t);return ye(o,t),r}async resolvePackageLocation(t,n){if(n.type==="absolute")return await(0,b.realpath)(n.directory);let r=`${n.packageName}/package.json`,o=await t.resolve(r,(0,w.normalizePath)(n.importedFrom),{skipSelf:!0});if(!o||o.external)throw new f(`Failed to find '${r}' (from '${n.importedFrom}'), is the dependency installed correctly?`);let i=await(0,b.realpath)((0,S.dirname)(o.id));return y&&P(`Found package '${n.packageName}' at ${i}`),i}createI18nCache(){return new N({getId(t){return(0,w.normalizePath)(t)},async getValue(t,n){return y&&P(`Loading i18n file ${t}`),n.addWatchFile(t),{i18n:await he(t),watchFiles:new Set([t])}},onInvalidate(t){y&&P(`Removed cache entry for i18n file ${t}`)},onCachedReturn(t){y&&P(`Returning cached entry for i18n file ${t}`)}})}createPackageMetadataCache(){let t={_byName:new Map,getId(n){return(0,w.normalizePath)(n)},async getValue(n,r){y&&P(`Loading metadata for package at ${n}`);let o=new Set,i=[],a={resolve:r.resolve,addWatchFile(d){r.addWatchFile(d),o.add(d)},warn(d){i.push(typeof d=="string"?{message:d}:d)}},s=await ht(a,n);y&&P(`Metadata for '${s.name}': %O`,s);let p=this._byName.get(s.name);if(p&&(0,w.normalizePath)(p.directory)!==(0,w.normalizePath)(s.directory))throw new f(`Found package '${s.name}' at two different locations ${p.directory} and ${s.directory}`);return this._byName.set(s.name,s),{metadata:s,watchFiles:o,warnings:i}},onInvalidate(n,r){y&&P(`Removed cache entry for '${r.metadata.name}'`),this._byName.delete(r.metadata.name)},onCachedReturn(n,r){y&&P(`Returning cached metadata for '${r.metadata.name}'`)}};return new N(t)}};function ye(e,t){for(let n of e)t.addWatchFile(n)}async function ht(e,t){y&&P(`Visiting package directory ${t}.`);let n=(0,S.join)(t,"package.json");e.addWatchFile(n);let{name:r,dependencies:o}=await Et(e,n),i=(0,S.join)(t,q),a;if(e.addWatchFile((0,w.normalizePath)(i)),await D(i))try{a=await pe(i)}catch(g){let u=g.message||"Unknown error";throw new f(`Failed to load build config ${i}: ${u}`)}else throw new f(`Expected a ${q} in ${t}`);let s;if(a.services.length)try{s=await Pe(e,t,a.servicesModule??"./services")}catch(g){e.warn(`Failed to resolve entry point for package ${t}: ${g}`)}let p;if(a.styles){try{p=await Pe(e,t,a.styles)}catch(g){throw new f(`Failed to resolve css file for package ${t}: ${g}`)}if(!p)throw new f(`Failed to find css file '${a.styles}' in ${t}`)}let d=new Map;if(a.i18n)for(let g of a.i18n){if(d.has(g))throw new f(`Locale '${g}' was defined twice in ${i}`);let u=(0,S.join)(t,"i18n",`${g}.yaml`);if(e.addWatchFile(u),!await D(u))throw new f(`i18n file '${u}' does not exist.`);d.set(g,(0,w.normalizePath)(u))}return{name:r,directory:t,packageJsonPath:n,servicesModulePath:s,cssFilePath:p,i18nPaths:d,dependencies:o,config:a}}async function Et(e,t){if(!await D(t))throw new f(`Expected a 'package.json' file at ${t}`);let n;try{n=JSON.parse(await(0,b.readFile)(t,"utf-8"))}catch(a){throw new f(`Failed to read ${t}: ${a}`)}let r=n.name;if(typeof r!="string")throw new f(`Expected 'name' to be a string in ${t}`);let o=n.dependencies??{};if(typeof o!="object")throw new f(`Expected a valid 'dependencies' object in ${t}`);let i=Object.keys(o);return{name:r,dependencies:i}}async function Pe(e,t,n){let r=await e.resolve(`./${n}`,`${t}/package.json`,{skipSelf:!0});return r==null?void 0:r.id}function yt(e){switch(e.type){case"absolute":return`${e.directory}`;case"unresolved":return`'${e.packageName}' required by ${e.importedFrom}`}}var Pt=/[\\/]node_modules[\\/]/;function Mt(e,t){return oe(e,t)&&!Pt.test(e)}var Ct=/[\\/]package\.json($|\?)/;function vt(e){return Ct.test(e)}function Me(e){let t=n=>`@import ${JSON.stringify(n)};`;return e.filter(n=>!!n.cssFilePath).map(n=>t(n.cssFilePath)).join(`
39
- `)}var F=require("node:path/posix"),Ce=require("vite"),A="@@open-pioneer-app",kt="open-pioneer-app",Rt=/[?&]open-pioneer-app(?:$|&)/,wt="open-pioneer-packages",It=/[?&]open-pioneer-packages(?:$|&)/,xt="open-pioneer-styles",St=/[?&]open-pioneer-styles(?:$|&)/,_t="open-pioneer-i18n-index",At=/[?&]open-pioneer-i18n-index(?:$|&)/,$t="open-pioneer-i18n",Nt=/[?&]open-pioneer-i18n(?:$|&)/,bt=/[?&]locale=(?<locale>.*?)(?:$|&)/,ve="@@open-pioneer-react-hooks",Ft=/^(.*?)(?:\?|$)/;function H(e){let t=(0,Ce.normalizePath)(e);if(!t||t.includes("\\0"))return;let n=Lt(t);if(!n)return;let r=(0,F.basename)(n);if(r===ve)return{type:"package-hooks",packageDirectory:(0,F.dirname)(n)};if(r===A)return Ot(n,t)}function Ot(e,t){var r,o;let n=(0,F.dirname)(e);if(t.match(Rt))return{type:"app-meta",packageDirectory:n};if(t.match(It))return{type:"app-packages",packageDirectory:n};if(t.match(St))return{type:"app-css",packageDirectory:n};if(t.match(At))return{type:"app-i18n-index",packageDirectory:n};if(t.match(Nt)){let i="app-i18n",a=(o=(r=t.match(bt))==null?void 0:r.groups)==null?void 0:o.locale;if(!a)throw new Error("Missing locale name in i18n module request");return{type:i,packageDirectory:n,locale:a}}throw new Error(`Unexpected module id: ${t}`)}function C(e){switch(e.type){case"package-hooks":return`${e.packageDirectory}/${ve}`;case"app-meta":return`${e.packageDirectory}/${A}?${kt}`;case"app-packages":return`${e.packageDirectory}/${A}?${wt}`;case"app-css":return`${e.packageDirectory}/${A}?${xt}`;case"app-i18n-index":return`${e.packageDirectory}/${A}?${_t}`;case"app-i18n":return`${e.packageDirectory}/${A}?${$t}&locale=${e.locale}`}}function Lt(e){var n;let t=(n=e.match(Ft))==null?void 0:n[1];if(!(!t||e[0]=="\0"))return t}function ke(e,t){let n=C({type:"app-packages",packageDirectory:e}),r=C({type:"app-css",packageDirectory:e})+"&inline&lang.scss",o=C({type:"app-i18n-index",packageDirectory:e});return`
37
+ `);function ne(e){let t=new V,n=c.objectExpression([]),r=[];for(let o of e){let a=We(o,{importServiceClass(s,p,d){let l=t.generate(s),g=ze({SERVICE_NAME:c.identifier(p),IMPORT_NAME:c.identifier(l),IMPORT_SOURCE:c.stringLiteral(d)});return r.push(g),l}});n.properties.push(c.objectProperty(c.stringLiteral(o.name),a))}let i=c.program([...r,c.exportDefaultDeclaration(n)]);return(0,te.default)(i).code}function We(e,t){let n=c.objectExpression([]);for(let a of e.config.services){if(!e.servicesModulePath)throw new u(`Package '${e.name}' must have a valid services module (typically 'services.ts' or 'services.js').
38
+ The entry point can be configured by setting the 'servicesModule' property in the build.config.mjs.`);let s=t.importServiceClass(e.name+"_"+a.name,a.name,e.servicesModulePath),p=Te({SERVICE_NAME:c.stringLiteral(a.name),SERVICE_IMPORT:c.identifier(s),SERVICE_INTERFACES:c.arrayExpression(a.provides.map(d=>Je({INTERFACE_NAME:c.stringLiteral(d.name),QUALIFIER:d.qualifier==null?re():c.stringLiteral(d.qualifier)}))),SERVICE_REFERENCES:c.objectExpression(Object.entries(a.references).map(([d,l])=>c.objectProperty(c.stringLiteral(d),ee(l))))});n.properties.push(c.objectProperty(c.stringLiteral(a.name),p))}let r=Ke({UI_REFERENCES:c.arrayExpression(e.config.ui.references.map(a=>ee(a)))}),i=c.objectExpression(e.config.properties.map(a=>c.objectProperty(c.stringLiteral(a.name),Be({VALUE:K(a.defaultValue),REQUIRED:c.booleanLiteral(a.required)}))));return De({PACKAGE_NAME:c.stringLiteral(e.name),PACKAGE_SERVICES:n,PACKAGE_UI:r,PROPERTIES:i})}function K(e){if(e==null)return c.nullLiteral();if(typeof e=="string")return c.stringLiteral(e);if(typeof e=="number")return c.numericLiteral(e);if(typeof e=="boolean")return c.booleanLiteral(e);if(Array.isArray(e))return c.arrayExpression(e.map(t=>K(t)));if(typeof e=="object")return c.objectExpression(Object.entries(e).map(([t,n])=>c.objectProperty(c.stringLiteral(t),K(n))));throw new Error(`Unexpected value while serializing JSON: ${e}.`)}function ee(e){return Ge({INTERFACE_NAME:c.stringLiteral(e.name),QUALIFIER:e.qualifier?c.stringLiteral(e.qualifier):re(),ALL:c.booleanLiteral(e.all??!1)})}function re(){return c.unaryExpression("void",c.numericLiteral(0))}var N=require("fs/promises"),I=require("path"),R=require("vite");var U=w(require("node:fs")),z=require("node:path");function D(e){return U.promises.access(e,U.constants.F_OK).then(()=>!0).catch(()=>!1)}function ae(e,t){let n=(0,z.relative)(t,e);return!!(n&&!n.startsWith("..")&&!(0,z.isAbsolute)(n))}var $=class{values=new Map;jobs=new Map;provider;constructor(t){this.provider=t}invalidate(t){var i,o;let n=this.provider.getId(t),r=this.values.get(n);this.values.delete(n),this.jobs.delete(n),r&&((o=(i=this.provider).onInvalidate)==null||o.call(i,t,r))}async get(t,...n){var l;let r=this.provider,i=r.getId(t),o=this.values,a=o.get(i);if(a)return(l=r.onCachedReturn)==null||l.call(r,t,a),Promise.resolve(a);let s=this.jobs,p=s.get(i);if(p)return p;let d=r.getValue(t,...n);s.set(i,d);try{let g=await d;return s.get(i)===d&&o.set(i,g),g}finally{s.get(i)===d&&s.delete(i)}}};var ie=require("node:url"),T=require("@open-pioneer/build-common"),oe=require("node:path"),qe=0;async function se(e){let n=await import(`${(0,ie.pathToFileURL)(e)}?id=${++qe}`);if(!n||!n.default)throw new Error("The module must contain a default export.");let r=n.default;return Qe(r)}function Qe(e){let t=(0,T.verifyBuildConfig)(e);return Ye(t)}function ce(e){return(0,oe.basename)(e)===T.BUILD_CONFIG_NAME}function Ye(e){return{styles:e.styles,i18n:e.i18n,services:Object.entries(e.services??{}).map(([t,n])=>He(t,n)),servicesModule:e.servicesModule,ui:et(e.ui),properties:tt(e.properties,e.propertiesMeta)}}function He(e,t){return{name:e,provides:Ze(t.provides),references:Xe(t.references)}}function Ze(e){return e?typeof e=="string"?[{name:e}]:e.map(t=>typeof t=="string"?{name:t}:t):[]}function Xe(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,de(n)])):{}}function de(e){return typeof e=="string"?{name:e}:e}function et(e){var t;return{references:((t=e==null?void 0:e.references)==null?void 0:t.map(de))??[]}}function tt(e,t){var r;let n=[];for(let[i,o]of Object.entries(e??{})){let a=((r=t==null?void 0:t[i])==null?void 0:r.required)??!1;n.push({name:i,defaultValue:o,required:a})}return n}var pe=require("fs/promises"),le=require("js-yaml"),x=require("zod"),ge=require("zod-validation-error");var B=x.z.lazy(()=>x.z.record(x.z.union([x.z.string(),B])).nullish()),nt=x.z.strictObject({messages:B.nullish().optional(),overrides:x.z.record(B).nullish().optional()}).nullish();async function ue(e){let t;try{t=await(0,pe.readFile)(e,"utf-8")}catch(n){throw new u(`Failed to read ${e}: ${n}`)}try{return rt(t)}catch(n){throw new u(`Failed to parse ${e}: ${n}`)}}function rt(e){let t=(0,le.load)(e);return at(t)}function at(e){let t=nt.safeParse(e);if(!t.success)throw(0,ge.fromZodError)(t.error);let n=t.data;return{messages:fe((n==null?void 0:n.messages)??void 0),overrides:it((n==null?void 0:n.overrides)??void 0)}}function fe(e){let t=new Map,n=[],r=o=>{for(let[a,s]of Object.entries(o))typeof s=="string"?i(a,s):s&&(n.push(a),r(s),n.pop())},i=(o,a)=>{let s=[...n,o].join(".");if(t.has(s))throw new Error(`Message '${s}' was already defined.`);t.set(s,a)};return e&&r(e),t}function it(e){let t=new Map;if(e)for(let[n,r]of Object.entries(e)){let i=fe(r??void 0);t.set(n,i)}return t}var W=require("@open-pioneer/build-common"),y=!!process.env.DEBUG,E=j("open-pioneer:metadata"),J=class{sourceRoot;packageMetadataCache;i18nCache;constructor(t){this.sourceRoot=t,this.packageMetadataCache=this.createPackageMetadataCache(),this.i18nCache=this.createI18nCache()}reset(){this.packageMetadataCache=this.createPackageMetadataCache(),this.i18nCache=this.createI18nCache()}onFileChanged(t){(gt(t)||ce(t))&&this.packageMetadataCache.invalidate((0,I.dirname)(t)),this.i18nCache.invalidate(t)}async getAppMetadata(t,n){y&&E(`Request for app metadata of ${n}`);let r=await this.getPackageMetadata(t,{type:"absolute",directory:n});if(!r)throw new u(`Failed to parse app metadata in ${n}. Ensure that the app is a valid local package.`);let i=Array.from(r.i18nPaths.keys()),o=new Map;o.set(r.name,r);let a=async(p,d)=>{let l=p.map(async g=>{let f=await this.getPackageMetadata(t,{type:"unresolved",packageName:g,importedFrom:d});f&&(o.has(f.name)||o.set(f.name,f),await a(f.dependencies,f.packageJsonPath))});return await Promise.all(l)};return await a(r.dependencies,r.packageJsonPath),{name:r.name,directory:r.directory,locales:i,packageJsonPath:r.packageJsonPath,packages:Array.from(o.values())}}async getPackageMetadata(t,n){y&&E(`Request for package metadata of ${ct(n)}`);let r=await this.resolvePackageLocation(t,n);if(!pt(r,this.sourceRoot)){y&&E(`Skipping non-local package '${r}'.`);return}let i=await this.packageMetadataCache.get(r,t);me(i.watchFiles,t);for(let o of i.warnings)t.warn(o);return i.metadata}async getI18nFile(t,n){let{i18n:r,watchFiles:i}=await this.i18nCache.get(n,t);return me(i,t),r}async resolvePackageLocation(t,n){if(n.type==="absolute")return await(0,N.realpath)(n.directory);let r=`${n.packageName}/package.json`,i=await t.resolve(r,(0,R.normalizePath)(n.importedFrom),{skipSelf:!0});if(!i||i.external)throw new u(`Failed to find '${r}' (from '${n.importedFrom}'), is the dependency installed correctly?`);let o=await(0,N.realpath)((0,I.dirname)(i.id));return y&&E(`Found package '${n.packageName}' at ${o}`),o}createI18nCache(){return new $({getId(t){return(0,R.normalizePath)(t)},async getValue(t,n){return y&&E(`Loading i18n file ${t}`),n.addWatchFile(t),{i18n:await ue(t),watchFiles:new Set([t])}},onInvalidate(t){y&&E(`Removed cache entry for i18n file ${t}`)},onCachedReturn(t){y&&E(`Returning cached entry for i18n file ${t}`)}})}createPackageMetadataCache(){let t={_byName:new Map,getId(n){return(0,R.normalizePath)(n)},async getValue(n,r){y&&E(`Loading metadata for package at ${n}`);let i=new Set,o=[],a={resolve:r.resolve,addWatchFile(d){r.addWatchFile(d),i.add(d)},warn(d){o.push(typeof d=="string"?{message:d}:d)}},s=await ot(a,n);y&&E(`Metadata for '${s.name}': %O`,s);let p=this._byName.get(s.name);if(p&&(0,R.normalizePath)(p.directory)!==(0,R.normalizePath)(s.directory))throw new u(`Found package '${s.name}' at two different locations ${p.directory} and ${s.directory}`);return this._byName.set(s.name,s),{metadata:s,watchFiles:i,warnings:o}},onInvalidate(n,r){y&&E(`Removed cache entry for '${r.metadata.name}'`),this._byName.delete(r.metadata.name)},onCachedReturn(n,r){y&&E(`Returning cached metadata for '${r.metadata.name}'`)}};return new $(t)}};function me(e,t){for(let n of e)t.addWatchFile(n)}async function ot(e,t){y&&E(`Visiting package directory ${t}.`);let n=(0,I.join)(t,"package.json");e.addWatchFile(n);let{name:r,dependencies:i}=await st(e,n),o=(0,I.join)(t,W.BUILD_CONFIG_NAME),a;if(e.addWatchFile((0,R.normalizePath)(o)),await D(o))try{a=await se(o)}catch(l){let g=l.message||"Unknown error";throw new u(`Failed to load build config ${o}: ${g}`)}else throw new u(`Expected a ${W.BUILD_CONFIG_NAME} in ${t}`);let s;if(a.services.length)try{s=await he(e,t,a.servicesModule??"./services")}catch(l){e.warn(`Failed to resolve entry point for package ${t}: ${l}`)}let p;if(a.styles){try{p=await he(e,t,a.styles)}catch(l){throw new u(`Failed to resolve css file for package ${t}: ${l}`)}if(!p)throw new u(`Failed to find css file '${a.styles}' in ${t}`)}let d=new Map;if(a.i18n)for(let l of a.i18n){if(d.has(l))throw new u(`Locale '${l}' was defined twice in ${o}`);let g=(0,I.join)(t,"i18n",`${l}.yaml`);if(e.addWatchFile(g),!await D(g))throw new u(`i18n file '${g}' does not exist.`);d.set(l,(0,R.normalizePath)(g))}return{name:r,directory:t,packageJsonPath:n,servicesModulePath:s,cssFilePath:p,i18nPaths:d,dependencies:i,config:a}}async function st(e,t){if(!await D(t))throw new u(`Expected a 'package.json' file at ${t}`);let n;try{n=JSON.parse(await(0,N.readFile)(t,"utf-8"))}catch(a){throw new u(`Failed to read ${t}: ${a}`)}let r=n.name;if(typeof r!="string")throw new u(`Expected 'name' to be a string in ${t}`);let i=n.dependencies??{};if(typeof i!="object")throw new u(`Expected a valid 'dependencies' object in ${t}`);let o=Object.keys(i);return{name:r,dependencies:o}}async function he(e,t,n){let r=await e.resolve(`./${n}`,`${t}/package.json`,{skipSelf:!0});return r==null?void 0:r.id}function ct(e){switch(e.type){case"absolute":return`${e.directory}`;case"unresolved":return`'${e.packageName}' required by ${e.importedFrom}`}}var dt=/[\\/]node_modules[\\/]/;function pt(e,t){return ae(e,t)&&!dt.test(e)}var lt=/[\\/]package\.json($|\?)/;function gt(e){return lt.test(e)}function ye(e){let t=n=>`@import ${JSON.stringify(n)};`;return e.filter(n=>!!n.cssFilePath).map(n=>t(n.cssFilePath)).join(`
39
+ `)}var F=require("node:path/posix"),Ee=require("vite"),S="@@open-pioneer-app",ut="open-pioneer-app",ft=/[?&]open-pioneer-app(?:$|&)/,mt="open-pioneer-packages",ht=/[?&]open-pioneer-packages(?:$|&)/,yt="open-pioneer-styles",Et=/[?&]open-pioneer-styles(?:$|&)/,Pt="open-pioneer-i18n-index",Mt=/[?&]open-pioneer-i18n-index(?:$|&)/,kt="open-pioneer-i18n",Ct=/[?&]open-pioneer-i18n(?:$|&)/,vt=/[?&]locale=(?<locale>.*?)(?:$|&)/,Pe="@@open-pioneer-react-hooks",Rt=/^(.*?)(?:\?|$)/;function q(e){let t=(0,Ee.normalizePath)(e);if(!t||t.includes("\\0"))return;let n=xt(t);if(!n)return;let r=(0,F.basename)(n);if(r===Pe)return{type:"package-hooks",packageDirectory:(0,F.dirname)(n)};if(r===S)return wt(n,t)}function wt(e,t){var r,i;let n=(0,F.dirname)(e);if(t.match(ft))return{type:"app-meta",packageDirectory:n};if(t.match(ht))return{type:"app-packages",packageDirectory:n};if(t.match(Et))return{type:"app-css",packageDirectory:n};if(t.match(Mt))return{type:"app-i18n-index",packageDirectory:n};if(t.match(Ct)){let o="app-i18n",a=(i=(r=t.match(vt))==null?void 0:r.groups)==null?void 0:i.locale;if(!a)throw new Error("Missing locale name in i18n module request");return{type:o,packageDirectory:n,locale:a}}throw new Error(`Unexpected module id: ${t}`)}function M(e){switch(e.type){case"package-hooks":return`${e.packageDirectory}/${Pe}`;case"app-meta":return`${e.packageDirectory}/${S}?${ut}`;case"app-packages":return`${e.packageDirectory}/${S}?${mt}`;case"app-css":return`${e.packageDirectory}/${S}?${yt}`;case"app-i18n-index":return`${e.packageDirectory}/${S}?${Pt}`;case"app-i18n":return`${e.packageDirectory}/${S}?${kt}&locale=${e.locale}`}}function xt(e){var n;let t=(n=e.match(Rt))==null?void 0:n[1];if(!(!t||e[0]=="\0"))return t}function Me(e,t){let n=M({type:"app-packages",packageDirectory:e}),r=M({type:"app-css",packageDirectory:e})+"&inline&lang.scss",i=M({type:"app-i18n-index",packageDirectory:e});return`
40
40
  import { createBox } from ${JSON.stringify(t)};
41
41
  import packages from ${JSON.stringify(n)};
42
42
  import stylesString from ${JSON.stringify(r)};
43
- import { locales, loadMessages } from ${JSON.stringify(o)};
43
+ import { locales, loadMessages } from ${JSON.stringify(i)};
44
44
 
45
45
  const styles = createBox(stylesString);
46
46
  if (import.meta.hot) {
@@ -62,7 +62,7 @@ export {
62
62
  locales,
63
63
  loadMessages
64
64
  };
65
- `.trim()}var _e=require("node:fs/promises");function Re(e,t){return`
65
+ `.trim()}var xe=require("node:fs/promises");function ke(e,t){return`
66
66
  import { useServiceInternal, useServicesInternal, usePropertiesInternal, useIntlInternal } from ${JSON.stringify(t)};
67
67
 
68
68
  const PACKAGE_NAME = ${JSON.stringify(e)};
@@ -70,17 +70,17 @@ export const useService = /*@__PURE__*/ useServiceInternal.bind(undefined, PACKA
70
70
  export const useServices = /*@__PURE__*/ useServicesInternal.bind(undefined, PACKAGE_NAME);
71
71
  export const useProperties = /*@__PURE__*/ usePropertiesInternal.bind(undefined, PACKAGE_NAME);
72
72
  export const useIntl = /*@__PURE__*/ useIntlInternal.bind(undefined, PACKAGE_NAME);
73
- `.trim()}var E=I(require("@babel/types")),G=I(require("@babel/template"));var Z=I(require("@babel/generator"));var jt=G.default.program(`
73
+ `.trim()}var h=w(require("@babel/types")),G=w(require("@babel/template"));var Q=w(require("@babel/generator"));var It=G.default.program(`
74
74
  export const locales = %%LOCALES_ARRAY%%;
75
75
 
76
76
  export function loadMessages(locale) {
77
77
  %%LOCALE_SWITCH%%
78
78
  throw new Error(\`Unsupported locale: '\${locale}'\`);
79
79
  }
80
- `),zt=G.default.statement(`
80
+ `),At=G.default.statement(`
81
81
  return import(%%MODULE_ID%%).then(mod => mod.default);
82
- `),Vt=G.default.program(`
82
+ `),St=G.default.program(`
83
83
  const messages = JSON.parse(%%SERIALIZED%%);
84
84
  export default messages;
85
- `);function we(e,t){let n=E.arrayExpression(t.map(i=>E.stringLiteral(i))),r=E.switchStatement(E.identifier("locale"),t.map(i=>{let a=C({type:"app-i18n",packageDirectory:e,locale:i}),s=zt({MODULE_ID:E.stringLiteral(a)});return E.switchCase(E.stringLiteral(i),[s])})),o=jt({LOCALES_ARRAY:n,LOCALE_SWITCH:r});return(0,Z.default)(o).code}async function Ie(e){let{locale:t,appName:n,packages:r,loadI18n:o}=e,i=new Map,a=new Set,s;for(let u of r){u.i18nPaths.size!==0&&a.add(u.name);let m=u.i18nPaths.get(t);if(!m)continue;let{messages:h,overrides:M}=await o(m);if(u.name===n)s=M;else if(M.size!==0)throw new f(`Unexpected 'overrides' block in '${m}'. Overrides are only supported in the app.`);i.set(u.name,h)}if(s)for(let[u,m]of s.entries()){let h=i.get(u);if(!h){i.set(u,m);continue}let M=new Map([...h,...m]);i.set(u,M)}for(let u of a)if(!i.get(u))throw new f(`Package '${u}' requires messages for locale '${t}'. Either update the package or add messages from the app via 'overrides'.`);let p={};for(let[u,m]of i.entries())p[u]=Object.fromEntries(m.entries());let d=JSON.stringify(p),g=Vt({SERIALIZED:E.stringLiteral(d)});return(0,Z.default)(g).code}var v=!!process.env.DEBUG,k=z("open-pioneer:codegen");function Ae(){let e=new Map,t,n,r,o,i;return{name:"pioneer:codegen",async buildStart(){e.clear(),n==null||n.reset();let a=async s=>{let p=await this.resolve(s,__filename);return p||this.error(`Failed to find '${s}'.`),p.id};o=await a("@open-pioneer/runtime/react-integration"),i=await a("@open-pioneer/runtime/metadata")},configResolved(a){t=a,n=new J(t.root)},configureServer(a){r=a,a.watcher.on("all",(s,p)=>{let d=e.get((0,$.normalizePath)(p));if(d){v&&k(`File changed: ${p}`),n.onFileChanged(p);for(let g of d){let u=a.moduleGraph.getModuleById(g);u&&(v&&k(`Triggering hmr of ${g}`),a.reloadModule(u).catch(m=>{t.logger.error(`Failed to trigger hmr: ${m}`)}))}}})},async resolveId(a,s){try{if(!s)return;if(H(a))return a;let p=()=>{let d=Dt((0,_.dirname)(s),t.root);if(!d)throw new f(`Failed to find package.json for package from '${s}'.`);let g=(0,_.dirname)(d);return(0,$.normalizePath)(g)};if(a==="open-pioneer:app")return C({type:"app-meta",packageDirectory:p()});if(a==="open-pioneer:react-hooks")return C({type:"package-hooks",packageDirectory:p()})}catch(p){xe(this,p)}},async load(a){var s,p;try{let d=H(a);if(!d)return;v&&k("Loading virtual module %O",d);let g=(s=await this.resolve(d.packageDirectory+"/package.json"))==null?void 0:s.id;if(!g)throw new f(`Failed to resolve package.json in ${d.packageDirectory}`);if(d.type==="package-hooks"){let h=d.packageDirectory,M=(p=await this.resolve(h+"/package.json"))==null?void 0:p.id;if(!M)throw new f(`Failed to resolve package.json in ${h}`);let Fe=await Jt(this,M),Q=Re(Fe,o);return v&&k("Generated hooks code: %O",Q),Q}if(d.type==="app-meta")return ke(d.packageDirectory,i);let u=Ut(this,a,r,e),m=await n.getAppMetadata(u,(0,_.dirname)(g));switch(d.type){case"app-packages":{let h=re(m.packages);return v&&k("Generated app metadata: %O",h),h}case"app-css":{let h=Me(m.packages);return v&&k("Generated app css: %O",h),h}case"app-i18n-index":{let h=we(d.packageDirectory,m.locales);return v&&k("Generated i18n lookup: %O",h),h}case"app-i18n":{let h=await Ie({locale:d.locale,appName:m.name,packages:m.packages,loadI18n(M){return n.getI18nFile(u,M)}});return v&&k("Generated i18n messages: %O",h),h}}}catch(d){xe(this,d)}}}}function Ut(e,t,n,r){return{warn:e.warn,resolve:e.resolve,addWatchFile:o=>{n&&(v&&k(`Adding manual watch for ${o}`),n.watcher.add(o),Tt(r,o,t)),e.addWatchFile(o)}}}function xe(e,t){t instanceof f&&e.error(t);let n=String(t.message)||"Unknown error";e.error("Internal error: "+n)}function Tt(e,t,n){let r=(0,$.normalizePath)(t),o=e.get(r);o||(o=new Set,e.set(r,o)),o.add(n)}function Dt(e,t){let n=e;for(;n;){let r=(0,_.join)(n,"package.json");if((0,Se.existsSync)(r))return r;if((0,$.normalizePath)(n)==(0,$.normalizePath)(t))return;let o=(0,_.dirname)(n);n=o===n||o==="."?"":o}}async function Jt(e,t){let n;try{let r=await(0,_e.readFile)(t,"utf-8");n=JSON.parse(r).name}catch(r){throw new f(`Failed to read package.json file: ${r}`)}if(!n)throw new f(`Failed to read package name from ${t}.`);return n}var L=require("node:fs"),O=require("node:path"),Y=require("node:path"),Ne=require("node:process");function be(e){let t=(e==null?void 0:e.rootSite)??!1,n=(e==null?void 0:e.apps)||[],r=(e==null?void 0:e.sites)||[],o;return{name:"pioneer:mpa",config(i){let a=i.root??(0,Ne.cwd)(),{entryPoints:s,appNames:p}=Gt({apps:n,sites:r,rootSite:t,sourceRoot:a});return{build:{rollupOptions:{input:s,output:{entryFileNames(g){return p.includes(g.name)?"[name].js":Y.posix.join(o.build.assetsDir,"[hash:12].js")},chunkFileNames(g){return Y.posix.join(o.build.assetsDir,"[hash:12].js")}}}}}},configResolved(i){o=i}}}function Gt(e){let t;Array.isArray(e.apps)?t=e.apps.map(a=>{let s=(0,O.resolve)(e.sourceRoot,"apps",a,"app"),p=Bt(a,s);return{name:a,path:p}}):t=Object.entries(e.apps).map(([a,s])=>{let p=(0,O.resolve)(e.sourceRoot,s);if(!(0,L.existsSync)(p))throw new Error(`Failed to find app '${a}' at ${p}. Ensure that the path is spelled correctly.`);return{name:a,path:p}});let n=e.sites.map(a=>{let s=(0,O.resolve)(e.sourceRoot,a,"index.html");if(!(0,L.existsSync)(s))throw new Error(`Failed to find site at ${s}. Ensure that the site name in your vite configuration is spelled correctly.`);return{name:a,path:s}});if(e.rootSite){let a=(0,O.resolve)(e.sourceRoot,"index.html");if(!(0,L.existsSync)(a))throw new Error(`Failed to find root site at ${a}. Create the missing file or set 'rootSite' to false.`);n.push({name:"index",path:a})}let r={},o=0;for(let{name:a,path:s}of[t,n].flat()){let p=r[a];if(p)throw new Error(`Entry point '${a}' was defined twice (paths ${p} and ${s}). Remove the duplicated entry.`);r[a]=s,++o}if(o===0)throw new Error("You must configure at least one site or one app in the pioneer plugin options.");let i=t.map(({name:a})=>a);return{entryPoints:r,appNames:i}}var $e=[".ts",".tsx",".js",".jsx"];function Bt(e,t){for(let r of $e){let o=t+r;if((0,L.existsSync)(o))return o}let n=$e.join(", ");throw new Error(`Failed to find a matching entry point file for app '${e}' at ${t}. Supported extensions are ${n}. Ensure that the app name is spelled correctly or create the missing file.`)}function Kt(e){return[be(e),Ae()]}0&&(module.exports={pioneer});
85
+ `);function Ce(e,t){let n=h.arrayExpression(t.map(o=>h.stringLiteral(o))),r=h.switchStatement(h.identifier("locale"),t.map(o=>{let a=M({type:"app-i18n",packageDirectory:e,locale:o}),s=At({MODULE_ID:h.stringLiteral(a)});return h.switchCase(h.stringLiteral(o),[s])})),i=It({LOCALES_ARRAY:n,LOCALE_SWITCH:r});return(0,Q.default)(i).code}async function ve(e){let{locale:t,appName:n,packages:r,loadI18n:i}=e,o=new Map,a=new Set,s;for(let g of r){g.i18nPaths.size!==0&&a.add(g.name);let f=g.i18nPaths.get(t);if(!f)continue;let{messages:m,overrides:P}=await i(f);if(g.name===n)s=P;else if(P.size!==0)throw new u(`Unexpected 'overrides' block in '${f}'. Overrides are only supported in the app.`);o.set(g.name,m)}if(s)for(let[g,f]of s.entries()){let m=o.get(g);if(!m){o.set(g,f);continue}let P=new Map([...m,...f]);o.set(g,P)}for(let g of a)if(!o.get(g))throw new u(`Package '${g}' requires messages for locale '${t}'. Either update the package or add messages from the app via 'overrides'.`);let p={};for(let[g,f]of o.entries())p[g]=Object.fromEntries(f.entries());let d=JSON.stringify(p),l=St({SERIALIZED:h.stringLiteral(d)});return(0,Q.default)(l).code}var k=!!process.env.DEBUG,C=j("open-pioneer:codegen");function Ie(){let e=new Map,t,n,r,i,o;return{name:"pioneer:codegen",async buildStart(){e.clear(),n==null||n.reset();let a=async s=>{let p=await this.resolve(s,__filename);return p||this.error(`Failed to find '${s}'.`),p.id};i=await a("@open-pioneer/runtime/react-integration"),o=await a("@open-pioneer/runtime/metadata")},configResolved(a){t=a,n=new J(t.root)},configureServer(a){r=a,a.watcher.on("all",(s,p)=>{let d=e.get((0,_.normalizePath)(p));if(d){k&&C(`File changed: ${p}`),n.onFileChanged(p);for(let l of d){let g=a.moduleGraph.getModuleById(l);g&&(k&&C(`Triggering hmr of ${l}`),a.reloadModule(g).catch(f=>{t.logger.error(`Failed to trigger hmr: ${f}`)}))}}})},async resolveId(a,s){try{if(!s)return;if(q(a))return a;let p=()=>{let d=Nt((0,A.dirname)(s),t.root);if(!d)throw new u(`Failed to find package.json for package from '${s}'.`);let l=(0,A.dirname)(d);return(0,_.normalizePath)(l)};if(a==="open-pioneer:app")return M({type:"app-meta",packageDirectory:p()});if(a==="open-pioneer:react-hooks")return M({type:"package-hooks",packageDirectory:p()})}catch(p){Re(this,p)}},async load(a){var s,p;try{let d=q(a);if(!d)return;k&&C("Loading virtual module %O",d);let l=(s=await this.resolve(d.packageDirectory+"/package.json"))==null?void 0:s.id;if(!l)throw new u(`Failed to resolve package.json in ${d.packageDirectory}`);if(d.type==="package-hooks"){let m=d.packageDirectory,P=(p=await this.resolve(m+"/package.json"))==null?void 0:p.id;if(!P)throw new u(`Failed to resolve package.json in ${m}`);let $e=await Ft(this,P),H=ke($e,i);return k&&C("Generated hooks code: %O",H),H}if(d.type==="app-meta")return Me(d.packageDirectory,o);let g=_t(this,a,r,e),f=await n.getAppMetadata(g,(0,A.dirname)(l));switch(d.type){case"app-packages":{let m=ne(f.packages);return k&&C("Generated app metadata: %O",m),m}case"app-css":{let m=ye(f.packages);return k&&C("Generated app css: %O",m),m}case"app-i18n-index":{let m=Ce(d.packageDirectory,f.locales);return k&&C("Generated i18n lookup: %O",m),m}case"app-i18n":{let m=await ve({locale:d.locale,appName:f.name,packages:f.packages,loadI18n(P){return n.getI18nFile(g,P)}});return k&&C("Generated i18n messages: %O",m),m}}}catch(d){Re(this,d)}}}}function _t(e,t,n,r){return{warn:e.warn,resolve:e.resolve,addWatchFile:i=>{n&&(k&&C(`Adding manual watch for ${i}`),n.watcher.add(i),$t(r,i,t)),e.addWatchFile(i)}}}function Re(e,t){t instanceof u&&e.error(t);let n=String(t.message)||"Unknown error";e.error("Internal error: "+n)}function $t(e,t,n){let r=(0,_.normalizePath)(t),i=e.get(r);i||(i=new Set,e.set(r,i)),i.add(n)}function Nt(e,t){let n=e;for(;n;){let r=(0,A.join)(n,"package.json");if((0,we.existsSync)(r))return r;if((0,_.normalizePath)(n)==(0,_.normalizePath)(t))return;let i=(0,A.dirname)(n);n=i===n||i==="."?"":i}}async function Ft(e,t){let n;try{let r=await(0,xe.readFile)(t,"utf-8");n=JSON.parse(r).name}catch(r){throw new u(`Failed to read package.json file: ${r}`)}if(!n)throw new u(`Failed to read package name from ${t}.`);return n}var O=require("node:fs"),b=require("node:path"),Y=require("node:path"),Se=require("node:process");function _e(e){let t=(e==null?void 0:e.rootSite)??!1,n=(e==null?void 0:e.apps)||[],r=(e==null?void 0:e.sites)||[],i;return{name:"pioneer:mpa",config(o){let a=o.root??(0,Se.cwd)(),{entryPoints:s,appNames:p}=bt({apps:n,sites:r,rootSite:t,sourceRoot:a});return{build:{rollupOptions:{input:s,output:{entryFileNames(l){return p.includes(l.name)?"[name].js":Y.posix.join(i.build.assetsDir,"[hash:12].js")},chunkFileNames(l){return Y.posix.join(i.build.assetsDir,"[hash:12].js")}}}}}},configResolved(o){i=o}}}function bt(e){let t;Array.isArray(e.apps)?t=e.apps.map(a=>{let s=(0,b.resolve)(e.sourceRoot,"apps",a,"app"),p=Ot(a,s);return{name:a,path:p}}):t=Object.entries(e.apps).map(([a,s])=>{let p=(0,b.resolve)(e.sourceRoot,s);if(!(0,O.existsSync)(p))throw new Error(`Failed to find app '${a}' at ${p}. Ensure that the path is spelled correctly.`);return{name:a,path:p}});let n=e.sites.map(a=>{let s=(0,b.resolve)(e.sourceRoot,a,"index.html");if(!(0,O.existsSync)(s))throw new Error(`Failed to find site at ${s}. Ensure that the site name in your vite configuration is spelled correctly.`);return{name:a,path:s}});if(e.rootSite){let a=(0,b.resolve)(e.sourceRoot,"index.html");if(!(0,O.existsSync)(a))throw new Error(`Failed to find root site at ${a}. Create the missing file or set 'rootSite' to false.`);n.push({name:"index",path:a})}let r={},i=0;for(let{name:a,path:s}of[t,n].flat()){let p=r[a];if(p)throw new Error(`Entry point '${a}' was defined twice (paths ${p} and ${s}). Remove the duplicated entry.`);r[a]=s,++i}if(i===0)throw new Error("You must configure at least one site or one app in the pioneer plugin options.");let o=t.map(({name:a})=>a);return{entryPoints:r,appNames:o}}var Ae=[".ts",".tsx",".js",".jsx"];function Ot(e,t){for(let r of Ae){let i=t+r;if((0,O.existsSync)(i))return i}let n=Ae.join(", ");throw new Error(`Failed to find a matching entry point file for app '${e}' at ${t}. Supported extensions are ${n}. Ensure that the app name is spelled correctly or create the missing file.`)}function Lt(e){return[_e(e),Ie()]}0&&(module.exports={pioneer});
86
86
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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/BuildConfigSchema.ts", "../src/metadata/parseI18nYaml.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: ${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(appMetadata.packages);\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(\"Internal error: \" + message);\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: ${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 { ReferenceConfig } from \"@open-pioneer/build-support\";\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\nimport { ReportableError } from \"../ReportableError\";\nimport { IdGenerator } from \"./IdGenerator\";\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\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(packages: PackageMetadataInput[]): string {\n const idGenerator = new IdGenerator();\n const packagesMetadata = nodes.objectExpression([]);\n const imports: nodes.Statement[] = [];\n for (const pkg of packages) {\n const packageMetadata = generatePackageMetadata(pkg, {\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): nodes.Expression {\n const servicesObject = nodes.objectExpression([]);\n for (const service of pkg.config.services) {\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.name,\n service.name,\n pkg.servicesModulePath\n );\n const serviceObject = SERVICE_OBJECT({\n SERVICE_NAME: nodes.stringLiteral(service.name),\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.name),\n QUALIFIER:\n p.qualifier == null ? undefinedNode() : nodes.stringLiteral(p.qualifier)\n })\n )\n ),\n SERVICE_REFERENCES: nodes.objectExpression(\n Object.entries(service.references).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.name), serviceObject)\n );\n }\n\n const uiObject = UI_OBJECT({\n UI_REFERENCES: nodes.arrayExpression(\n pkg.config.ui.references.map((r) => referenceObject(r))\n )\n });\n\n const propertiesObject = nodes.objectExpression(\n pkg.config.properties.map((prop) =>\n nodes.objectProperty(\n nodes.stringLiteral(prop.name),\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(referenceConfig: ReferenceConfig): nodes.Expression {\n return REFERENCE_OBJECT({\n INTERFACE_NAME: nodes.stringLiteral(referenceConfig.name),\n QUALIFIER: referenceConfig.qualifier\n ? nodes.stringLiteral(referenceConfig.qualifier)\n : undefinedNode(),\n ALL: nodes.booleanLiteral(referenceConfig.all ?? false)\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 { normalizePath } from \"vite\";\nimport { ReportableError } from \"../ReportableError\";\nimport { createDebugger } from \"../utils/debug\";\nimport { fileExists, isInDirectory } from \"../utils/fileUtils\";\nimport { Cache } from \"../utils/Cache\";\nimport {\n BUILD_CONFIG_NAME,\n isBuildConfig,\n loadBuildConfig,\n NormalizedPackageConfig\n} from \"./parseBuildConfig\";\nimport { I18nFile, loadI18nFile } from \"./parseI18nYaml\";\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 /** 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: string[];\n\n /** Parsed metadata (from build config file). */\n config: NormalizedPackageConfig;\n}\n\nexport type MetadataContext = Pick<PluginContext, \"addWatchFile\" | \"resolve\" | \"warn\">;\n\nexport interface ResolvedPackageLocation {\n type: \"absolute\";\n directory: string;\n}\n\nexport interface UnresolvedPackageLocation {\n type: \"unresolved\";\n packageName: string;\n importedFrom: string;\n}\n\nexport type PackageLocation = ResolvedPackageLocation | UnresolvedPackageLocation;\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: PackageMetadata;\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 /**\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 }\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 (dependencies: string[], importedFrom: string) => {\n const jobs = dependencies.map(async (packageName) => {\n const packageMetadata = await this.getPackageMetadata(ctx, {\n type: \"unresolved\",\n packageName,\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 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(ctx, loc);\n\n // This would have to be changed when packages from the 'outside' are also supported in the future.\n if (!isLocalPackage(packageDir, this.sourceRoot)) {\n isDebug && debug(`Skipping non-local package '${packageDir}'.`);\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 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(ctx: MetadataContext, loc: PackageLocation) {\n if (loc.type === \"absolute\") {\n return await realpath(loc.directory);\n }\n\n // Try to locate the package via rollup resolve.\n const unresolvedPackageJson = `${loc.packageName}/package.json`;\n const packageJsonLocation = await ctx.resolve(\n unresolvedPackageJson,\n normalizePath(loc.importedFrom),\n {\n skipSelf: true\n }\n );\n if (!packageJsonLocation || packageJsonLocation.external) {\n throw new ReportableError(\n `Failed to find '${unresolvedPackageJson}' (from '${loc.importedFrom}'), is the dependency installed correctly?`\n );\n }\n\n const packageDir = await realpath(dirname(packageJsonLocation.id));\n isDebug && debug(`Found package '${loc.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 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 const metadata = await parsePackageMetadata(trackingCtx, directory);\n isDebug && debug(`Metadata for '${metadata.name}': %O`, metadata);\n\n // Ensure only one version of a package exists in the app\n const existingMetadata = this._byName.get(metadata.name);\n if (\n existingMetadata &&\n normalizePath(existingMetadata.directory) !== 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 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\nexport async function parsePackageMetadata(\n ctx: MetadataContext,\n packageDir: string\n): Promise<PackageMetadata> {\n isDebug && debug(`Visiting package directory ${packageDir}.`);\n\n const packageJsonPath = join(packageDir, \"package.json\");\n\n ctx.addWatchFile(packageJsonPath);\n const { name: packageName, dependencies } = await parsePackageJson(ctx, packageJsonPath);\n\n const buildConfigPath = join(packageDir, BUILD_CONFIG_NAME);\n let buildConfig: NormalizedPackageConfig | undefined;\n ctx.addWatchFile(normalizePath(buildConfigPath));\n if (await fileExists(buildConfigPath)) {\n try {\n buildConfig = await loadBuildConfig(buildConfigPath);\n } catch (e) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const msg = (e as any).message || \"Unknown error\";\n throw new ReportableError(`Failed to load build config ${buildConfigPath}: ${msg}`);\n }\n } else {\n throw new ReportableError(`Expected a ${BUILD_CONFIG_NAME} in ${packageDir}`);\n }\n\n let servicesModule: string | undefined;\n if (buildConfig.services.length) {\n try {\n servicesModule = await resolveLocalFile(\n ctx,\n packageDir,\n buildConfig.servicesModule ?? \"./services\"\n );\n } catch (e) {\n ctx.warn(`Failed to resolve entry point for package ${packageDir}: ${e}`);\n }\n }\n\n let cssFile: string | undefined;\n if (buildConfig.styles) {\n try {\n cssFile = await resolveLocalFile(ctx, packageDir, buildConfig.styles);\n } catch (e) {\n throw new ReportableError(`Failed to resolve css file for package ${packageDir}: ${e}`);\n }\n if (!cssFile) {\n throw new ReportableError(\n `Failed to find css file '${buildConfig.styles}' in ${packageDir}`\n );\n }\n }\n\n const i18nPaths = new Map<string, string>();\n if (buildConfig.i18n) {\n for (const locale of buildConfig.i18n) {\n if (i18nPaths.has(locale)) {\n throw new ReportableError(\n `Locale '${locale}' was defined twice in ${buildConfigPath}`\n );\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\n return {\n name: packageName,\n directory: packageDir,\n packageJsonPath: packageJsonPath,\n servicesModulePath: servicesModule,\n cssFilePath: cssFile,\n i18nPaths,\n dependencies,\n config: buildConfig\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 let packageJsonContent;\n try {\n packageJsonContent = JSON.parse(await readFile(packageJsonPath, \"utf-8\"));\n } catch (e) {\n throw new ReportableError(`Failed to read ${packageJsonPath}: ${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 const dependencies = packageJsonContent.dependencies ?? {};\n if (typeof dependencies !== \"object\") {\n throw new ReportableError(`Expected a valid 'dependencies' object in ${packageJsonPath}`);\n }\n\n const dependencyNames = Object.keys(dependencies);\n return {\n name: packageName,\n dependencies: dependencyNames\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 return `'${loc.packageName}' required by ${loc.importedFrom}`;\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 { pathToFileURL } from \"node:url\";\nimport {\n BuildConfig,\n PropertyMetaConfig,\n ProvidesConfig,\n ReferenceConfig,\n ServiceConfig\n} from \"@open-pioneer/build-support\";\nimport { verifyBuildConfigSchema } from \"./BuildConfigSchema\";\n\nexport const BUILD_CONFIG_NAME = \"build.config.mjs\";\n\nexport interface NormalizedPackageConfig {\n services: NormalizedServiceConfig[];\n servicesModule: string | undefined;\n styles: string | undefined;\n i18n: string[] | undefined;\n ui: NormalizedUiConfig;\n properties: NormalizedProperty[];\n}\n\nexport interface NormalizedServiceConfig {\n name: string;\n provides: ProvidesConfig[];\n references: Record<string, ReferenceConfig>;\n}\n\nexport interface NormalizedUiConfig {\n references: ReferenceConfig[];\n}\n\nexport interface NormalizedProperty {\n name: string;\n defaultValue: unknown;\n required: boolean;\n}\n\nlet requestId = 0;\n\n/**\n * Loads and parses a build configuration file from the given path on disk.\n */\nexport async function loadBuildConfig(path: string): Promise<NormalizedPackageConfig> {\n const fileURL = pathToFileURL(path);\n const importedModule = (await import(`${fileURL}?id=${++requestId}`)) as Record<\n string,\n unknown\n >;\n if (!importedModule || !importedModule.default) {\n throw new Error(`The module must contain a default export.`);\n }\n\n const config = importedModule.default;\n return parseBuildConfig(config);\n}\n\n/**\n * Parses a build configuration object and validates it.\n */\nexport function parseBuildConfig(object: unknown): NormalizedPackageConfig {\n const rawConfig = verifyBuildConfigSchema(object);\n return normalizeConfig(rawConfig);\n}\n\nconst BUILD_CONFIG_RE = /[\\\\/]build\\.config\\.mjs($|\\?)/;\n\nexport function isBuildConfig(file: string) {\n return BUILD_CONFIG_RE.test(file);\n}\n\nfunction normalizeConfig(rawConfig: BuildConfig): NormalizedPackageConfig {\n return {\n styles: rawConfig.styles,\n i18n: rawConfig.i18n,\n services: Object.entries(rawConfig.services ?? {}).map(([serviceName, serviceConfig]) => {\n return normalizeServiceConfig(serviceName, serviceConfig);\n }),\n servicesModule: rawConfig.servicesModule,\n ui: normalizeUiConfig(rawConfig.ui),\n properties: normalizeProperties(rawConfig.properties, rawConfig.propertiesMeta)\n };\n}\n\nfunction normalizeServiceConfig(name: string, rawConfig: ServiceConfig): NormalizedServiceConfig {\n return {\n name: name,\n provides: normalizeProvidesConfig(rawConfig.provides),\n references: normalizeReferencesConfig(rawConfig.references)\n };\n}\n\nfunction normalizeProvidesConfig(rawConfig: ServiceConfig[\"provides\"]): ProvidesConfig[] {\n if (!rawConfig) {\n return [];\n }\n\n if (typeof rawConfig === \"string\") {\n return [\n {\n name: rawConfig\n }\n ];\n }\n\n return rawConfig.map((providesConfig) => {\n const normalized: ProvidesConfig =\n typeof providesConfig === \"string\" ? { name: providesConfig } : providesConfig;\n return normalized;\n });\n}\n\nfunction normalizeReferencesConfig(\n rawConfig: ServiceConfig[\"references\"]\n): Record<string, ReferenceConfig> {\n if (!rawConfig) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(rawConfig).map(([referenceName, referenceConfig]) => {\n return [referenceName, normalizeReferenceConfig(referenceConfig)];\n })\n );\n}\n\nfunction normalizeReferenceConfig(rawConfig: string | ReferenceConfig): ReferenceConfig {\n if (typeof rawConfig === \"string\") {\n return { name: rawConfig };\n }\n return rawConfig;\n}\n\nfunction normalizeUiConfig(rawConfig: BuildConfig[\"ui\"]): NormalizedUiConfig {\n return {\n references: rawConfig?.references?.map(normalizeReferenceConfig) ?? []\n };\n}\n\nfunction normalizeProperties(\n properties: Record<string, unknown> | undefined,\n propertiesMeta: Record<string, PropertyMetaConfig> | undefined\n): NormalizedProperty[] {\n const result: NormalizedProperty[] = [];\n for (const [name, defaultValue] of Object.entries(properties ?? {})) {\n const required = propertiesMeta?.[name]?.required ?? false;\n result.push({\n name,\n defaultValue,\n required\n });\n }\n return result;\n}\n", "// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { z } from \"zod\";\nimport {\n BuildConfig,\n PropertyMetaConfig,\n ProvidesConfig,\n ReferenceConfig,\n ServiceConfig,\n UiConfig\n} from \"@open-pioneer/build-support\";\nimport { fromZodError } from \"zod-validation-error\";\n\nconst LITERAL_SCHEMA = z.union([z.string(), z.number(), z.boolean(), z.null()]);\n\ntype Literal = z.infer<typeof LITERAL_SCHEMA>;\n\ntype Json = Literal | { [key: string]: Json } | Json[];\n\nconst JSON_SCHEMA: z.ZodType<Json> = z.lazy(() =>\n z.union([LITERAL_SCHEMA, z.array(JSON_SCHEMA), z.record(JSON_SCHEMA)])\n);\n\nconst PROPERTY_META_SCHEMA: z.ZodType<PropertyMetaConfig> = z.strictObject({\n required: z.boolean().optional()\n});\n\nconst REFERENCE_CONFIG_SCHEMA: z.ZodType<ReferenceConfig> = z.strictObject({\n name: z.string(),\n qualifier: z.string().optional(),\n all: z.boolean().optional()\n});\n\nconst PROVIDES_CONFIG_SCHEMA: z.ZodType<ProvidesConfig> = z.strictObject({\n name: z.string(),\n qualifier: z.string().optional()\n});\n\nconst UI_CONFIG_SCHEMA: z.ZodType<UiConfig> = z.strictObject({\n references: z.array(z.string().or(REFERENCE_CONFIG_SCHEMA)).optional()\n});\n\nconst SERVICE_CONFIG_SCHEMA: z.ZodType<ServiceConfig> = z.strictObject({\n provides: z\n .string()\n .or(z.array(z.string().or(PROVIDES_CONFIG_SCHEMA)))\n .optional(),\n references: z.record(z.string(), z.string().or(REFERENCE_CONFIG_SCHEMA)).optional()\n});\n\nconst BUILD_CONFIG_SCHEMA: z.ZodType<BuildConfig> = z.strictObject({\n styles: z.string().optional(),\n i18n: z.array(z.string()).optional(),\n services: z.record(z.string(), SERVICE_CONFIG_SCHEMA).optional(),\n servicesModule: z.string().optional(),\n ui: UI_CONFIG_SCHEMA.optional(),\n properties: z.record(z.string(), JSON_SCHEMA).optional(),\n propertiesMeta: z.record(z.string(), PROPERTY_META_SCHEMA).optional()\n});\n\n/**\n * Ensures that `value` conforms to the {@link BuildConfig} interface.\n * Throws an error if that is not the case.\n *\n * @returns `value` but casted to the appropriate type.\n */\nexport function verifyBuildConfigSchema(value: unknown): BuildConfig {\n const result = BUILD_CONFIG_SCHEMA.safeParse(value);\n if (result.success) {\n return result.data;\n }\n throw fromZodError(result.error);\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}: ${e}`);\n }\n\n try {\n return parseI18nYaml(content);\n } catch (e) {\n throw new ReportableError(`Failed to parse ${path}: ${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\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 /** The name of the current application. */\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": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,ICEA,IAAAI,GAA2B,mBAC3BC,EAA8B,qBAE9BC,EAAqE,gBCHrE,IAAAC,GAAsB,iBAMf,SAASC,EAAeC,EAA6B,CACxD,IAAMC,KAAS,UAAMD,CAAS,EAC9B,OAAO,YAA0BE,EAAM,CACnCD,EAAO,GAAGC,CAAI,CAClB,CACJ,CCXA,IAAAC,GAAqB,+BACrBC,EAAqB,8BACrBC,EAAuB,2BCFhB,IAAMC,EAAN,cAA8B,KAAM,CAAC,ECArC,IAAMC,EAAN,KAAkB,CACb,SAAW,IAAI,IAKvB,SAASC,EAAuB,CAC5B,IAAMC,EAAQC,GAAUF,CAAK,EAEvBG,EAAW,KAAK,SAChBC,EAAQD,EAAS,IAAIF,CAAK,GAAK,EACrC,OAAAE,EAAS,IAAIF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ACvC,MAAM,IAAI,MACN,uDAAuDT,SAAeC,+BACrCW,8EAErC,CACJ,CjBtKO,SAASC,GAAQC,EAA0C,CAC9D,MAAO,CAACC,GAAUD,CAAO,EAAGE,GAAc,CAAC,CAC/C",
6
- "names": ["src_exports", "__export", "pioneer", "__toCommonJS", "import_node_fs", "import_node_path", "import_vite", "import_debug", "createDebugger", "namespace", "logger", "args", "import_generator", "import_template", "nodes", "ReportableError", "IdGenerator", "input", "clean", "cleanName", "existing", "count", "SERVICE_IMPORT", "template", "PKG_OBJECT", "SERVICE_OBJECT", "INTERFACE_OBJECT", "REFERENCE_OBJECT", "UI_OBJECT", "PROPERTY_OBJECT", "generatePackagesMetadata", "packages", "idGenerator", "IdGenerator", "packagesMetadata", "imports", "pkg", "packageMetadata", "generatePackageMetadata", "variableName", "className", "moduleId", "id", "renderedImporter", "program", "generate", "options", "servicesObject", "service", "ReportableError", "importName", "serviceObject", "p", "undefinedNode", "referenceName", "referenceConfig", "referenceObject", "uiObject", "r", "propertiesObject", "prop", "jsonToExpression", "json", "item", "name", "value", "import_promises", "import_path", "import_vite", "fs", "import_node_path", "fileExists", "file", "isInDirectory", "candidate", "directory", "rel", "Cache", "provider", "key", "_a", "_b", "id", "oldValue", "context", "values", "existingValue", "jobs", "existingJob", "job", "value", "import_node_url", "import_zod", "import_zod_validation_error", "LITERAL_SCHEMA", "JSON_SCHEMA", "PROPERTY_META_SCHEMA", "REFERENCE_CONFIG_SCHEMA", "PROVIDES_CONFIG_SCHEMA", "UI_CONFIG_SCHEMA", "SERVICE_CONFIG_SCHEMA", "BUILD_CONFIG_SCHEMA", "verifyBuildConfigSchema", "value", "result", "BUILD_CONFIG_NAME", "requestId", "loadBuildConfig", "path", "importedModule", "config", "parseBuildConfig", "object", "rawConfig", "verifyBuildConfigSchema", "normalizeConfig", "BUILD_CONFIG_RE", "isBuildConfig", "file", "serviceName", "serviceConfig", "normalizeServiceConfig", "normalizeUiConfig", "normalizeProperties", "name", "normalizeProvidesConfig", "normalizeReferencesConfig", "providesConfig", "referenceName", "referenceConfig", "normalizeReferenceConfig", "_a", "properties", "propertiesMeta", "result", "defaultValue", "required", "import_promises", "import_js_yaml", "import_zod", "import_zod_validation_error", "MESSAGES_SCHEMA", "I18N_SCHEMA", "loadI18nFile", "path", "content", "e", "ReportableError", "parseI18nYaml", "yaml", "data", "loadYaml", "parseI18nFile", "result", "rawI18n", "gatherMessages", "gatherOverrides", "messages", "prefix", "visitChildren", "record", "key", "value", "visitMessage", "message", "id", "overrides", "isDebug", "debug", "createDebugger", "MetadataRepository", "sourceRoot", "path", "isPackageJson", "isBuildConfig", "ctx", "appDirectory", "appPackageMetadata", "ReportableError", "appLocales", "packageMetadataByName", "visitDependencies", "dependencies", "importedFrom", "jobs", "packageName", "packageMetadata", "loc", "formatPackageLocation", "packageDir", "isLocalPackage", "entry", "propagateWatchFiles", "warning", "i18n", "watchFiles", "unresolvedPackageJson", "packageJsonLocation", "Cache", "loadI18nFile", "provider", "directory", "warnings", "trackingCtx", "id", "msg", "metadata", "parsePackageMetadata", "existingMetadata", "file", "packageJsonPath", "parsePackageJson", "buildConfigPath", "BUILD_CONFIG_NAME", "buildConfig", "fileExists", "loadBuildConfig", "e", "servicesModule", "resolveLocalFile", "cssFile", "i18nPaths", "locale", "packageJsonContent", "dependencyNames", "localModuleId", "result", "NODE_MODULES_RE", "sourceDir", "isInDirectory", "PACKAGE_JSON_RE", "generateCombinedCss", "packages", "cssImport", "file", "pkg", "import_posix", "import_vite", "APP_MODULE", "APP_META_QUERY", "APP_META_RE", "APP_PACKAGES_QUERY", "APP_PACKAGES_RE", "APP_CSS_QUERY", "APP_CSS_RE", "APP_I18N_INDEX_QUERY", "APP_I18N_INDEX_RE", "APP_I18N_QUERY", "APP_I18N_RE", "APP_I18N_LOCALE_RE", "PACKAGE_HOOKS_MODULE", "SOURCE_FILE_RE", "parseVirtualModuleId", "inputModuleId", "moduleId", "sourceFile", "getSourceFile", "base", "parseAppModuleId", "_a", "_b", "packageDirectory", "type", "locale", "serializeModuleId", "mod", "generateAppMetadata", "packageDirectory", "metadataModuleId", "packagesModule", "serializeModuleId", "cssModule", "i18nModule", "import_promises", "generateReactHooks", "packageName", "runtimeModuleId", "nodes", "import_template", "import_generator", "INDEX_TEMPLATE", "template", "IMPORT_TEMPLATE", "MESSAGES_TEMPLATE", "generateI18nIndex", "packageDirectory", "locales", "localesArray", "locale", "switchStmt", "localeModuleId", "serializeModuleId", "importStatement", "program", "generate", "generateI18nMessages", "options", "appName", "packages", "loadI18n", "packageMessages", "packagesNeedingMessages", "packageOverrides", "pkg", "filePath", "messages", "overrides", "ReportableError", "packageName", "existingMessages", "updatedMessages", "allMessages", "serialized", "isDebug", "debug", "createDebugger", "codegenPlugin", "manualDeps", "config", "repository", "devServer", "reactIntegrationId", "metadataId", "resolve", "rawModuleId", "resolvedResult", "resolvedConfig", "MetadataRepository", "server", "_", "path", "moduleIds", "moduleId", "mod", "err", "importer", "parseVirtualModuleId", "getPackageDirectory", "packageJsonPath", "findPackageJson", "ReportableError", "packageDir", "serializeModuleId", "e", "reportError", "_a", "_b", "directory", "packageName", "getPackageName", "generatedSourceCode", "generateReactHooks", "generateAppMetadata", "context", "buildMetadataContext", "appMetadata", "generatePackagesMetadata", "generateCombinedCss", "generateI18nIndex", "generateI18nMessages", "ctx", "id", "addManualDep", "error", "message", "file", "normalizedPath", "startDir", "rootDir", "dir", "candidate", "parent", "name", "content", "import_node_fs", "import_node_path", "import_node_process", "mpaPlugin", "options", "rootSite", "apps", "sites", "resolvedConfig", "config", "sourceRoot", "entryPoints", "appNames", "gatherEntryPoints", "chunk", "appName", "prefix", "path", "findMatchingEntryPointFile", "name", "appPath", "sitePath", "entryPointCount", "existingPath", "EXTENSIONS", "ext", "candidate", "extensions", "pioneer", "options", "mpaPlugin", "codegenPlugin"]
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/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: ${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(appMetadata.packages);\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(\"Internal error: \" + message);\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: ${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 { ReferenceConfig } from \"@open-pioneer/build-support\";\nimport { PackageMetadata } from \"../metadata/MetadataRepository\";\nimport { ReportableError } from \"../ReportableError\";\nimport { IdGenerator } from \"./IdGenerator\";\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\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(packages: PackageMetadataInput[]): string {\n const idGenerator = new IdGenerator();\n const packagesMetadata = nodes.objectExpression([]);\n const imports: nodes.Statement[] = [];\n for (const pkg of packages) {\n const packageMetadata = generatePackageMetadata(pkg, {\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): nodes.Expression {\n const servicesObject = nodes.objectExpression([]);\n for (const service of pkg.config.services) {\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.name,\n service.name,\n pkg.servicesModulePath\n );\n const serviceObject = SERVICE_OBJECT({\n SERVICE_NAME: nodes.stringLiteral(service.name),\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.name),\n QUALIFIER:\n p.qualifier == null ? undefinedNode() : nodes.stringLiteral(p.qualifier)\n })\n )\n ),\n SERVICE_REFERENCES: nodes.objectExpression(\n Object.entries(service.references).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.name), serviceObject)\n );\n }\n\n const uiObject = UI_OBJECT({\n UI_REFERENCES: nodes.arrayExpression(\n pkg.config.ui.references.map((r) => referenceObject(r))\n )\n });\n\n const propertiesObject = nodes.objectExpression(\n pkg.config.properties.map((prop) =>\n nodes.objectProperty(\n nodes.stringLiteral(prop.name),\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(referenceConfig: ReferenceConfig): nodes.Expression {\n return REFERENCE_OBJECT({\n INTERFACE_NAME: nodes.stringLiteral(referenceConfig.name),\n QUALIFIER: referenceConfig.qualifier\n ? nodes.stringLiteral(referenceConfig.qualifier)\n : undefinedNode(),\n ALL: nodes.booleanLiteral(referenceConfig.all ?? false)\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 { 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, NormalizedPackageConfig } from \"./parseBuildConfig\";\nimport { I18nFile, loadI18nFile } from \"./parseI18nYaml\";\nimport { BUILD_CONFIG_NAME } from \"@open-pioneer/build-common\";\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 /** 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: string[];\n\n /** Parsed metadata (from build config file). */\n config: NormalizedPackageConfig;\n}\n\nexport type MetadataContext = Pick<PluginContext, \"addWatchFile\" | \"resolve\" | \"warn\">;\n\nexport interface ResolvedPackageLocation {\n type: \"absolute\";\n directory: string;\n}\n\nexport interface UnresolvedPackageLocation {\n type: \"unresolved\";\n packageName: string;\n importedFrom: string;\n}\n\nexport type PackageLocation = ResolvedPackageLocation | UnresolvedPackageLocation;\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: PackageMetadata;\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 /**\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 }\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 (dependencies: string[], importedFrom: string) => {\n const jobs = dependencies.map(async (packageName) => {\n const packageMetadata = await this.getPackageMetadata(ctx, {\n type: \"unresolved\",\n packageName,\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 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(ctx, loc);\n\n // This would have to be changed when packages from the 'outside' are also supported in the future.\n if (!isLocalPackage(packageDir, this.sourceRoot)) {\n isDebug && debug(`Skipping non-local package '${packageDir}'.`);\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 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(ctx: MetadataContext, loc: PackageLocation) {\n if (loc.type === \"absolute\") {\n return await realpath(loc.directory);\n }\n\n // Try to locate the package via rollup resolve.\n const unresolvedPackageJson = `${loc.packageName}/package.json`;\n const packageJsonLocation = await ctx.resolve(\n unresolvedPackageJson,\n normalizePath(loc.importedFrom),\n {\n skipSelf: true\n }\n );\n if (!packageJsonLocation || packageJsonLocation.external) {\n throw new ReportableError(\n `Failed to find '${unresolvedPackageJson}' (from '${loc.importedFrom}'), is the dependency installed correctly?`\n );\n }\n\n const packageDir = await realpath(dirname(packageJsonLocation.id));\n isDebug && debug(`Found package '${loc.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 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 const metadata = await parsePackageMetadata(trackingCtx, directory);\n isDebug && debug(`Metadata for '${metadata.name}': %O`, metadata);\n\n // Ensure only one version of a package exists in the app\n const existingMetadata = this._byName.get(metadata.name);\n if (\n existingMetadata &&\n normalizePath(existingMetadata.directory) !== 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 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\nexport async function parsePackageMetadata(\n ctx: MetadataContext,\n packageDir: string\n): Promise<PackageMetadata> {\n isDebug && debug(`Visiting package directory ${packageDir}.`);\n\n const packageJsonPath = join(packageDir, \"package.json\");\n\n ctx.addWatchFile(packageJsonPath);\n const { name: packageName, dependencies } = await parsePackageJson(ctx, packageJsonPath);\n\n const buildConfigPath = join(packageDir, BUILD_CONFIG_NAME);\n let buildConfig: NormalizedPackageConfig | undefined;\n ctx.addWatchFile(normalizePath(buildConfigPath));\n if (await fileExists(buildConfigPath)) {\n try {\n buildConfig = await loadBuildConfig(buildConfigPath);\n } catch (e) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const msg = (e as any).message || \"Unknown error\";\n throw new ReportableError(`Failed to load build config ${buildConfigPath}: ${msg}`);\n }\n } else {\n throw new ReportableError(`Expected a ${BUILD_CONFIG_NAME} in ${packageDir}`);\n }\n\n let servicesModule: string | undefined;\n if (buildConfig.services.length) {\n try {\n servicesModule = await resolveLocalFile(\n ctx,\n packageDir,\n buildConfig.servicesModule ?? \"./services\"\n );\n } catch (e) {\n ctx.warn(`Failed to resolve entry point for package ${packageDir}: ${e}`);\n }\n }\n\n let cssFile: string | undefined;\n if (buildConfig.styles) {\n try {\n cssFile = await resolveLocalFile(ctx, packageDir, buildConfig.styles);\n } catch (e) {\n throw new ReportableError(`Failed to resolve css file for package ${packageDir}: ${e}`);\n }\n if (!cssFile) {\n throw new ReportableError(\n `Failed to find css file '${buildConfig.styles}' in ${packageDir}`\n );\n }\n }\n\n const i18nPaths = new Map<string, string>();\n if (buildConfig.i18n) {\n for (const locale of buildConfig.i18n) {\n if (i18nPaths.has(locale)) {\n throw new ReportableError(\n `Locale '${locale}' was defined twice in ${buildConfigPath}`\n );\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\n return {\n name: packageName,\n directory: packageDir,\n packageJsonPath: packageJsonPath,\n servicesModulePath: servicesModule,\n cssFilePath: cssFile,\n i18nPaths,\n dependencies,\n config: buildConfig\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 let packageJsonContent;\n try {\n packageJsonContent = JSON.parse(await readFile(packageJsonPath, \"utf-8\"));\n } catch (e) {\n throw new ReportableError(`Failed to read ${packageJsonPath}: ${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 const dependencies = packageJsonContent.dependencies ?? {};\n if (typeof dependencies !== \"object\") {\n throw new ReportableError(`Expected a valid 'dependencies' object in ${packageJsonPath}`);\n }\n\n const dependencyNames = Object.keys(dependencies);\n return {\n name: packageName,\n dependencies: dependencyNames\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 return `'${loc.packageName}' required by ${loc.importedFrom}`;\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 { pathToFileURL } from \"node:url\";\nimport {\n BuildConfig,\n PropertyMetaConfig,\n ProvidesConfig,\n ReferenceConfig,\n ServiceConfig\n} from \"@open-pioneer/build-support\";\nimport { BUILD_CONFIG_NAME, verifyBuildConfig } from \"@open-pioneer/build-common\";\nimport { basename } from \"node:path\";\n\nexport interface NormalizedPackageConfig {\n services: NormalizedServiceConfig[];\n servicesModule: string | undefined;\n styles: string | undefined;\n i18n: string[] | undefined;\n ui: NormalizedUiConfig;\n properties: NormalizedProperty[];\n}\n\nexport interface NormalizedServiceConfig {\n name: string;\n provides: ProvidesConfig[];\n references: Record<string, ReferenceConfig>;\n}\n\nexport interface NormalizedUiConfig {\n references: ReferenceConfig[];\n}\n\nexport interface NormalizedProperty {\n name: string;\n defaultValue: unknown;\n required: boolean;\n}\n\nlet requestId = 0;\n\n/**\n * Loads and parses a build configuration file from the given path on disk.\n */\nexport async function loadBuildConfig(path: string): Promise<NormalizedPackageConfig> {\n const fileURL = pathToFileURL(path);\n const importedModule = (await import(`${fileURL}?id=${++requestId}`)) as Record<\n string,\n unknown\n >;\n if (!importedModule || !importedModule.default) {\n throw new Error(`The module must contain a default export.`);\n }\n\n const config = importedModule.default;\n return parseBuildConfig(config);\n}\n\n/**\n * Parses a build configuration object and validates it.\n */\nexport function parseBuildConfig(object: unknown): NormalizedPackageConfig {\n const rawConfig = verifyBuildConfig(object);\n return normalizeConfig(rawConfig);\n}\n\nexport function isBuildConfig(file: string) {\n return basename(file) === BUILD_CONFIG_NAME;\n}\n\nfunction normalizeConfig(rawConfig: BuildConfig): NormalizedPackageConfig {\n return {\n styles: rawConfig.styles,\n i18n: rawConfig.i18n,\n services: Object.entries(rawConfig.services ?? {}).map(([serviceName, serviceConfig]) => {\n return normalizeServiceConfig(serviceName, serviceConfig);\n }),\n servicesModule: rawConfig.servicesModule,\n ui: normalizeUiConfig(rawConfig.ui),\n properties: normalizeProperties(rawConfig.properties, rawConfig.propertiesMeta)\n };\n}\n\nfunction normalizeServiceConfig(name: string, rawConfig: ServiceConfig): NormalizedServiceConfig {\n return {\n name: name,\n provides: normalizeProvidesConfig(rawConfig.provides),\n references: normalizeReferencesConfig(rawConfig.references)\n };\n}\n\nfunction normalizeProvidesConfig(rawConfig: ServiceConfig[\"provides\"]): ProvidesConfig[] {\n if (!rawConfig) {\n return [];\n }\n\n if (typeof rawConfig === \"string\") {\n return [\n {\n name: rawConfig\n }\n ];\n }\n\n return rawConfig.map((providesConfig) => {\n const normalized: ProvidesConfig =\n typeof providesConfig === \"string\" ? { name: providesConfig } : providesConfig;\n return normalized;\n });\n}\n\nfunction normalizeReferencesConfig(\n rawConfig: ServiceConfig[\"references\"]\n): Record<string, ReferenceConfig> {\n if (!rawConfig) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(rawConfig).map(([referenceName, referenceConfig]) => {\n return [referenceName, normalizeReferenceConfig(referenceConfig)];\n })\n );\n}\n\nfunction normalizeReferenceConfig(rawConfig: string | ReferenceConfig): ReferenceConfig {\n if (typeof rawConfig === \"string\") {\n return { name: rawConfig };\n }\n return rawConfig;\n}\n\nfunction normalizeUiConfig(rawConfig: BuildConfig[\"ui\"]): NormalizedUiConfig {\n return {\n references: rawConfig?.references?.map(normalizeReferenceConfig) ?? []\n };\n}\n\nfunction normalizeProperties(\n properties: Record<string, unknown> | undefined,\n propertiesMeta: Record<string, PropertyMetaConfig> | undefined\n): NormalizedProperty[] {\n const result: NormalizedProperty[] = [];\n for (const [name, defaultValue] of Object.entries(properties ?? {})) {\n const required = propertiesMeta?.[name]?.required ?? false;\n result.push({\n name,\n defaultValue,\n required\n });\n }\n return result;\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}: ${e}`);\n }\n\n try {\n return parseI18nYaml(content);\n } catch (e) {\n throw new ReportableError(`Failed to parse ${path}: ${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\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 /** The name of the current application. */\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": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,ICEA,IAAAI,GAA2B,mBAC3BC,EAA8B,qBAE9BC,EAAqE,gBCHrE,IAAAC,EAAsB,iBAMf,SAASC,EAAeC,EAA6B,CACxD,IAAMC,KAAS,SAAMD,CAAS,EAC9B,OAAO,YAA0BE,EAAM,CACnCD,EAAO,GAAGC,CAAI,CAClB,CACJ,CCXA,IAAAC,GAAqB,+BACrBC,EAAqB,8BACrBC,EAAuB,2BCFhB,IAAMC,EAAN,cAA8B,KAAM,CAAC,ECArC,IAAMC,EAAN,KAAkB,CACb,SAAW,IAAI,IAKvB,SAASC,EAAuB,CAC5B,IAAMC,EAAQC,GAAUF,CAAK,EAEvBG,EAAW,KAAK,SAChBC,EAAQD,EAAS,IAAIF,CAAK,GAAK,EACrC,OAAAE,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,EAAU,YAAY,EAC/D,GAAI,IAAC,cAAWJ,CAAI,EAChB,MAAM,IAAI,MACN,0BAA0BA,+EAC9B,EAEJ,MAAO,CACH,KAAMI,EACN,KAAMJ,CACV,CACJ,CAAC,EACD,GAAIb,EAAQ,SAAU,CAClB,IAAMa,KAAO,WAAQb,EAAQ,WAAY,YAAY,EACrD,GAAI,IAAC,cAAWa,CAAI,EAChB,MAAM,IAAI,MACN,+BAA+BA,wDACnC,EAEJV,EAAM,KAAK,CACP,KAAM,QACN,KAAMU,CACV,CAAC,EAGL,IAAMN,EAAsC,CAAC,EACzCW,EAAkB,EACtB,OAAW,CAAE,KAAAH,EAAM,KAAAF,CAAK,GAAK,CAACX,EAAMC,CAAK,EAAE,KAAK,EAAG,CAC/C,IAAMgB,EAAeZ,EAAYQ,CAAI,EACrC,GAAII,EACA,MAAM,IAAI,MACN,gBAAgBJ,+BAAkCI,SAAoBN,kCAC1E,EAEJN,EAAYQ,CAAI,EAAIF,EACpB,EAAEK,EAEN,GAAIA,IAAoB,EACpB,MAAM,IAAI,MACN,gFACJ,EAGJ,IAAMV,EAAWN,EAAK,IAAI,CAAC,CAAE,KAAAa,CAAK,IAAMA,CAAI,EAC5C,MAAO,CACH,YAAAR,EACA,SAAAC,CACJ,CACJ,CAEA,IAAMY,GAAa,CAAC,MAAO,OAAQ,MAAO,MAAM,EAEhD,SAASN,GAA2BH,EAAiBC,EAAgB,CACjE,QAAWS,KAAOD,GAAY,CAC1B,IAAME,EAAYV,EAASS,EAC3B,MAAI,cAAWC,CAAS,EACpB,OAAOA,EAIf,IAAMC,EAAaH,GAAW,KAAK,IAAI,EACvC,MAAM,IAAI,MACN,uDAAuDT,SAAeC,+BACrCW,8EAErC,CACJ,ChBtKO,SAASC,GAAQC,EAA0C,CAC9D,MAAO,CAACC,GAAUD,CAAO,EAAGE,GAAc,CAAC,CAC/C",
6
+ "names": ["src_exports", "__export", "pioneer", "__toCommonJS", "import_node_fs", "import_node_path", "import_vite", "import_debug", "createDebugger", "namespace", "logger", "args", "import_generator", "import_template", "nodes", "ReportableError", "IdGenerator", "input", "clean", "cleanName", "existing", "count", "SERVICE_IMPORT", "template", "PKG_OBJECT", "SERVICE_OBJECT", "INTERFACE_OBJECT", "REFERENCE_OBJECT", "UI_OBJECT", "PROPERTY_OBJECT", "generatePackagesMetadata", "packages", "idGenerator", "IdGenerator", "packagesMetadata", "imports", "pkg", "packageMetadata", "generatePackageMetadata", "variableName", "className", "moduleId", "id", "renderedImporter", "program", "generate", "options", "servicesObject", "service", "ReportableError", "importName", "serviceObject", "p", "undefinedNode", "referenceName", "referenceConfig", "referenceObject", "uiObject", "r", "propertiesObject", "prop", "jsonToExpression", "json", "item", "name", "value", "import_promises", "import_path", "import_vite", "fs", "import_node_path", "fileExists", "file", "isInDirectory", "candidate", "directory", "rel", "Cache", "provider", "key", "_a", "_b", "id", "oldValue", "context", "values", "existingValue", "jobs", "existingJob", "job", "value", "import_node_url", "import_build_common", "import_node_path", "requestId", "loadBuildConfig", "path", "importedModule", "config", "parseBuildConfig", "object", "rawConfig", "normalizeConfig", "isBuildConfig", "file", "serviceName", "serviceConfig", "normalizeServiceConfig", "normalizeUiConfig", "normalizeProperties", "name", "normalizeProvidesConfig", "normalizeReferencesConfig", "providesConfig", "referenceName", "referenceConfig", "normalizeReferenceConfig", "_a", "properties", "propertiesMeta", "result", "defaultValue", "required", "import_promises", "import_js_yaml", "import_zod", "import_zod_validation_error", "MESSAGES_SCHEMA", "I18N_SCHEMA", "loadI18nFile", "path", "content", "e", "ReportableError", "parseI18nYaml", "yaml", "data", "loadYaml", "parseI18nFile", "result", "rawI18n", "gatherMessages", "gatherOverrides", "messages", "prefix", "visitChildren", "record", "key", "value", "visitMessage", "message", "id", "overrides", "import_build_common", "isDebug", "debug", "createDebugger", "MetadataRepository", "sourceRoot", "path", "isPackageJson", "isBuildConfig", "ctx", "appDirectory", "appPackageMetadata", "ReportableError", "appLocales", "packageMetadataByName", "visitDependencies", "dependencies", "importedFrom", "jobs", "packageName", "packageMetadata", "loc", "formatPackageLocation", "packageDir", "isLocalPackage", "entry", "propagateWatchFiles", "warning", "i18n", "watchFiles", "unresolvedPackageJson", "packageJsonLocation", "Cache", "loadI18nFile", "provider", "directory", "warnings", "trackingCtx", "id", "msg", "metadata", "parsePackageMetadata", "existingMetadata", "file", "packageJsonPath", "parsePackageJson", "buildConfigPath", "buildConfig", "fileExists", "loadBuildConfig", "e", "servicesModule", "resolveLocalFile", "cssFile", "i18nPaths", "locale", "packageJsonContent", "dependencyNames", "localModuleId", "result", "NODE_MODULES_RE", "sourceDir", "isInDirectory", "PACKAGE_JSON_RE", "generateCombinedCss", "packages", "cssImport", "file", "pkg", "import_posix", "import_vite", "APP_MODULE", "APP_META_QUERY", "APP_META_RE", "APP_PACKAGES_QUERY", "APP_PACKAGES_RE", "APP_CSS_QUERY", "APP_CSS_RE", "APP_I18N_INDEX_QUERY", "APP_I18N_INDEX_RE", "APP_I18N_QUERY", "APP_I18N_RE", "APP_I18N_LOCALE_RE", "PACKAGE_HOOKS_MODULE", "SOURCE_FILE_RE", "parseVirtualModuleId", "inputModuleId", "moduleId", "sourceFile", "getSourceFile", "base", "parseAppModuleId", "_a", "_b", "packageDirectory", "type", "locale", "serializeModuleId", "mod", "generateAppMetadata", "packageDirectory", "metadataModuleId", "packagesModule", "serializeModuleId", "cssModule", "i18nModule", "import_promises", "generateReactHooks", "packageName", "runtimeModuleId", "nodes", "import_template", "import_generator", "INDEX_TEMPLATE", "template", "IMPORT_TEMPLATE", "MESSAGES_TEMPLATE", "generateI18nIndex", "packageDirectory", "locales", "localesArray", "locale", "switchStmt", "localeModuleId", "serializeModuleId", "importStatement", "program", "generate", "generateI18nMessages", "options", "appName", "packages", "loadI18n", "packageMessages", "packagesNeedingMessages", "packageOverrides", "pkg", "filePath", "messages", "overrides", "ReportableError", "packageName", "existingMessages", "updatedMessages", "allMessages", "serialized", "isDebug", "debug", "createDebugger", "codegenPlugin", "manualDeps", "config", "repository", "devServer", "reactIntegrationId", "metadataId", "resolve", "rawModuleId", "resolvedResult", "resolvedConfig", "MetadataRepository", "server", "_", "path", "moduleIds", "moduleId", "mod", "err", "importer", "parseVirtualModuleId", "getPackageDirectory", "packageJsonPath", "findPackageJson", "ReportableError", "packageDir", "serializeModuleId", "e", "reportError", "_a", "_b", "directory", "packageName", "getPackageName", "generatedSourceCode", "generateReactHooks", "generateAppMetadata", "context", "buildMetadataContext", "appMetadata", "generatePackagesMetadata", "generateCombinedCss", "generateI18nIndex", "generateI18nMessages", "ctx", "id", "addManualDep", "error", "message", "file", "normalizedPath", "startDir", "rootDir", "dir", "candidate", "parent", "name", "content", "import_node_fs", "import_node_path", "import_node_process", "mpaPlugin", "options", "rootSite", "apps", "sites", "resolvedConfig", "config", "sourceRoot", "entryPoints", "appNames", "gatherEntryPoints", "chunk", "appName", "prefix", "path", "findMatchingEntryPointFile", "name", "appPath", "sitePath", "entryPointCount", "existingPath", "EXTENSIONS", "ext", "candidate", "extensions", "pioneer", "options", "mpaPlugin", "codegenPlugin"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-pioneer/vite-plugin-pioneer",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "types.d.ts",
6
6
  "type": "commonjs",
@@ -26,7 +26,8 @@
26
26
  "debug": "^4.3.4",
27
27
  "js-yaml": "^4.1.0",
28
28
  "zod": "^3.21.4",
29
- "zod-validation-error": "^1.3.0"
29
+ "zod-validation-error": "^1.3.0",
30
+ "@open-pioneer/build-common": "^0.1.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/babel__generator": "^7.6.4",
@@ -41,15 +42,14 @@
41
42
  "sass": "^1.62.1",
42
43
  "vite": "^4.3.6",
43
44
  "@open-pioneer/build-support": "^0.3.2",
44
- "@open-pioneer/vite-plugin-pioneer": "^0.5.1",
45
- "dev-utils": "0.0.1"
45
+ "@open-pioneer/vite-plugin-pioneer": "^0.5.2",
46
+ "internal-dev-utils": "0.0.1"
46
47
  },
47
48
  "scripts": {
48
49
  "clean": "rimraf dist temp",
49
50
  "build": "node build.mjs build",
50
51
  "build-dev": "node build.mjs buildDev",
51
52
  "dev": "node build.mjs watch",
52
- "test": "pnpm run build-dev && rimraf temp && mocha dist/all.test.js",
53
- "test-debug": "pnpm run build-dev && rimraf temp && mocha --node-option inspect-brk dist/all.test.js"
53
+ "test": "vitest"
54
54
  }
55
55
  }