@hitachivantara/app-shell-vite-plugin 1.6.10 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +11 -13
  2. package/dist/automatic-utils.d.ts +0 -1
  3. package/dist/automatic-utils.js +16 -17
  4. package/dist/config-utils.d.ts +0 -1
  5. package/dist/config-utils.js +8 -9
  6. package/dist/esm-externals/emotion-cache.production.min.js +2 -2
  7. package/dist/esm-externals/emotion-cache.production.min.js.map +1 -1
  8. package/dist/esm-externals/emotion-react.production.min.js +2 -2
  9. package/dist/esm-externals/emotion-react.production.min.js.map +1 -1
  10. package/dist/esm-externals/react-dom.production.min.js +2 -2
  11. package/dist/esm-externals/react-dom.production.min.js.map +1 -1
  12. package/dist/esm-externals/react-router-dom.production.min.js +9 -9
  13. package/dist/esm-externals/react-router-dom.production.min.js.map +1 -1
  14. package/dist/esm-externals/react.production.min.js +2 -2
  15. package/dist/esm-externals/react.production.min.js.map +1 -1
  16. package/dist/index.d.ts +1 -3
  17. package/dist/index.js +0 -2
  18. package/dist/nodeModule.d.ts +2 -4
  19. package/dist/nodeModule.js +11 -8
  20. package/dist/shared-dependencies.d.ts +0 -1
  21. package/dist/shared-dependencies.js +8 -9
  22. package/dist/tests/automatic-utils.test.d.ts +0 -1
  23. package/dist/tests/automatic-utils.test.js +102 -99
  24. package/dist/tests/config-utils.test.d.ts +0 -1
  25. package/dist/tests/config-utils.test.js +10 -10
  26. package/dist/tests/mocks/path.mock.d.ts +0 -1
  27. package/dist/tests/mocks/path.mock.js +1 -2
  28. package/dist/tests/vite-configuration-processor-plugin.test.d.ts +0 -1
  29. package/dist/tests/vite-configuration-processor-plugin.test.js +22 -23
  30. package/dist/tests/vite-crossorigin-fix-plugin.test.d.ts +0 -1
  31. package/dist/tests/vite-crossorigin-fix-plugin.test.js +2 -3
  32. package/dist/tests/vite-generate-base-plugin.test.d.ts +0 -1
  33. package/dist/tests/vite-generate-base-plugin.test.js +1 -2
  34. package/dist/tests/vite-metadata-plugin.test.d.ts +0 -1
  35. package/dist/tests/vite-metadata-plugin.test.js +9 -9
  36. package/dist/virtual-entrypoints.d.ts +0 -1
  37. package/dist/virtual-entrypoints.js +1 -2
  38. package/dist/vite-configuration-processor-plugin.d.ts +0 -1
  39. package/dist/vite-configuration-processor-plugin.js +18 -19
  40. package/dist/vite-crossorigin-fix-plugin.d.ts +1 -2
  41. package/dist/vite-crossorigin-fix-plugin.js +7 -8
  42. package/dist/vite-generate-base-plugin.d.ts +1 -2
  43. package/dist/vite-generate-base-plugin.js +8 -9
  44. package/dist/vite-generate-bash-script-plugin.d.ts +0 -1
  45. package/dist/vite-generate-bash-script-plugin.js +4 -5
  46. package/dist/vite-importmap-plugin.d.ts +0 -1
  47. package/dist/vite-importmap-plugin.js +21 -22
  48. package/dist/vite-metadata-plugin.d.ts +0 -1
  49. package/dist/vite-metadata-plugin.js +7 -8
  50. package/dist/vite-plugin.d.ts +1 -3
  51. package/dist/vite-plugin.js +25 -27
  52. package/dist/vite-watch-config-plugin.d.ts +0 -1
  53. package/dist/vite-watch-config-plugin.js +7 -8
  54. package/package.json +36 -44
  55. package/LICENSE +0 -201
  56. package/dist/automatic-utils.d.ts.map +0 -1
  57. package/dist/automatic-utils.js.map +0 -1
  58. package/dist/config-utils.d.ts.map +0 -1
  59. package/dist/config-utils.js.map +0 -1
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/index.js.map +0 -1
  62. package/dist/nodeModule.d.ts.map +0 -1
  63. package/dist/nodeModule.js.map +0 -1
  64. package/dist/shared-dependencies.d.ts.map +0 -1
  65. package/dist/shared-dependencies.js.map +0 -1
  66. package/dist/tests/automatic-utils.test.d.ts.map +0 -1
  67. package/dist/tests/automatic-utils.test.js.map +0 -1
  68. package/dist/tests/config-utils.test.d.ts.map +0 -1
  69. package/dist/tests/config-utils.test.js.map +0 -1
  70. package/dist/tests/mocks/path.mock.d.ts.map +0 -1
  71. package/dist/tests/mocks/path.mock.js.map +0 -1
  72. package/dist/tests/setup.d.ts +0 -2
  73. package/dist/tests/setup.d.ts.map +0 -1
  74. package/dist/tests/setup.js +0 -2
  75. package/dist/tests/setup.js.map +0 -1
  76. package/dist/tests/vite-configuration-processor-plugin.test.d.ts.map +0 -1
  77. package/dist/tests/vite-configuration-processor-plugin.test.js.map +0 -1
  78. package/dist/tests/vite-crossorigin-fix-plugin.test.d.ts.map +0 -1
  79. package/dist/tests/vite-crossorigin-fix-plugin.test.js.map +0 -1
  80. package/dist/tests/vite-generate-base-plugin.test.d.ts.map +0 -1
  81. package/dist/tests/vite-generate-base-plugin.test.js.map +0 -1
  82. package/dist/tests/vite-metadata-plugin.test.d.ts.map +0 -1
  83. package/dist/tests/vite-metadata-plugin.test.js.map +0 -1
  84. package/dist/virtual-entrypoints.d.ts.map +0 -1
  85. package/dist/virtual-entrypoints.js.map +0 -1
  86. package/dist/vite-configuration-processor-plugin.d.ts.map +0 -1
  87. package/dist/vite-configuration-processor-plugin.js.map +0 -1
  88. package/dist/vite-crossorigin-fix-plugin.d.ts.map +0 -1
  89. package/dist/vite-crossorigin-fix-plugin.js.map +0 -1
  90. package/dist/vite-generate-base-plugin.d.ts.map +0 -1
  91. package/dist/vite-generate-base-plugin.js.map +0 -1
  92. package/dist/vite-generate-bash-script-plugin.d.ts.map +0 -1
  93. package/dist/vite-generate-bash-script-plugin.js.map +0 -1
  94. package/dist/vite-importmap-plugin.d.ts.map +0 -1
  95. package/dist/vite-importmap-plugin.js.map +0 -1
  96. package/dist/vite-metadata-plugin.d.ts.map +0 -1
  97. package/dist/vite-metadata-plugin.js.map +0 -1
  98. package/dist/vite-plugin.d.ts.map +0 -1
  99. package/dist/vite-plugin.js.map +0 -1
  100. package/dist/vite-watch-config-plugin.d.ts.map +0 -1
  101. package/dist/vite-watch-config-plugin.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-crossorigin-fix-plugin.test.js","sourceRoot":"","sources":["../../src/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AC7B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;YACrE,MAAM,IAAI,GAAG;;;;;;;;;;;;OAYZ,CAAC;YAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAClD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACrD,MAAM,IAAI,GAAG;;;;;;;;;;;;OAYZ,CAAC;YAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAClD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport {\n checkCrossOrigin,\n addUseCredentials\n} from \"../vite-crossorigin-fix-plugin\";\n\ndescribe(\"vite-crossorigin-fix\", () => {\n describe(\"checkCrossOrigin\", () => {\n it('should return an empty array if no scripts have crossorigin=\"use-credentials\"', () => {\n const html = `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Test</title>\n </head>\n <body>\n <script src=\"/assets/main.js\"></script>\n </body>\n </html>\n `;\n\n const result = checkCrossOrigin(html);\n expect(result).toEqual([]);\n });\n\n it('should return an array of script sources with crossorigin=\"use-credentials\"', () => {\n const html = `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Test</title>\n </head>\n <body>\n <script src=\"/assets/main.js\" crossorigin=\"use-credentials\" type=\"module\"></script>\n </body>\n </html>\n `;\n\n const result = checkCrossOrigin(html);\n expect(result).toEqual([\"/assets/main.js\"]);\n });\n\n it(\"should ignore scripts that are not modules\", () => {\n const html = `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Test</title>\n </head>\n <body>\n <script src=\"/assets/main.js\" crossorigin=\"use-credentials\"></script>\n </body>\n </html>\n `;\n\n const result = checkCrossOrigin(html);\n expect(result).toEqual([]);\n });\n\n it(\"should ignore external and data URLs\", () => {\n const html = `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Test</title>\n </head>\n <body>\n <script src=\"https://external.com/main.js\" crossorigin=\"use-credentials\" type=\"module\"></script>\n <script src=\"data:text/javascript;base64,abcd\" crossorigin=\"use-credentials\" type=\"module\"></script>\n </body>\n </html>\n `;\n\n const result = checkCrossOrigin(html);\n expect(result).toEqual([]);\n });\n });\n\n describe(\"addUseCredentials\", () => {\n it('should add crossorigin=\"use-credentials\" to all script tags', () => {\n const html = `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Test</title>\n </head>\n <body>\n <script \n src=\"/assets/main.js\" \n crossorigin type=\"module\"></script>\n </body>\n </html>\n `;\n\n const result = addUseCredentials(\"main.js\", html);\n expect(result).toContain('crossorigin=\"use-credentials\"');\n });\n\n it('should handle link rel=\"modulepreload\" tags', () => {\n const html = `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Test</title>\n <link rel=\"modulepreload\"\n href=\"/assets/main.js\"\n crossorigin>\n </head>\n <body>\n </body>\n </html>\n `;\n\n const result = addUseCredentials(\"main.js\", html);\n expect(result).toContain('crossorigin=\"use-credentials\"');\n });\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-generate-base-plugin.test.d.ts","sourceRoot":"","sources":["../../src/tests/vite-generate-base-plugin.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-generate-base-plugin.test.js","sourceRoot":"","sources":["../../src/tests/vite-generate-base-plugin.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACzC,IAAI,CAAC,IAAI,CAAsC;YAC7C,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,WAAW,CAAC;YAC3C,CAAC,IAAI,EAAE,EAAE,EAAE,oBAAoB,CAAC;SACjC,CAAC,CAAC,uCAAuC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;YACtE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\nimport { getAppTitle } from \"../vite-generate-base-plugin\";\n\ndescribe(\"test vite-generate-base plugin\", () => {\n describe(\"test `getAppTitle` method\", () => {\n test.each<[boolean, HvAppShellConfig, string]>([\n [false, { name: \"dummyName\" }, \"dummyName\"],\n [true, {}, \"%%APPSHELL_TITLE%%\"]\n ])(\"At mode %b, %j, app title matches %s\", (value, config, expected) => {\n expect(getAppTitle(value, config)).toBe(expected);\n });\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-metadata-plugin.test.d.ts","sourceRoot":"","sources":["../../src/tests/vite-metadata-plugin.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-metadata-plugin.test.js","sourceRoot":"","sources":["../../src/tests/vite-metadata-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAErD,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MA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AqC;QACrC,EAAE,CAAC,UAAU,GAAG,KAAK,CAAC;QACtB,qCAAqC;QACrC,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import fs from \"fs\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport injectMetadata from \"../vite-metadata-plugin\";\n\ndescribe(\"test vite-metadata plugin\", () => {\n it(\"it returns the injectMetadata information\", () => {\n const fsTmp = fs.existsSync;\n fs.existsSync = vi.fn().mockImplementation((file: string) => {\n return file.match(\"/dummyPath/dummyRootProject/app-shell.config.json\");\n });\n\n const readFileSyncTmp = fs.readFileSync;\n fs.readFileSync = vi.fn().mockImplementation((file: string) => {\n const version = (packageFile: string) => {\n if (\n packageFile.indexOf(\"/client/packages/app-shell-ui/package.json\") >= 0\n ) {\n return \"appShellUIDummyVersion\";\n }\n if (\n packageFile.indexOf(\n \"/client/packages/app-shell-vite-plugin/package.json\"\n ) >= 0\n ) {\n return \"appShellVitePluginDummyVersion\";\n }\n return \"dummyVersion\";\n };\n return JSON.stringify({ version: version(file) });\n });\n\n const metadata: PluginOption = injectMetadata();\n const { transformIndexHtml } = metadata as Plugin;\n // @ts-expect-error This is a function an dis callable\n expect(transformIndexHtml()).toMatchObject([\n {\n attrs: {\n content: \"appShellUIDummyVersion\",\n name: \"app-shell-ui-version\"\n },\n tag: \"meta\"\n },\n {\n attrs: {\n content: \"appShellVitePluginDummyVersion\",\n name: \"app-shell-vite-plugin-version\"\n },\n tag: \"meta\"\n }\n ]);\n\n // Restore the original fs.existsSync\n fs.existsSync = fsTmp;\n // Restore the original fs.existsSync\n fs.readFileSync = readFileSyncTmp;\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"virtual-entrypoints.d.ts","sourceRoot":"","sources":["../src/virtual-entrypoints.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,YAAY,EAAE,OAAO;;;EAoClE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"virtual-entrypoints.js","sourceRoot":"","sources":["../src/virtual-entrypoints.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,YAAqB;IACjE,OAAO;QACL,mBAAmB,EAAE;;;;;;;;;;IAUrB;QAEA,iBAAiB,EAAE,YAAY;YAC7B,CAAC,CAAC;;;;;;;;;oBASY;YACd,CAAC,CAAC;;;;;;;;;oBASY;KACjB,CAAC;AACJ,CAAC","sourcesContent":["export default function getVirtualEntrypoints(inlineConfig: boolean) {\n return {\n \"/virtual/main.tsx\": `import React, { Suspense } from \"react\";\nimport ReactDOM from \"react-dom/client\";\nimport App from \"virtual:App.tsx\";\n\nconst root = ReactDOM.createRoot(document.getElementById(\"hv-root\"));\n\nroot.render(React.createElement(\n Suspense,\n { fallback: true },\n React.createElement(App, null)\n));`,\n\n \"virtual:App.tsx\": inlineConfig\n ? `import React from \"react\";\nimport HvAppShell from \"@hitachivantara/app-shell-ui\";\n\nconst App = () => {\n return React.createElement(HvAppShell, {\n config: globalThis.__appshell_config__\n });\n};\n\nexport default App;`\n : `import React from \"react\";\nimport HvAppShell from \"@hitachivantara/app-shell-ui\";\n\nconst App = () => {\n return React.createElement(HvAppShell, {\n configUrl: document.baseURI + \"app-shell.config.json\"\n });\n};\n\nexport default App;`\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-configuration-processor-plugin.d.ts","sourceRoot":"","sources":["../src/vite-configuration-processor-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,MAAM,CAAC;AAGrD,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAc1C,KAAK,gBAAgB,GACjB,yBAAyB,GACzB,qBAAqB,GACrB,sBAAsB,CAAC;AAE3B,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,EAChE,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,MAAM,GAClB,CAAC,EAAE,CAkBL;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,gBAAgB,EAChC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,OAAO,EACxB,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,GAAE,MAAM,EAAO,GACrB,YAAY,CAyJd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-configuration-processor-plugin.js","sourceRoot":"","sources":["../src/vite-configuration-processor-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAYxB,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,IAAK,WAGJ;AAHD,WAAK,WAAW;IACd,8BAAe,CAAA;IACf,8BAAe,CAAA;AACjB,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AAOD,MAAM,UAAU,uBAAuB,CACrC,OAAY,EACZ,WAAmB;IAEnB,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;QACpC,IAAI,OAAO,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAClE,OAAO;gBACL,GAAG,gBAAgB;gBACnB,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,WAAW,GAAG,CAAC;gBAC/D,KAAK,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC;aACpE,CAAC;QACJ,CAAC;QAED,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,OAAO;gBACL,GAAG,gBAAgB;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AED,kBAAkB,EAAE;YAClB,OAAO,EAAE,IAAI,CAAC,EAAE;gBACd,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,OAAO,SAAS,CAAC;gBACnB,CAAC;gBAED,OAAO;oBACL,IAAI;oBAEJ,IAAI,EAAE;wBACJ;4BACE,GAAG,EAAE,QAAQ;4BACb,QAAQ,EAAE,cAAc;4BACxB,QAAQ,EAAE,oCACR,kBAAkB;gCAChB,CAAC,CAAC,qBAAqB;gCACvB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,IAAI,cAAc,CAC1D,GAAG;yBACJ;qBACF;iBACF,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PluginOption, UserConfig } from \"vite\";\nimport type { NormalizedOutputOptions } from \"rollup\";\n\nimport type {\n HvAppShellConfig,\n HvAppShellHeaderAction,\n HvAppShellProvidersConfig,\n HvAppShellViewsConfig\n} from \"@hitachivantara/app-shell-shared\";\n\nimport {\n getAppModules,\n getBasePath,\n replaceSelf,\n startsWithSelf\n} from \"./config-utils.js\";\n\nenum ViteCommand {\n BUILD = \"build\",\n SERVE = \"serve\"\n}\n\ntype BundleDefinition =\n | HvAppShellProvidersConfig\n | HvAppShellViewsConfig\n | HvAppShellHeaderAction;\n\nexport function replaceReferencesToSelf<T extends BundleDefinition>(\n bundles: T[],\n selfAppName: string\n): T[] {\n return bundles.map(bundleDefinition => {\n if (\"views\" in bundleDefinition && bundleDefinition.views != null) {\n return {\n ...bundleDefinition,\n bundle: replaceSelf(bundleDefinition.bundle, `${selfAppName}/`),\n views: replaceReferencesToSelf(bundleDefinition.views, selfAppName)\n };\n }\n\n if (startsWithSelf(bundleDefinition.bundle)) {\n return {\n ...bundleDefinition,\n bundle: replaceSelf(bundleDefinition.bundle, `${selfAppName}/`)\n };\n }\n return bundleDefinition;\n });\n}\n\n/**\n * Process configuration, executing several tasks:\n * - Create rollup configuration to support module creation\n * - Generates final transformed configuration json\n * - \"base\" value is always \"./\" for build, and main app baseUrl for preview or dev\n * @param root Project root directory.\n * @param appShellConfig The original App Shell configuration json.\n * @param selfAppName The name of the application bundle being built.\n * @param buildEntryPoint If true, the index.html entry point will be added to the bundle.\n * @param inlineConfig flag to control if config is included at index.html\n * @param generateEmptyShell flag to control if we are creating an empty AppShell instance\n * @param modules the set of modules to be created by the rollup\n */\nexport default function processConfiguration(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string,\n buildEntryPoint: boolean,\n inlineConfig: boolean,\n generateEmptyShell: boolean,\n modules: string[] = []\n): PluginOption {\n let finalAppShellConfig: HvAppShellConfig;\n let basePath: string;\n\n return {\n name: \"vite-plugin-appShell-configuration-processor\",\n\n config(config: UserConfig, { command }) {\n const projectRoot = root ?? config.root;\n\n let appModules: Record<string, string> = {};\n if (!generateEmptyShell) {\n appModules = getAppModules(projectRoot, modules);\n console.info(\n \"Modules exported by the application bundle:\",\n Object.entries(appModules).reduce(\n (acc, [key, value]) => {\n acc[`${selfAppName}/${key}.js`] = value;\n return acc;\n },\n {} as Record<string, string>\n )\n );\n }\n\n basePath = getBasePath(appShellConfig.baseUrl, config.base);\n\n return {\n build: {\n rollupOptions: {\n preserveEntrySignatures: \"strict\",\n input: {\n ...(buildEntryPoint &&\n fs.existsSync(path.resolve(projectRoot, \"index.html\"))\n ? { main: path.resolve(projectRoot, \"index.html\") }\n : {}),\n ...appModules\n },\n output: {\n entryFileNames: \"[name].js\"\n }\n }\n },\n // if serve (preview/dev) it uses the basePath. Otherwise(build), use ./\n base: command === ViteCommand.SERVE ? basePath : \"./\"\n };\n },\n\n /**\n * Rollup hook with the info for bundle generation\n * It will be used to create a new configuration with:\n * - bundles replace with the final location (e.g. -> \"bundle\": \"src/pages/Main\" transformed to \"bundle\": \"pages/Main.js\",\n * @param options build options\n */\n async generateBundle(options: NormalizedOutputOptions) {\n if (generateEmptyShell || !buildEntryPoint) {\n return;\n }\n\n // obtain the directory (dist) where the new config file will be placed\n let targetDir: string | undefined;\n if (options.dir) {\n targetDir = options.dir;\n } else if (options.file) {\n targetDir = path.dirname(options.file);\n }\n\n if (!targetDir) {\n throw new Error(\n \"Please set outputPath, so we can know where to place the json file\"\n );\n }\n\n // create the targetDir if it does not exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n\n // theming structure does not rely on having the 'bundle' prop\n const { theming } = appShellConfig;\n if (theming != null) {\n theming.themes = theming.themes?.map(theme => {\n if (startsWithSelf(theme)) {\n const bundleName = replaceSelf(theme);\n return `${selfAppName}/${bundleName}`;\n }\n\n return theme;\n });\n }\n\n finalAppShellConfig = { ...appShellConfig };\n\n // if no baseUrl is present on the configuration, then assume the calculated basePath\n if (!finalAppShellConfig.baseUrl) {\n finalAppShellConfig.baseUrl = basePath;\n }\n\n finalAppShellConfig.apps = undefined;\n // also replace implicit references to selfApp in other parts of the configuration\n if (finalAppShellConfig.providers != null) {\n finalAppShellConfig.providers = replaceReferencesToSelf(\n finalAppShellConfig.providers,\n selfAppName\n );\n }\n\n if (finalAppShellConfig.mainPanel?.views != null) {\n finalAppShellConfig.mainPanel.views = replaceReferencesToSelf(\n finalAppShellConfig.mainPanel.views,\n selfAppName\n ) as HvAppShellViewsConfig[];\n }\n\n if (finalAppShellConfig.header?.actions != null) {\n finalAppShellConfig.header.actions = replaceReferencesToSelf(\n finalAppShellConfig.header?.actions,\n selfAppName\n );\n }\n\n if (!inlineConfig) {\n fs.writeFileSync(\n path.resolve(targetDir, \"app-shell.config.json\"),\n JSON.stringify(finalAppShellConfig)\n );\n }\n },\n\n transformIndexHtml: {\n handler: html => {\n if (!inlineConfig) {\n return undefined;\n }\n\n return {\n html,\n\n tags: [\n {\n tag: \"script\",\n injectTo: \"head-prepend\",\n children: `globalThis.__appshell_config__ = ${\n generateEmptyShell\n ? \"%%APPSHELL_CONFIG%%\"\n : JSON.stringify(finalAppShellConfig ?? appShellConfig)\n };`\n }\n ]\n };\n }\n }\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-crossorigin-fix-plugin.d.ts","sourceRoot":"","sources":["../src/vite-crossorigin-fix-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AASpC,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAuBhE;AA0BD,eAAO,MAAM,UAAU,QAAoB,CAAC;AAC5C,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAA+B,CAAC;AAE5E,eAAO,MAAM,SAAS,QAAe,CAAC;AACtC,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,OAA8B,CAAC;AAKvE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,YA2B5C;AAED,QAAA,MAAM,cAAc,QAAO,YAqC1B,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-crossorigin-fix-plugin.js","sourceRoot":"","sources":["../src/vite-crossorigin-fix-plugin.ts"],"names":[],"mappings":"AAGA,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CACjC,KAAK,CAAC,OAAO,CACX,wCAAwC,EACxC,+BAA+B,CAChC,CAAC;AAEJ,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,IAAY;IAC/D,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAE1E,OAAO,CACL,IAAI;SACD,OAAO;IACN,sCAAsC;IACtC,IAAI,MAAM,CACR,iEAAiE,gBAAgB,uDAAuD,EACxI,IAAI,CACL,EACD,QAAQ,CACT;QACD,mEAAmE;SAClE,OAAO;IACN,uCAAuC;IACvC,IAAI,MAAM,CACR,iJAAiJ,gBAAgB,uDAAuD,EACxN,IAAI,CACL,EACD,QAAQ,CACT,CACJ,CAAC;AACJ,CAAC;AAED,SAAS,aAA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ACnB,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;wBACpD,OAAO,IAAI,CAAC;oBACd,CAAC;oBAED,wFAAwF;oBACxF,yFAAyF;oBAEzF,MAAM,mBAAmB,GAAG,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oBAC9D,IAAI,mBAAmB,IAAI,IAAI,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACpE,OAAO,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;oBACrE,CAAC;oBAED,OAAO,IAAI,CAAC;gBACd,CAAC;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { PluginOption } from \"vite\";\nimport { OutputBundle } from \"rollup\";\n\nconst replacer = (match: string) =>\n match.replace(\n /crossorigin(?!\\s*=\\s*[\"'][^\"']*[\"'])/gi,\n 'crossorigin=\"use-credentials\"'\n );\n\nexport function addUseCredentials(scriptSrc: string, html: string) {\n const escapedScriptSrc = scriptSrc.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n return (\n html\n .replace(\n // src attribute ending with scriptSrc\n new RegExp(\n `<script(?:\\\\s+\\\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\\\s+src=(?:\"[^\"]*${escapedScriptSrc}\"|'[^']*')(?:\\\\s+\\\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\\\s*>`,\n \"gi\"\n ),\n replacer\n )\n // the same for <link rel=\"modulepreload\" crossorigin href=\"\"> tags\n .replace(\n // href attribute ending with scriptSrc\n new RegExp(\n `<link(?:\\\\s+\\\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\\\s+rel=(?:\"modulepreload\"|'modulepreload')(?:\\\\s+\\\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\\\s+href=(?:\"[^\"]*${escapedScriptSrc}\"|'[^']*')(?:\\\\s+\\\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\\\s*>`,\n \"gi\"\n ),\n replacer\n )\n );\n}\n\nfunction processScript(\n bundle: OutputBundle,\n scriptSrc: string,\n html: string,\n seen: Set<string> = new Set()\n) {\n seen.add(scriptSrc);\n\n const script = bundle[scriptSrc];\n if (!script || script.type !== \"chunk\") {\n return html;\n }\n\n let newHtml = addUseCredentials(script.fileName, html);\n\n script.imports.forEach(importedScript => {\n if (!seen.has(importedScript)) {\n newHtml = processScript(bundle, importedScript, newHtml, seen);\n }\n });\n\n return newHtml;\n}\n\nexport const externalRE = /^(https?:)?\\/\\//;\nexport const isExternalUrl = (url: string): boolean => externalRE.test(url);\n\nexport const dataUrlRE = /^\\s*data:/i;\nexport const isDataUrl = (url: string): boolean => dataUrlRE.test(url);\n\nconst isExcludedUrl = (url: string) =>\n url[0] === \"#\" || isExternalUrl(url) || isDataUrl(url);\n\nexport function checkCrossOrigin(html: string) {\n // before the html is transformed, we need to check if any of the\n // entrypoint's scripts that will be bundled have crossorigin=\"use-credentials\"\n\n // search for script tags with crossorigin attribute set to use-credentials\n const scriptTagsWithCors = html.match(\n /<script(?:\\s+\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\s+crossorigin=(?:\"use-credentials\"|'use-credentials')(?:\\s+\\w+(?:=(?:\"[^\"]*\"|'[^']*'))?)*\\s*>/gi\n );\n\n // ignore the script tags that are not modules\n const modulesWithCors = scriptTagsWithCors?.filter(script =>\n /type\\s*=\\s*(?:\"module\"|'module')/i.test(script)\n );\n\n const withCredentials = [];\n if (modulesWithCors != null && modulesWithCors.length !== 0) {\n for (let i = 0; i !== modulesWithCors.length; i += 1) {\n const src = modulesWithCors[i].match(/src=\"([^\"]*)\"|src='([^']*)'/i);\n\n // only take into consideration valid non-external and non-data urls\n if (src != null && !isExcludedUrl(src[1] || src[2])) {\n withCredentials.push(src[1] || src[2]);\n }\n }\n }\n\n return withCredentials;\n}\n\nconst fixCrossOrigin = (): PluginOption => {\n const withCredentials: Record<string, string[]> = {};\n\n return [\n {\n name: \"vite-crossorigin-fix-collect-info-plugin\",\n\n transformIndexHtml: {\n order: \"pre\",\n handler(html, info) {\n withCredentials[info.filename] = checkCrossOrigin(html);\n }\n }\n },\n {\n name: \"vite-crossorigin-fix-replace-plugin\",\n\n transformIndexHtml: {\n order: \"post\",\n handler(html, context) {\n if (context.bundle == null || context.chunk == null) {\n return html;\n }\n\n // it there was at least one script with crossorigin=\"use-credentials\" in the entrypoint\n // we need to add crossorigin=\"use-credentials\" to all the script tags of exported chunks\n\n const toAddUseCredentials = withCredentials[context.filename];\n if (toAddUseCredentials != null && toAddUseCredentials.length !== 0) {\n return processScript(context.bundle, context.chunk.fileName, html);\n }\n\n return html;\n }\n }\n }\n ];\n};\n\nexport default fixCrossOrigin;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-generate-base-plugin.d.ts","sourceRoot":"","sources":["../src/vite-generate-base-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGzE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,uBACF,OAAO,kBACX,gBAAgB,uBAGjC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,cAAc,EAAE,gBAAgB,EAChC,kBAAkB,EAAE,OAAO,GAC1B,YAAY,CAyCd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-generate-base-plugin.js","sourceRoot":"","sources":["../src/vite-generate-base-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,kBAA2B,EAC3B,cAAgC,EAChC,EAAE;IACF,OAAO,kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC;AACzE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,cAAgC,EAChC,kBAA2B;IAE3B,IAAI,QAAgB,CAAC;IACrB,OAAO;QACL,IAAI,EAAE,2BAA2B;QACjC,MAAM,CAAC,MAAM;YACX,QAAQ,GAAG,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;gBAC1B,IAAI,EACF,kBAAkB,IAAI,cAAc,CAAC,IAAI,IAAI,IAAI;oBAC/C,CAAC,CAAC,IAAI,CAAC,OAAO,CACV,uBAAuB,EACvB,UAAU,WAAW,CACnB,kBAAkB,EAClB,cAAc,CACf,UAAU,CACZ;oBACH,CAAC,CAAC,IAAI;gBACV,IAAI,EAAE;oBACJ;wBACE,GAAG,EAAE,MAAM;wBACX,KAAK,EAAE;4BACL,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,QAAQ;yBAC1D;wBACD,QAAQ,EAAE,cAAc;qBACzB;oBACD;wBACE,GAAG,EAAE,MAAM;wBACX,QAAQ,EAAE,cAAc;wBACxB,KAAK,EAAE;4BACL,GAAG,EAAE,SAAS;4BACd,EAAE,EAAE,OAAO;4BACX,IAAI,EAAE,mBAAmB;yBAC1B;qBACF;iBACF;aACF,CAAC;SACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\nimport { getBasePath } from \"./config-utils.js\";\n\n/**\n * Calculate the App title, It applies the following rules to calculate the final value\n * - If we are generating an empty App Shell, it returns the value “%%APPSHELL_TITLE%%.”\n * - Otherwise, it returns the value of the configuration name property.\n * @param generateEmptyShell flag to control if we are generating an empty App Shell instance\n * @param appShellConfig App shell config values\n * @returns The app title\n */\nexport const getAppTitle = (\n generateEmptyShell: boolean,\n appShellConfig: HvAppShellConfig\n) => {\n return generateEmptyShell ? \"%%APPSHELL_TITLE%%\" : appShellConfig.name;\n};\n\n/**\n * Add the <BASE> tag and icons preload in the index.html file.\n * @param appShellConfig The app shell configuration.\n * @param generateEmptyShell Flag that controls if an empty app shell application is created with tags instead of final values\n */\nexport default function generateBaseTag(\n appShellConfig: HvAppShellConfig,\n generateEmptyShell: boolean\n): PluginOption {\n let basePath: string;\n return {\n name: \"vite-plugin-generate-base\",\n config(config) {\n basePath = getBasePath(appShellConfig.baseUrl, config.base);\n },\n transformIndexHtml: {\n order: \"post\",\n handler: (html: string) => ({\n html:\n generateEmptyShell || appShellConfig.name != null\n ? html.replace(\n /<title>(.*?)<\\/title>/,\n `<title>${getAppTitle(\n generateEmptyShell,\n appShellConfig\n )}</title>`\n )\n : html,\n tags: [\n {\n tag: \"base\",\n attrs: {\n href: generateEmptyShell ? \"%%APPSHELL_BASE%%\" : basePath\n },\n injectTo: \"head-prepend\"\n },\n {\n tag: \"link\",\n injectTo: \"head-prepend\",\n attrs: {\n rel: \"preload\",\n as: \"image\",\n href: \"./icons/icons.svg\"\n }\n }\n ]\n })\n }\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-generate-bash-script-plugin.d.ts","sourceRoot":"","sources":["../src/vite-generate-bash-script-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,MAAM,CAAC;AAKzD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,iBAAiB,EAAE,OAAO,EAC1B,YAAY,EAAE,OAAO,GACpB,YAAY,CAuId"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-generate-bash-script-pl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AAE,EAAE,CAAC,MAAM,QAAQ,oBAAoB,MAAM,MAAM,CACzE,CAAC,IAAI,CAAC,EAAE,CAAC;;;;;;+BAMe,0BAA0B,EAAE;;EAGzD,iBAAiB;gBACf,CAAC,CAAC;mKAC6J;gBAC/J,CAAC,CAAC;iGAEN;;EAGE,YAAY;gBACV,CAAC,CAAC;;;;;4BAKsB;gBACxB,CAAC,CAAC;;GAGN;CACC,CAAC;YAEI,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAU,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE;gBAC9D,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PluginOption, ResolvedConfig } from \"vite\";\n\nimport SHARED_DEPENDENCIES from \"./shared-dependencies.js\";\nimport { getExtraDependenciesString } from \"./vite-importmap-plugin.js\";\n\nexport default function generateBashScript(\n externalImportMap: boolean,\n inlineConfig: boolean\n): PluginOption {\n let config: ResolvedConfig;\n let targetDir: string | undefined;\n\n return {\n name: \"vite-plugin-generate-bash-script\",\n apply: \"build\",\n\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n targetDir = path.resolve(resolvedConfig.root, \"scripts\");\n\n if (!targetDir) {\n throw new Error(\n \"Please set outputPath, so we can know where to place the bash script file\"\n );\n }\n\n // create the targetDir if it does not exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n },\n closeBundle() {\n if (config.command === \"serve\") {\n return;\n }\n\n const script = `#!/bin/bash\nset -e\nset -o pipefail\n\n# This script is generated by @hitachivantara/app-shell-vite-plugin.\n# Do not edit this file directly.\n\n# This script will read the app-shell.config.json file and generate the importmap.\n\n${\n externalImportMap\n ? \"# The script will generate the importmap.js file.\"\n : \"# The importmap will be inlined in the index.html file, by replacing the %%APPSHELL_IMPORTMAP%% placeholder.\"\n}\n${\n inlineConfig\n ? \"# The config file will be inlined in the index.html file, by replacing the %%APPSHELL_CONFIG%% placeholder.\"\n : \"# The config will be saved as app-shell.config.json.\"\n}\n\n# Check if the index.html file exists in the current directory, otherwise exit:\nif [ ! -f index.html ]; then\n echo \"index.html file not found. Are you running this script in the correct directory?\" >&2\n exit 1\nfi\n\nCONFIG_FILE=\\${1:-app-shell.config.json}\n\n# Check if the config file exists, otherwise exit:\nif [ ! -f \"\\${CONFIG_FILE}\" ]; then\n echo \"Config file not found: \\${CONFIG_FILE}\" >&2\n exit 1\nfi\n\nSCRIPT_DIR=\"$(cd \"$(dirname \"\\${BASH_SOURCE[0]}\")\" && pwd)\"\nINDEX_HTML_ORIGINAL=\"\\${SCRIPT_DIR}/index.html.original\"\n\n# If the index.html doesn't contain any %%APPSHELL_*%% placeholders, copy the index.html.original at the script location:\nif ! grep -q \"%%APPSHELL_\" index.html; then\n if [ -f \"\\${INDEX_HTML_ORIGINAL}\" ]; then\n cp \"\\${INDEX_HTML_ORIGINAL}\" index.html\n fi\nelse\n # Backup the index.html file to index.html.original, in the current script folder:\n cp index.html \"\\${INDEX_HTML_ORIGINAL}\"\nfi\n\n# Reading the app-shell.config.json file:\nCONFIG=$(cat \"\\${CONFIG_FILE}\")\n\n# Getting the title from the config \"name\" property:\nTITLE=$(echo \"\\${CONFIG}\" | jq -r '.name')\nif [ -z \"\\${TITLE}\" ] || [ \"\\${TITLE}\" = \"null\" ] || [ \"\\${TITLE}\" = \"undefined\" ]; then\n TITLE=\"Hitachi Vantara\"\nfi\n\n# Replacing the title placeholder in the index.html file:\nsed -i.bak \"s/%%APPSHELL_TITLE%%/\\${TITLE//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak\n\n# Getting the baseUrl from the config \"baseUrl\" property:\nSELF_BASEURL=$(echo \"\\${CONFIG}\" | jq -r '.baseUrl')\nif [ -z \"\\${SELF_BASEURL}\" ] || [ \"\\${SELF_BASEURL}\" = \"null\" ] || [ \"\\${SELF_BASEURL}\" = \"undefined\" ]; then\n SELF_BASEURL=\"/\"\nfi\n\n# Replace the base placeholder in the index.html file:\nsed -i.bak \"s/%%APPSHELL_BASE%%/\\${SELF_BASEURL//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak\n\n# Generating the importmap:\n# for each app, we add a mapping from the app id to the app url\nIMPORTMAP=\"{\\\\\"imports\\\\\":{${SHARED_DEPENDENCIES.map(\n ({ moduleId, bundle }) => `\\\\\"${moduleId}\\\\\":\\\\\"./bundles/${bundle}\\\\\",`\n ).join(\"\")}\"\nwhile IFS= read -r line; do\n id=$(echo \"$line\" | jq -r '.key')\n baseUrl=$(echo \"$line\" | jq -r '.value')\n IMPORTMAP=\"\\${IMPORTMAP}\\\\\"\\${id}/\\\\\":\\\\\"\\${baseUrl}\\\\\",\"\ndone < <(echo \"\\${CONFIG}\" | jq -c '.apps | to_entries[]')\nIMPORTMAP=\"\\${IMPORTMAP%?}, ${getExtraDependenciesString()} }}\"\n\n${\n externalImportMap\n ? `# Generating the importmap.js file:\necho \"const im = document.createElement('script'); im.type = 'importmap'; im.textContent = \\\\\\`\\${IMPORTMAP}\\\\\\`; document.currentScript.after(im);\" >importmap.js`\n : `# Inlining the importmap in the index.html file:\nsed -i.bak \"s/%%APPSHELL_IMPORTMAP%%/\\${IMPORTMAP//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak`\n}\n\n${\n inlineConfig\n ? `# Inlining the config in the index.html file:\nCONFIG=$(echo \"\\${CONFIG}\" | tr -d '\\\\n')\nsed -i.bak \"s/%%APPSHELL_CONFIG%%/\\${CONFIG//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak\n\n# Removing the config file, just in case:\nrm -f app-shell.config.json`\n : `if [ \"\\${CONFIG_FILE}\" != \"app-shell.config.json\" ]; then\n echo \"\\${CONFIG}\" >app-shell.config.json\nfi`\n}\n`;\n\n fs.writeFileSync(path.join(targetDir!, \"app-shell.sh\"), script, {\n encoding: \"utf-8\"\n });\n }\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-importmap-plugin.d.ts","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAMzC,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAEpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAO,MAQ7C,CAAC;AA4CF;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,EAAE,EAC5B,iBAAiB,UAAQ,EACzB,qBAAqB,UAAQ,GAC5B,YAAY,CAiLd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-importmap-plugin.js","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACvD,kBAAkB,EAAE,UAAU;CAC/B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAW,EAAE;IACrD,IAAI,uBAAuB,GAAG,EAAE,CAAC;IACjC,8DAA8D;IAC9D,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACpC,uBAAuB,IAAI,MAAM,GAAG,WAAW,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC;IAC9E,CAAC;IACD,uBAAuB,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/D,OAAO,uBAAuB,CAAC;AACjC,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I,EAAE,CAAC,CAAC;gBAC/C,CAAC;gBAED,wGAAwG;gBACxG,qFAAqF;gBACrF,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EACvC,eAAe,CAChB,CAAC;YACJ,CAAC;YAED,kEAAkE;YAClE,kBAAkB,EAAE;gBAClB,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;oBAChB,IAAI;oBACJ,IAAI,EAAE;wBACJ;4BACE,GAAG,EAAE,QAAQ;4BACb,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,8BAA8B,EAAE;4BAC3D,QAAQ,EAAE,cAAc;yBACzB;wBACD,iBAAiB;4BACf,CAAC,CAAC;gCACE,GAAG,EAAE,QAAQ;gCACb,KAAK,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;gCAChC,QAAQ,EAAE,cAAc;6BACzB;4BACH,CAAC,CAAC;gCACE,GAAG,EAAE,QAAQ;gCACb,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;gCAC5B,QAAQ,EAAE,cAAc;gCACxB,QAAQ,EAAE,qBAAqB;oCAC7B,CAAC,CAAC,wBAAwB;oCAC1B,CAAC,CAAC,eAAe;6BACpB;qBACN;iBACF,CAAC;aACH;SACF;QACD,iBAAiB;YACf,CAAC,CAAC,OAAO,CAAC;gBACN,eAAe,EAAE,eAAe;aACjC,CAAC;YACJ,CAAC,CAAC,KAAK;KACV,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport type { NormalizedOutputOptions } from \"rollup\";\nimport type { PluginOption } from \"vite\";\n\nimport virtual from \"@rollup/plugin-virtual\";\n\nconst ID_PREFIX = `/@id/`;\n\nexport const extraDependencies: Record<string, string> = {\n \"@hv/uikit-icons/\": \"./icons/\"\n};\n\n/**\n * Auxiliary function to get the extraDependencies string\n * @returns a string with the extraDependencies content separated by commas\n */\nexport const getExtraDependenciesString = (): string => {\n let extraDependenciesString = \"\";\n // eslint-disable-next-line no-restricted-syntax, guard-for-in\n for (const key in extraDependencies) {\n extraDependenciesString += `\\\\\"${key}\\\\\": \\\\\"${extraDependencies[key]}\\\\\",`;\n }\n extraDependenciesString = extraDependenciesString.slice(0, -1);\n return extraDependenciesString;\n};\n\nfunction replaceIdPrefix(\n keys: (string | RegExp)[],\n packageName: string\n): PluginOption {\n const reg = new RegExp(\n `(/${packageName})?${ID_PREFIX}(${keys.join(\"|\")})`,\n \"g\"\n );\n\n return {\n name: \"vite-plugin-importmap-replace-idprefix\",\n enforce: \"pre\",\n apply: \"serve\",\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n transform: code =>\n reg.test(code) ? code.replace(reg, (m, s1, s2) => s2) : code,\n\n // and to say its resolved (as external)\n resolveId: (id: string) =>\n keys.some(key =>\n typeof key === \"string\" ? id.startsWith(key) : key.test(id)\n )\n ? {\n id,\n external: true\n }\n : undefined,\n\n // Avoid the warning: The following dependencies are imported but could not be resolved: [dependency] (imported by [sourceFile])\n load: (id: string) => {\n if (keys.includes(id)) {\n // Vite will try to resolve the modules even when externalized\n // In order to suppress the warning, a stub module is returned\n return \"export default {};\";\n }\n\n return undefined;\n }\n };\n}\n\n/**\n * Generate and injects the importmap tag into index.html\n * @param importmapElements The importmap elements to be included\n * @param packageName The application name identifier\n * @param sharedDependencies The shared packages (other than application bundles)\n * @param externalImportMap Flag to control if the importmap should be externalized\n * @param placeholderEntryPoint Flag to control if the importmap should be a placeholder\n */\nexport default function generateImportmap(\n importmapElements: Record<string, string>,\n packageName: string,\n sharedDependencies: string[],\n externalImportMap = false,\n placeholderEntryPoint = false\n): PluginOption {\n const keys = Object.keys(importmapElements);\n const devKeys = keys.filter(\n key => !sharedDependencies.some(lib => lib.startsWith(key))\n );\n\n let devMode = false;\n\n const importmapString = JSON.stringify(\n { imports: importmapElements },\n null,\n 2\n );\n\n const importmapScript = `const im = document.createElement('script');\nim.type = 'importmap';\nim.textContent = \\`${importmapString}\\`;\ndocument.currentScript.after(im);\n`;\n\n return [\n {\n name: \"vite-plugin-importmap\",\n enforce: \"pre\",\n\n // don't optimize / pre-transform deps that are in the importmap\n // except for react and react-dom when in dev mode\n config(config, { command }) {\n devMode = command !== \"build\";\n\n // vite docs says we can mutate the passed-in config directly\n // assigning to a new variable just to avoid the eslint warning\n const returnValue = config;\n\n // make sure optimizeDeps is defined\n returnValue.optimizeDeps = returnValue.optimizeDeps ?? {};\n\n returnValue.optimizeDeps.exclude = [\n ...(config.optimizeDeps?.exclude ?? []),\n ...(devMode ? devKeys : keys)\n ];\n\n if (devMode) {\n return;\n }\n\n // mark the modules referenced in the importmap as external\n const excludedModules = keys.map(key => {\n if (key.endsWith(\"/\")) {\n return new RegExp(`^${key}.*`);\n }\n\n return key;\n });\n\n console.info(\"Shared packages marked as external: \", excludedModules);\n\n // make sure build's rollupOptions is defined\n returnValue.build = returnValue.build ?? {};\n returnValue.build.rollupOptions = returnValue.build.rollupOptions ?? {};\n returnValue.build.rollupOptions.external =\n returnValue.build.rollupOptions.external ?? [];\n\n if (typeof returnValue.build.rollupOptions.external === \"function\") {\n // in case the developer has defined a custom external function\n // we wrap it and check our excluded modules first and call the original function if needed\n const originalExternal = returnValue.build.rollupOptions.external;\n\n returnValue.build.rollupOptions.external = (id, ...args) => {\n if (excludedModules.some(m => m === id)) {\n return true;\n }\n\n return originalExternal(id, ...args);\n };\n } else {\n // otherwise we just add our excluded modules to the list supplied by the developer\n const externalModules: (string | RegExp)[] = [];\n\n if (Array.isArray(returnValue.build.rollupOptions.external)) {\n externalModules.push(...returnValue.build.rollupOptions.external);\n } else {\n externalModules.push(returnValue.build.rollupOptions.external);\n }\n\n externalModules.push(...excludedModules);\n\n returnValue.build.rollupOptions.external = externalModules;\n }\n },\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n // and also to say they're resolved (as external)\n // (it will still output an error in the console, but it won't break)\n // known issue: https://github.com/vitejs/vite/issues/11633\n configResolved(resolvedConfig) {\n if (!devMode) {\n return;\n }\n\n // @ts-expect-error an hack: we want to add the plugin only after the config is resolved\n resolvedConfig.plugins.push(replaceIdPrefix(devKeys, packageName));\n },\n\n /**\n * Rollup hook with the info for bundle generation\n * It will be used to create a new configuration with:\n * - bundles replace with the final location (e.g. -> \"bundle\": \"src/pages/Main\" transformed to \"bundle\": \"pages/Main.js\",\n * @param options build options\n */\n async generateBundle(options: NormalizedOutputOptions) {\n if (!externalImportMap || placeholderEntryPoint) {\n return;\n }\n\n // obtain the directory (dist) where the new config file will be placed\n let targetDir: string | undefined;\n if (options.dir) {\n targetDir = options.dir;\n } else if (options.file) {\n targetDir = path.dirname(options.file);\n }\n\n if (!targetDir) {\n throw new Error(\n \"Please set outputPath, so we can know where to place the json file\"\n );\n }\n\n // create the targetDir if it does not exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n\n // support for external import maps isn't yet available (https://github.com/WICG/import-maps/issues/235)\n // workaround: https://github.com/WICG/import-maps/issues/235#issuecomment-1002340944\n fs.writeFileSync(\n path.resolve(targetDir, \"importmap.js\"),\n importmapScript\n );\n },\n\n // inject the importmap script and also the es-module-shims script\n transformIndexHtml: {\n order: \"post\",\n handler: html => ({\n html,\n tags: [\n {\n tag: \"script\",\n attrs: { async: true, src: \"./bundles/es-module-shims.js\" },\n injectTo: \"head-prepend\"\n },\n externalImportMap\n ? {\n tag: \"script\",\n attrs: { src: \"./importmap.js\" },\n injectTo: \"head-prepend\"\n }\n : {\n tag: \"script\",\n attrs: { type: \"importmap\" },\n injectTo: \"head-prepend\",\n children: placeholderEntryPoint\n ? \"%%APPSHELL_IMPORTMAP%%\"\n : importmapString\n }\n ]\n })\n }\n },\n externalImportMap\n ? virtual({\n \"/importmap.js\": importmapScript\n })\n : false\n ];\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-metadata-plugin.d.ts","sourceRoot":"","sources":["../src/vite-metadata-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAUzC;;;;GAIG;AACH,QAAA,MAAM,cAAc,QAAO,YA8B1B,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-metadata-plugin.js","sourceRoot":"","sources":["../src/vite-metadata-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,eAAuB,EAAU,EAAE;IACzD,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,aAAa,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,GAAiB,EAAE;IACxC,MAAM,iBAAiB,GAAG,cAAc,CACtC,aAAa,CAAC,2CAA2C,CAAC,CAC3D,CAAC;IAEF,MAAM,yBAAyB,GAAG,cAAc,CAC9C,aAAa,CAAC,oDAAoD,CAAC,CACpE,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,kBAAkB;YAChB,OAAO;gBACL;oBACE,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,sBAAsB;wBAC5B,OAAO,EAAE,iBAAiB;qBAC3B;iBACF;gBACD;oBACE,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,+BAA+B;wBACrC,OAAO,EAAE,yBAAyB;qBACnC;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import fs from \"fs\";\n\nimport type { PluginOption } from \"vite\";\n\nimport { resolveModule } from \"./nodeModule.js\";\n\nconst extractVersion = (packageJsonFile: string): string => {\n const packageJson = fs.readFileSync(packageJsonFile, \"utf8\");\n const packageObject = JSON.parse(packageJson);\n return packageObject.version;\n};\n\n/**\n * This plugin injects metadata into the index.html file.\n * The metadata is used to help any troubleshoot activity by referencing\n * the version of the app-shell-vite-plugin and app-shell-ui packages used by the app.\n */\nconst injectMetadata = (): PluginOption => {\n const appShellUIVersion = extractVersion(\n resolveModule(\"@hitachivantara/app-shell-ui/package.json\")\n );\n\n const appShellVitePluginVersion = extractVersion(\n resolveModule(\"@hitachivantara/app-shell-vite-plugin/package.json\")\n );\n\n return {\n name: \"vite-metadata-plugin\",\n transformIndexHtml() {\n return [\n {\n tag: \"meta\",\n attrs: {\n name: \"app-shell-ui-version\",\n content: appShellUIVersion\n }\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"app-shell-vite-plugin-version\",\n content: appShellVitePluginVersion\n }\n }\n ];\n }\n };\n};\n\nexport default injectMetadata;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AAc7C,OAAO,EACL,iBAAiB,EAIlB,MAAM,mBAAmB,CAAC;AAc3B,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAE7B;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAA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AAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;oBAC/C,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,KAAK,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC;oBAC7D,OAAO,GAAG,CAAC;gBACb,CAAC,EACD,EAA4B,CAC7B;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,EACD,WAAW,CAAC,IAAI,EAChB,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,EACnE,iBAAiB,IAAI,eAAe,EACpC,kBAAkB,CACnB;QAED,4CAA4C;QAC5C,eAAe,IAAI,cAAc,EAAE;QAEnC,2DAA2D;QAC3D,eAAe;YACb,eAAe,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;QAE5D,uDAAuD;QACvD,oBAAoB,CAClB,IAAI,EACJ,qBAAqB,EACrB,WAAW,CAAC,IAAI,EAChB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACjC;QAED,wDAAwD;QACxD,cAAc,EAAE;QAEhB,gEAAgE;QAChE,mBAAmB,CACjB,qBAAqB,EACrB,IAAI,EACJ,WAAW,CAAC,IAAI,EAChB,kBAAkB,EAClB,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAC7C;QAED,0EAA0E;QAC1E,kBAAkB,IAAI,kBAAkB,CAAC,iBAAiB,EAAE,YAAY,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport virtual from \"@rollup/plugin-virtual\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\n\nimport { loadEnv, PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap, {\n extraDependencies\n} from \"./vite-importmap-plugin.js\";\nimport processConfiguration from \"./vite-configuration-processor-plugin.js\";\nimport generateBaseTag from \"./vite-generate-base-plugin.js\";\nimport injectMetadata from \"./vite-metadata-plugin.js\";\nimport serveAppShellConfig from \"./vite-watch-config-plugin.js\";\nimport generateBashScript from \"./vite-generate-bash-script-plugin.js\";\nimport fixCrossOrigin from \"./vite-crossorigin-fix-plugin.js\";\n\nimport {\n ConfigReplacement,\n findAppShellConfigFile,\n getFinalModuleName,\n loadConfigFile\n} from \"./config-utils.js\";\nimport { getModulePath, resolveModule } from \"./nodeModule.js\";\nimport {\n applyAutomaticMenu,\n applyAutomaticViewsAndRoutes\n} from \"./automatic-utils.js\";\nimport getVirtualEntrypoints from \"./virtual-entrypoints.js\";\nimport SHARED_DEPENDENCIES from \"./shared-dependencies.js\";\n\nenum ViteBuildMode {\n PRODUCTION = \"production\",\n DEVELOPMENT = \"development\"\n}\n\nexport type ApplicationBundleType = \"app\" | \"bundle\";\n\nexport interface AppShellVitePluginOptions {\n /**\n * Project root directory. Most likely the location of the vite config file.\n *\n * @default process.cwd()\n */\n root?: string;\n /**\n * Execution mode.\n */\n mode?: string;\n\n /**\n * Type of application bundle being built. Can be \"app\" or \"bundle\".\n *\n * - \"app\": The application bundle includes both the index.html entry point and the exported modules.\n * - \"bundle\": The application bundle will not include the index.html entry point.\n *\n * @default \"app\"\n */\n type?: ApplicationBundleType;\n\n /** Array of tokens that are replaced at app-shell.config.json during the build of the solution.\n * e.g.\n * {\n * token: \"USER_NOTIFICATIONS_URL\",\n * value: \"http://localhost:8080\"\n * }\n * Tokens used at config file must be wrapped (at the beginning and at the end) by @@ sequence\n * e.g.\n * {\n * \"@hv/user-notifications-client\": \"@@USER_NOTIFICATIONS_URL@@\"\n * }\n */\n configReplacements?: ConfigReplacement[];\n\n /**\n * The folder containing Views to be shared as Shared Modules. Defaults to \"src/pages\".\n *\n * The folder path must be relative to the project root (e.g. \"src/pages\").\n */\n viewsFolder?: string;\n /**\n * If set, the plugin will search for Views at the folder specified by `viewsFolder` and will add them to the App Shell configuration as views.\n * The views' modules will be exported accordingly, and a route will be created from the folder structure.\n * Dynamic route parameters are supported by prefixing the folder name with a $ (e.g. \"src/pages/List/$id/index.tsx\" will be configured as \"/list/:id\").\n */\n autoViewsAndRoutes?: boolean;\n /**\n * If true, the plugin will try to automatically add the views to the menu.\n * Any menu defined in the App Shell config file will be overwritten.\n */\n autoMenu?: boolean;\n\n /**\n * If true, the plugin will generate the importmap with an external js file instead of inline in the html.\n * The map will be saved at the root of the application destination dir and named as \"importmap.js\".\n *\n * This option is not for general use. It is only intended to be used for easing the automated testing of the App Shell.\n *\n * @default false\n * @private\n */\n externalImportMap?: boolean;\n /**\n * If true, the plugin will inline the app-shell.config.json file in a script tag of the index html.\n *\n * This option is not for general use. Its value will be automatically managed by the App Shell build process.\n *\n * @default false, true if generateEmptyShell is true\n * @private\n */\n inlineConfig?: boolean;\n /**\n * If true, the config file is ignored, only the App Shell is built and the generated index.html will contain a placeholders\n * for importmap (if externalImportMap is false), app shell config (if inlineConfig is true) and title.\n *\n * A bash script will also be added to the dist folder to replace the placeholders with the actual content,\n * when provided with a concrete configuration.\n *\n * This option is not for general use. It is used for generating the App Shell container image.\n *\n * @default false\n * @private\n */\n generateEmptyShell?: boolean;\n /**\n * The modules to be exported by the application.\n *\n * All the modules that the application need to export should be declared here in order to have them built properly.\n *\n */\n modules?: string[];\n}\n\n/**\n * Vite plugin to support App Shell apps setup\n * @param opts Plugin options\n * @param env Environment variable\n */\nfunction appShellVitePlugin(\n opts: AppShellVitePluginOptions = {},\n env: Record<string, string> = {}\n): PluginOption {\n const {\n root = process.cwd(),\n mode = ViteBuildMode.PRODUCTION,\n externalImportMap = false,\n viewsFolder = \"src/pages\",\n autoViewsAndRoutes = false,\n autoMenu = false,\n inlineConfig = opts.generateEmptyShell ?? false,\n generateEmptyShell = false,\n modules = []\n } = opts;\n\n const globalEnv = loadEnv(mode, process.cwd(), \"\");\n\n const { type = globalEnv.CI ? \"bundle\" : \"app\" } = opts;\n\n console.info(`Vite running in mode: ${mode}`);\n console.info(`AppShell Vite plugin running with type: ${type}`);\n\n const devMode = mode === ViteBuildMode.DEVELOPMENT;\n const buildEntryPoint = type !== \"bundle\";\n\n const packageJsonRaw = fs.readFileSync(\n path.resolve(root, \"package.json\"),\n \"utf-8\"\n );\n const packageJson = JSON.parse(packageJsonRaw);\n\n const appShellConfigFile = !generateEmptyShell\n ? findAppShellConfigFile(root)\n : undefined;\n const appShellConfiguration: HvAppShellConfig = loadConfigFile(\n appShellConfigFile,\n opts,\n env\n );\n\n let autoViewsBundles: string[] = [];\n\n if (!generateEmptyShell) {\n if (autoViewsAndRoutes) {\n autoViewsBundles = applyAutomaticViewsAndRoutes(\n appShellConfiguration,\n packageJson.name,\n root,\n viewsFolder\n );\n }\n\n if (autoMenu) {\n applyAutomaticMenu(appShellConfiguration);\n }\n }\n\n return [\n // copy the shared dependencies js bundles to the \"bundles\" folder\n (buildEntryPoint || devMode) &&\n viteStaticCopy({\n targets: [\n {\n src: getModulePath(\"es-module-shims\", \"dist/*\"),\n dest: \"bundles\"\n },\n // copy the ui kit icons' sprites to the \"icons\" folder\n {\n src: [\n getModulePath(\n \"@hitachivantara/uikit-react-icons\",\n \"dist/sprites/*.svg\"\n )\n ],\n dest: \"icons\"\n },\n ...(!devMode && buildEntryPoint\n ? [\n {\n src: SHARED_DEPENDENCIES.flatMap(dep => {\n const module = resolveModule(dep.bundleSrc);\n try {\n return [module, resolveModule(`${dep.bundleSrc}.map`)];\n } catch {\n return [module];\n }\n }),\n dest: \"bundles\"\n }\n ]\n : [])\n ]\n }),\n\n // create virtual endpoints for shell code and for shared dependencies\n virtual({\n ...getVirtualEntrypoints(inlineConfig),\n\n ...SHARED_DEPENDENCIES.reduce(\n (acc, dep) => {\n acc[`/bundles/${dep.bundle}`] = dep.virtualSrc;\n return acc;\n },\n {} as Record<string, string>\n )\n }),\n\n // generate the importmap for shared dependencies and for apps referenced in the config file\n generateImportmap(\n {\n ...SHARED_DEPENDENCIES.reduce(\n (acc, dep) => {\n acc[dep.moduleId] = `./bundles/${dep.bundle}`;\n return acc;\n },\n {} as Record<string, string>\n ),\n\n ...extraDependencies,\n\n ...Object.entries(appShellConfiguration?.apps ?? {}).reduce(\n (acc, [key, value]) => {\n acc[`${key}/`] = value;\n return acc;\n },\n {} as Record<string, string>\n ),\n\n [`${packageJson.name}/`]: \"./\",\n\n ...(devMode\n ? modules.concat(autoViewsBundles).reduce(\n (acc, module) => {\n const finalModule = getFinalModuleName(module);\n acc[`${packageJson.name}/${finalModule}.js`] = `./${module}`;\n return acc;\n },\n {} as Record<string, string>\n )\n : {})\n },\n packageJson.name,\n [...SHARED_DEPENDENCIES.map(dep => dep.moduleId), packageJson.name],\n externalImportMap && buildEntryPoint,\n generateEmptyShell\n ),\n\n // inject version metadata in the index.html\n buildEntryPoint && injectMetadata(),\n\n // set the base tag and replace the title in the index.html\n buildEntryPoint &&\n generateBaseTag(appShellConfiguration, generateEmptyShell),\n\n // configure the build process based on the config file\n processConfiguration(\n root,\n appShellConfiguration,\n packageJson.name,\n buildEntryPoint,\n inlineConfig,\n generateEmptyShell,\n modules.concat(autoViewsBundles)\n ),\n\n // allow crossorigin=\"use-credentials\" in the index.html\n fixCrossOrigin(),\n\n // serve the app shell config file as json and watch for changes\n serveAppShellConfig(\n appShellConfiguration,\n root,\n packageJson.name,\n appShellConfigFile,\n autoViewsAndRoutes ? viewsFolder : undefined\n ),\n\n // generate the shell script to replace the placeholders in the index.html\n generateEmptyShell && generateBashScript(externalImportMap, inlineConfig)\n ];\n}\n\nexport default appShellVitePlugin;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-watch-config-plugin.d.ts","sourceRoot":"","sources":["../src/vite-watch-config-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE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AAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC,CAAC;YAEF,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC/B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;gBACvC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;YAC7C,CAAC;YAED,IAAI,oBAAoB,IAAI,IAAI,EAAE,CAAC;gBACjC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC;gBAC7D,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;gBAC5C,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;YAC3C,CAAC;YAED,MAAM,CAAC,WAAW,CAAC,GAAG,CACpB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,uBAAuB,EAC5C,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;gBACjB,GAAG,CAAC,GAAG,CACL,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CACrE,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import path from \"path\";\n\nimport type { PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport { require } from \"./nodeModule.js\";\nimport { replaceReferencesToSelf } from \"./vite-configuration-processor-plugin.js\";\nimport { replaceSelf } from \"./config-utils.js\";\n\nconst prepareConfigForDevMode = (\n config: HvAppShellConfig,\n selfAppName: string\n) => {\n const { mainPanel, header, theming, providers } = config;\n const replacedConfig: HvAppShellConfig = {\n ...config\n };\n const self = `${selfAppName}/`;\n // Main panel - Views\n if (mainPanel?.views && replacedConfig.mainPanel) {\n replacedConfig.mainPanel.views = replaceReferencesToSelf(\n mainPanel.views,\n selfAppName\n );\n }\n // Header - Actions\n if (header?.actions && replacedConfig.header) {\n replacedConfig.header.actions = replaceReferencesToSelf(\n header.actions,\n selfAppName\n );\n }\n // Theming\n if (theming?.themes && replacedConfig.theming) {\n replacedConfig.theming.themes = theming.themes?.map(theme => {\n return replaceSelf(theme, self);\n });\n }\n // Providers\n if (providers) {\n replacedConfig.providers = replaceReferencesToSelf(providers, selfAppName);\n }\n\n return replacedConfig;\n};\n\nexport default function serveAppShellConfig(\n appShellConfig: HvAppShellConfig,\n root: string,\n selfAppName: string,\n appShellConfigFile?: string,\n automaticViewsFolder?: string\n): PluginOption {\n return {\n name: \"vite-plugin-watch-app-shell-config\",\n apply: \"serve\",\n\n configureServer(server) {\n const restartServer = (file: string) => {\n if (appShellConfigFile != null && file.endsWith(appShellConfigFile)) {\n console.info(\"App Shell configuration file changed. Reloading...\");\n delete require.cache[require.resolve(appShellConfigFile)];\n server\n .restart()\n .catch(e => console.error(`Restart failed with: ${e}`));\n }\n };\n\n const restartServer2 = (file: string) => {\n if (automaticViewsFolder != null && /\\/index\\.[tj]sx?$/.exec(file)) {\n console.info(\"Automatic views folder changed. Reloading...\");\n server\n .restart()\n .catch(e => console.error(`Restart failed with: ${e}`));\n }\n };\n\n if (appShellConfigFile != null) {\n server.watcher.add(appShellConfigFile);\n server.watcher.on(\"change\", restartServer);\n }\n\n if (automaticViewsFolder != null) {\n server.watcher.add(path.resolve(root, automaticViewsFolder));\n server.watcher.on(\"unlink\", restartServer2);\n server.watcher.on(\"add\", restartServer2);\n }\n\n server.middlewares.use(\n `${server.config.base}app-shell.config.json`,\n async (req, res) => {\n res.end(\n JSON.stringify(prepareConfigForDevMode(appShellConfig, selfAppName))\n );\n }\n );\n }\n };\n}\n"]}