@equinor/fusion-framework-cli 8.1.0 → 9.0.0

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 (133) hide show
  1. package/CHANGELOG.md +109 -2
  2. package/README.md +78 -0
  3. package/bin/cli.mjs +1 -4
  4. package/dist/bin/build-application.js +44 -0
  5. package/dist/bin/build-application.js.map +1 -0
  6. package/dist/bin/bundle-application.js +55 -0
  7. package/dist/bin/bundle-application.js.map +1 -0
  8. package/dist/bin/create-dev-serve.js +117 -0
  9. package/dist/bin/create-dev-serve.js.map +1 -0
  10. package/dist/bin/create-export-config.js +51 -0
  11. package/dist/bin/create-export-config.js.map +1 -0
  12. package/dist/bin/create-export-manifest.js +60 -0
  13. package/dist/bin/create-export-manifest.js.map +1 -0
  14. package/dist/bin/dev-portal/AppLoader.js +54 -0
  15. package/dist/bin/dev-portal/AppLoader.js.map +1 -0
  16. package/dist/bin/dev-portal/BookMarkSideSheet.js +15 -0
  17. package/dist/bin/dev-portal/BookMarkSideSheet.js.map +1 -0
  18. package/dist/bin/dev-portal/ContextSelector.js +107 -0
  19. package/dist/bin/dev-portal/ContextSelector.js.map +1 -0
  20. package/dist/bin/dev-portal/EquinorLoader.js +14 -0
  21. package/dist/bin/dev-portal/EquinorLoader.js.map +1 -0
  22. package/dist/bin/dev-portal/ErrorViewer.js +7 -0
  23. package/dist/bin/dev-portal/ErrorViewer.js.map +1 -0
  24. package/dist/bin/dev-portal/FusionLogo.js +4 -0
  25. package/dist/bin/dev-portal/FusionLogo.js.map +1 -0
  26. package/dist/bin/dev-portal/Header.js +31 -0
  27. package/dist/bin/dev-portal/Header.js.map +1 -0
  28. package/dist/bin/dev-portal/Router.js +46 -0
  29. package/dist/bin/dev-portal/Router.js.map +1 -0
  30. package/dist/bin/dev-portal/config.js +45 -0
  31. package/dist/bin/dev-portal/config.js.map +1 -0
  32. package/dist/bin/dev-portal/main.js +11 -0
  33. package/dist/bin/dev-portal/main.js.map +1 -0
  34. package/dist/bin/dev-portal/usePersonResolver.js +40 -0
  35. package/dist/bin/dev-portal/usePersonResolver.js.map +1 -0
  36. package/dist/bin/dev-proxy.js +75 -0
  37. package/dist/bin/dev-proxy.js.map +1 -0
  38. package/dist/bin/main.app.js +78 -0
  39. package/dist/bin/main.app.js.map +1 -0
  40. package/dist/bin/main.js +18 -0
  41. package/dist/bin/main.js.map +1 -0
  42. package/dist/{scripts/dev-portal/assets/index-677239e8.js → bin/public/assets/index-61aab88e.js} +3 -3
  43. package/dist/{scripts/dev-portal → bin/public}/index.html +1 -1
  44. package/dist/bin/utils/execute-commant.js +20 -0
  45. package/dist/bin/utils/execute-commant.js.map +1 -0
  46. package/dist/bin/utils/format.js +17 -0
  47. package/dist/bin/utils/format.js.map +1 -0
  48. package/dist/bin/utils/load-app-config.js +34 -0
  49. package/dist/bin/utils/load-app-config.js.map +1 -0
  50. package/dist/bin/utils/load-manifest.js +35 -0
  51. package/dist/bin/utils/load-manifest.js.map +1 -0
  52. package/dist/bin/utils/load-package.js +24 -0
  53. package/dist/bin/utils/load-package.js.map +1 -0
  54. package/dist/bin/utils/load-vite-config.js +54 -0
  55. package/dist/bin/utils/load-vite-config.js.map +1 -0
  56. package/dist/bin/utils/spinner.js +67 -0
  57. package/dist/bin/utils/spinner.js.map +1 -0
  58. package/dist/lib/app-config.js +54 -0
  59. package/dist/lib/app-config.js.map +1 -0
  60. package/dist/lib/app-manifest.js +70 -0
  61. package/dist/lib/app-manifest.js.map +1 -0
  62. package/dist/lib/app-package.js +33 -0
  63. package/dist/lib/app-package.js.map +1 -0
  64. package/dist/lib/index.js +4 -0
  65. package/dist/lib/index.js.map +1 -0
  66. package/dist/lib/utils/assert.js +27 -0
  67. package/dist/lib/utils/assert.js.map +1 -0
  68. package/dist/lib/utils/config.js +76 -0
  69. package/dist/lib/utils/config.js.map +1 -0
  70. package/dist/lib/utils/expect.js +27 -0
  71. package/dist/lib/utils/expect.js.map +1 -0
  72. package/dist/lib/utils/file-exists.js +27 -0
  73. package/dist/lib/utils/file-exists.js.map +1 -0
  74. package/dist/lib/utils/types.js +2 -0
  75. package/dist/lib/utils/types.js.map +1 -0
  76. package/dist/lib/vite-config.js +81 -0
  77. package/dist/lib/vite-config.js.map +1 -0
  78. package/dist/lib/vite-logger.js +14 -0
  79. package/dist/lib/vite-logger.js.map +1 -0
  80. package/dist/types/bin/build-application.d.ts +12 -0
  81. package/dist/types/bin/bundle-application.d.ts +4 -0
  82. package/dist/types/bin/create-dev-serve.d.ts +10 -0
  83. package/dist/types/bin/create-export-config.d.ts +7 -0
  84. package/dist/types/bin/create-export-manifest.d.ts +20 -0
  85. package/dist/types/bin/dev-portal/AppLoader.d.ts +4 -0
  86. package/dist/types/bin/dev-portal/BookMarkSideSheet.d.ts +6 -0
  87. package/dist/types/bin/dev-portal/ContextSelector.d.ts +2 -0
  88. package/dist/types/bin/dev-portal/EquinorLoader.d.ts +5 -0
  89. package/dist/types/bin/dev-portal/ErrorViewer.d.ts +4 -0
  90. package/dist/types/bin/dev-portal/FusionLogo.d.ts +6 -0
  91. package/dist/types/bin/dev-portal/Header.d.ts +3 -0
  92. package/dist/types/bin/dev-portal/Router.d.ts +1 -0
  93. package/dist/types/bin/dev-portal/config.d.ts +3 -0
  94. package/dist/types/bin/dev-portal/main.d.ts +1 -0
  95. package/dist/types/bin/dev-portal/usePersonResolver.d.ts +1 -0
  96. package/dist/types/bin/dev-proxy.d.ts +27 -0
  97. package/dist/types/bin/main.app.d.ts +3 -0
  98. package/dist/types/bin/main.d.ts +1 -0
  99. package/dist/types/bin/utils/execute-commant.d.ts +8 -0
  100. package/dist/types/bin/utils/format.d.ts +9 -0
  101. package/dist/types/bin/utils/load-app-config.d.ts +9 -0
  102. package/dist/types/bin/utils/load-manifest.d.ts +9 -0
  103. package/dist/types/bin/utils/load-package.d.ts +5 -0
  104. package/dist/types/bin/utils/load-vite-config.d.ts +10 -0
  105. package/dist/types/bin/utils/spinner.d.ts +19 -0
  106. package/dist/types/lib/app-config.d.ts +27 -0
  107. package/dist/types/lib/app-manifest.d.ts +35 -0
  108. package/dist/types/lib/app-package.d.ts +23 -0
  109. package/dist/types/lib/index.d.ts +3 -0
  110. package/dist/types/lib/utils/assert.d.ts +10 -0
  111. package/dist/types/lib/utils/config.d.ts +26 -0
  112. package/dist/types/lib/utils/expect.d.ts +4 -0
  113. package/dist/types/lib/utils/file-exists.d.ts +6 -0
  114. package/dist/types/lib/utils/types.d.ts +6 -0
  115. package/dist/types/lib/vite-config.d.ts +17 -0
  116. package/dist/types/lib/vite-logger.d.ts +2 -0
  117. package/dist/types/version.d.ts +1 -0
  118. package/dist/version.js +1 -1
  119. package/package.json +41 -17
  120. package/dist/scripts/app-config.d.ts +0 -38
  121. package/dist/scripts/app-config.js +0 -73
  122. package/dist/scripts/app-config.js.map +0 -1
  123. package/dist/scripts/create-config.d.ts +0 -7
  124. package/dist/scripts/create-config.js +0 -59
  125. package/dist/scripts/create-config.js.map +0 -1
  126. package/dist/scripts/main.d.ts +0 -2
  127. package/dist/scripts/main.js +0 -51
  128. package/dist/scripts/main.js.map +0 -1
  129. package/dist/scripts/serve.d.ts +0 -6
  130. package/dist/scripts/serve.js +0 -109
  131. package/dist/scripts/serve.js.map +0 -1
  132. package/dist/version.d.ts +0 -1
  133. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,10 +1,117 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1194](https://github.com/equinor/fusion-framework/pull/1194) [`a424aef5`](https://github.com/equinor/fusion-framework/commit/a424aef5dc6575204a9448b74e0170192147b1b3) Thanks [@odinr](https://github.com/odinr)! - Rewrite fusion framework CLI
8
+
9
+ Rework of the Fusion Framework CLI to support future features
10
+
11
+ > the CLI was thrown together as a proof of concept, but grown un-manageable, because of lack of structure
12
+
13
+ **Main Features**
14
+
15
+ - Separate logic and utilities from program (app/cli commands)
16
+ - allow user to provide config files `app.{config,manifest,vite}.{ts,js,json}`
17
+ - the cli will try to resolve from `.ts` then `.js` then `.json`
18
+ - `app.config` is used to configure application environment configs (app-service config)
19
+ - `app.manifest` application manifest, information about the application
20
+ - `app.vite` override the CLI vite configuration
21
+ - provide interface for `app.TYPE.ts` config
22
+ - `define` and `merge` functionality
23
+ - note that `app.config` and `app.manifest` needs to return full object _(will not be merged by CLI)_
24
+ - allow providing config file in command
25
+ - using config when resolving proxy request
26
+ - improved CLI logging
27
+
28
+ **examples**
29
+
30
+ app.config.ts
31
+
32
+ ```ts
33
+ import { mergeAppConfigs, defineAppConfig } from '@equinor/fusion-framework-cli';
34
+ export default defineAppConfig((_nev, { base }) =>
35
+ mergeAppConfigs(base, {
36
+ environment: {
37
+ api: {
38
+ foo: {
39
+ baseUri: 'https://foo.bars',
40
+ scopes: ['foobar'],
41
+ },
42
+ },
43
+ },
44
+ }),
45
+ );
46
+ ```
47
+
48
+ app.manifest
49
+
50
+ ```ts
51
+ import { defineAppManifest, mergeManifests } from '@equinor/fusion-framework-cli';
52
+
53
+ export default defineAppManifest((env, { base }) => {
54
+ if (env.command === 'serve') {
55
+ return mergeManifests(base, {
56
+ key: 'simple',
57
+ });
58
+ }
59
+ return base;
60
+ });
61
+ ```
62
+
63
+ fusion-framework-cli app
64
+
65
+ ```sh
66
+ fusion-framework-cli app dev --manifest app.manifest.local.ts
67
+ ```
68
+
69
+ ### Minor Changes
70
+
71
+ - [#1194](https://github.com/equinor/fusion-framework/pull/1194) [`a424aef5`](https://github.com/equinor/fusion-framework/commit/a424aef5dc6575204a9448b74e0170192147b1b3) Thanks [@odinr](https://github.com/odinr)! - add command for generating manifest
72
+
73
+ generate manifest for application
74
+
75
+ ```sh
76
+ fusion-framework-cli app manifest
77
+ #output to file
78
+ fusion-framework-cli app manifest -o manifest.json
79
+ #specify custom config
80
+ fusion-framework-cli app manifest -c app.manifest.custom.ts
81
+ ```
82
+
83
+ - [#1194](https://github.com/equinor/fusion-framework/pull/1194) [`a424aef5`](https://github.com/equinor/fusion-framework/commit/a424aef5dc6575204a9448b74e0170192147b1b3) Thanks [@odinr](https://github.com/odinr)! - add pack command to cli
84
+
85
+ add method which will build, generate manifest and pack assets into a zip file (**just like the legacy @equinor/fusion-cli**)
86
+
87
+ ```sh
88
+ fusion-framework-cli app pack
89
+ ```
90
+
91
+ ### Patch Changes
92
+
93
+ - [#1194](https://github.com/equinor/fusion-framework/pull/1194) [`a424aef5`](https://github.com/equinor/fusion-framework/commit/a424aef5dc6575204a9448b74e0170192147b1b3) Thanks [@odinr](https://github.com/odinr)! - Add command for outputting application configuration
94
+
95
+ **example**
96
+
97
+ ```sh
98
+ fusion-framework-cli app config -o my-app.config.json
99
+ fdev portal config -e ci -k my-app --config-file my-app.config.json set
100
+ ```
101
+
102
+ ## 8.1.1
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [[`6f64d1aa`](https://github.com/equinor/fusion-framework/commit/6f64d1aa5e44af37f0abd76cef36e87761134760), [`758eaaf4`](https://github.com/equinor/fusion-framework/commit/758eaaf436ae28d180e7d91818b41abe0d9624c4)]:
107
+ - @equinor/fusion-observable@8.1.1
108
+ - @equinor/fusion-framework-app@7.1.3
109
+
3
110
  ## 8.1.0
4
111
 
5
112
  ### Minor Changes
6
113
 
7
- - [#1173](https://github.com/equinor/fusion-framework/pull/1173) [`571046fe`](https://github.com/equinor/fusion-framework/commit/571046fe1305c02eda0c2da46d33796f1cbcf5f1) Thanks [@odinr](https://github.com/odinr)! - Remove emotion decencies from CLI
114
+ - [`066d843c`](https://github.com/equinor/fusion-framework/commit/066d843c88cb974150f23f4fb9e7d0b066c93594) Thanks [@odinr](https://github.com/odinr)! - Remove emotion decencies from CLI
8
115
 
9
116
  align CLI with EDS and use style components instead of emotion 🥲
10
117
  prevent conflict of react types dependent on both emotion and eds
@@ -18,7 +125,7 @@
18
125
 
19
126
  ### Patch Changes
20
127
 
21
- - [#1184](https://github.com/equinor/fusion-framework/pull/1184) [`59982e55`](https://github.com/equinor/fusion-framework/commit/59982e55e24a49f06d37334f1cefcc0048894fe7) Thanks [@odinr](https://github.com/odinr)! - fixed bin resolve for pnpm
128
+ - [`066d843c`](https://github.com/equinor/fusion-framework/commit/066d843c88cb974150f23f4fb9e7d0b066c93594) Thanks [@odinr](https://github.com/odinr)! - fixed bin resolve for pnpm
22
129
 
23
130
  - Updated dependencies []:
24
131
  - @equinor/fusion-framework-app@7.1.2
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Fusion Framework CLI
2
+
3
+ [![npm version](https://badge.fury.io/js/@equinor%2Ffusion-framework-cli.svg)](https://badge.fury.io/js/@equinor%2Ffusion-framework-cli)
4
+
5
+ ## install
6
+ install from your favorite package manger
7
+
8
+ ## App
9
+ commands relative to working with applications
10
+
11
+ **app.config**
12
+
13
+ the cli will look for a `app.config.{ts,js,json}` which will be provided to the configuration step of the application
14
+
15
+ ```ts
16
+ export type AppConfig = {
17
+ /** application config */
18
+ environment?: Record<string, unknown>;
19
+ };
20
+ ```
21
+
22
+ **app.manifest**
23
+
24
+ the cli will look for a `app.manifest.{ts,js,json}` which will be provided to the configuration step oas manifest
25
+
26
+
27
+ **app.vite**
28
+
29
+ the cli will look for a `app.vite.{ts,js,json}` [Vite Configuration](https://vitejs.dev/config/)
30
+
31
+
32
+ ### dev
33
+
34
+ develop an application (with [Vite](https://vitejs.dev/) and generic [Fusion](https://fusion.equinor.com/) portal)
35
+
36
+ ```sh
37
+ fusion-framework-cli app dev --help
38
+ ```
39
+
40
+ ### build
41
+ builds application
42
+ > only source files are included, the dev-port is __not__ bundled.
43
+
44
+ ```sh
45
+ fusion-framework-cli app build --help
46
+ ```
47
+
48
+ ### manifest
49
+ generate manifest
50
+ ```sh
51
+ fusion-framework-cli app manifest --help
52
+ ```
53
+ ### config
54
+ generate application config
55
+ ```sh
56
+ fusion-framework-cli app manifest --help
57
+ ```
58
+
59
+ __example__
60
+ ```sh
61
+ fusion-framework-cli app config -o my-app.config.json
62
+ fdev portal config -e ci -k my-app --config-file my-app.config.json set
63
+ ```
64
+
65
+
66
+ ### pack
67
+
68
+ bundle application, generate manifest and zip output
69
+
70
+ ```sh
71
+ fusion-framework-cli app pack --help
72
+ ```
73
+
74
+ __example__
75
+ ```sh
76
+ fusion-framework-cli app pack
77
+ fdev portal upload -e ci -k my-app dist/app-bundle.zip
78
+ ```
package/bin/cli.mjs CHANGED
@@ -1,5 +1,2 @@
1
1
  #!/usr/bin/env node
2
- function start() {
3
- return import('../dist/scripts/main.js');
4
- }
5
- start();
2
+ import('../dist/bin/main.js');
@@ -0,0 +1,44 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { dirname } from 'node:path';
11
+ import { build } from 'vite';
12
+ import { chalk } from './utils/format.js';
13
+ import { Spinner } from './utils/spinner.js';
14
+ import { loadViteConfig } from './utils/load-vite-config.js';
15
+ import { resolveAppPackage } from '../lib/app-package.js';
16
+ export const buildApplication = (options) => __awaiter(void 0, void 0, void 0, function* () {
17
+ var _a;
18
+ const { configSourceFiles, library, outDir } = options;
19
+ const env = {
20
+ command: 'build',
21
+ mode: (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'production',
22
+ };
23
+ const spinner = Spinner.Global({ prefixText: chalk.dim('build') });
24
+ spinner.start('resolve application package');
25
+ const pkg = yield resolveAppPackage();
26
+ spinner.succeed();
27
+ spinner.info('📦', chalk.yellowBright([pkg.packageJson.name, pkg.packageJson.version].join('@')));
28
+ const packageDirname = dirname(pkg.path);
29
+ spinner.info(`🏠 ${chalk.blueBright(packageDirname)}`);
30
+ const { viteConfig } = yield loadViteConfig(env, {
31
+ file: configSourceFiles === null || configSourceFiles === void 0 ? void 0 : configSourceFiles.vite,
32
+ });
33
+ if (library === 'react') {
34
+ const reactPlugin = yield import('@vitejs/plugin-react');
35
+ viteConfig.plugins.push(reactPlugin.default());
36
+ }
37
+ viteConfig.build.outDir = outDir.trim();
38
+ const viteBuild = yield build(viteConfig);
39
+ return {
40
+ viteConfig,
41
+ viteBuild,
42
+ };
43
+ });
44
+ //# sourceMappingURL=build-application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-application.js","sourceRoot":"","sources":["../../src/bin/build-application.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAO,OAQtC,EAAE,EAAE;;IACD,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,GAAG,GAAsB;QAC3B,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,YAAY;KAC7C,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAEnE,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,MAAM,iBAAiB,EAAE,CAAC;IACtC,OAAO,CAAC,OAAO,EAAE,CAAC;IAElB,OAAO,CAAC,IAAI,CACR,IAAI,EACJ,KAAK,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAChF,CAAC;IAEF,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAEvD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE;QAC7C,IAAI,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,IAAI;KAChC,CAAC,CAAC;IAEH,IAAI,OAAO,KAAK,OAAO,EAAE;QACrB,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACzD,UAAU,CAAC,OAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;KACnD;IAED,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAExC,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IAE1C,OAAO;QACH,UAAU;QACV,SAAS;KACZ,CAAC;AACN,CAAC,CAAA,CAAC"}
@@ -0,0 +1,55 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import AdmZip from 'adm-zip';
11
+ import { resolve } from 'node:path';
12
+ import { loadPackage } from './utils/load-package.js';
13
+ import { chalk, formatByteSize, formatPath } from './utils/format.js';
14
+ import { Spinner } from './utils/spinner.js';
15
+ import { buildApplication } from './build-application.js';
16
+ import createExportManifest from './create-export-manifest.js';
17
+ import { fileExistsSync } from '../lib/utils/file-exists.js';
18
+ export const bundleApplication = (options) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const { outDir, archive } = options;
20
+ const spinner = Spinner.Global({ prefixText: chalk.dim('pack') });
21
+ const pkg = yield loadPackage();
22
+ spinner.start('build application');
23
+ yield buildApplication({ outDir });
24
+ spinner.succeed();
25
+ spinner.start('generate manifest');
26
+ const manifest = yield createExportManifest({ outputFile: `${outDir}-app-manifest.json` });
27
+ spinner.succeed();
28
+ console.log(chalk.dim(JSON.stringify(manifest, undefined, 2)));
29
+ spinner.start('compress content');
30
+ const bundle = new AdmZip();
31
+ bundle.addLocalFile(pkg.path);
32
+ spinner.info(`added ./package.json`);
33
+ bundle.addLocalFolder(outDir);
34
+ spinner.info(`added ./${outDir}`);
35
+ const licenseFile = resolve(pkg.path, 'LICENSE');
36
+ if (fileExistsSync(licenseFile)) {
37
+ bundle.addLocalFile(licenseFile);
38
+ spinner.info(`added ${licenseFile}`);
39
+ }
40
+ else {
41
+ spinner.warn(`missing ./LICENSE`);
42
+ }
43
+ const readmeFile = resolve(pkg.path, 'README');
44
+ if (fileExistsSync(readmeFile)) {
45
+ bundle.addLocalFile(readmeFile);
46
+ spinner.info(`added ${readmeFile}`);
47
+ }
48
+ else {
49
+ spinner.warn(`missing ./README`);
50
+ }
51
+ bundle.writeZip(archive);
52
+ spinner.info(formatPath(archive), formatByteSize(archive));
53
+ spinner.succeed();
54
+ });
55
+ //# sourceMappingURL=bundle-application.js.map
@@ -0,0 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
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { fileURLToPath } from 'node:url';
11
+ import { readFileSync } from 'node:fs';
12
+ import { assert } from 'node:console';
13
+ import { createServer } from 'vite';
14
+ import ViteRestart from 'vite-plugin-restart';
15
+ import portFinder from 'portfinder';
16
+ import { createDevProxy } from './dev-proxy.js';
17
+ import { loadAppConfig } from './utils/load-app-config.js';
18
+ import { loadViteConfig } from './utils/load-vite-config.js';
19
+ import { loadAppManifest } from './utils/load-manifest.js';
20
+ import { Spinner } from './utils/spinner.js';
21
+ import { chalk, formatPath } from './utils/format.js';
22
+ import { supportedExt } from '../lib/utils/config.js';
23
+ import { createManifest, manifestConfigFilename } from '../lib/app-manifest.js';
24
+ import { appConfigFilename, createAppConfig } from '../lib/app-config.js';
25
+ import { loadPackage } from './utils/load-package.js';
26
+ import { rateLimit } from 'express-rate-limit';
27
+ const resolveRelativePath = (path) => fileURLToPath(new URL(path, import.meta.url));
28
+ export const createDevServer = (options) => __awaiter(void 0, void 0, void 0, function* () {
29
+ var _a;
30
+ const { configSourceFiles, library, portal, port } = options;
31
+ const spinner = Spinner.Global({ prefixText: chalk.dim('dev-server') });
32
+ const pkg = yield loadPackage();
33
+ spinner.info(`using portal 🔌${formatPath(portal)} as proxy target`);
34
+ const env = {
35
+ command: 'serve',
36
+ mode: (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'development',
37
+ root: pkg.root,
38
+ };
39
+ const manifest = yield loadAppManifest(env, pkg, { file: configSourceFiles.manifest });
40
+ const { key: appKey } = manifest.manifest;
41
+ spinner.info(`resolved application key ${chalk.magenta(appKey)}`);
42
+ const { viteConfig, path: viteConfigPath } = yield loadViteConfig(env, {
43
+ file: configSourceFiles.vite,
44
+ });
45
+ if (library === 'react') {
46
+ const reactPlugin = yield import('@vitejs/plugin-react');
47
+ viteConfig.plugins.push(reactPlugin.default());
48
+ }
49
+ viteConfig.plugins.push(ViteRestart({
50
+ restart: ['package.json', viteConfigPath].filter((x) => !!x),
51
+ reload: [
52
+ ...supportedExt.map((ext) => [appConfigFilename, ext].join('')),
53
+ ...supportedExt.map((ext) => [manifestConfigFilename, ext].join('')),
54
+ ],
55
+ }));
56
+ const vite = yield createServer(Object.assign(Object.assign({}, env), viteConfig));
57
+ assert(vite.config.build.lib, 'expected vite build to have library defined');
58
+ const { entry } = vite.config.build.lib;
59
+ spinner.info('💾 application entrypoint', formatPath(String(entry)));
60
+ const devPortalPath = resolveRelativePath('public');
61
+ spinner.info('resolving cli internal assets from ', formatPath(devPortalPath));
62
+ const server = createDevProxy({
63
+ onConfigResponse: (slug, message, data) => __awaiter(void 0, void 0, void 0, function* () {
64
+ if (slug.appKey === appKey) {
65
+ if (message.statusCode === 404) {
66
+ const { config: response, path } = yield loadAppConfig(env, pkg, {
67
+ file: configSourceFiles.app,
68
+ });
69
+ return { response, path, statusCode: 200 };
70
+ }
71
+ else if (data) {
72
+ const { config: response, path } = yield createAppConfig(env, data, {
73
+ file: configSourceFiles.manifest,
74
+ });
75
+ path && spinner.info('created config from ', formatPath(path));
76
+ return { response, path };
77
+ }
78
+ }
79
+ }),
80
+ onManifestResponse: (slug, message, data) => __awaiter(void 0, void 0, void 0, function* () {
81
+ if (slug.appKey === appKey) {
82
+ if (message.statusCode === 404) {
83
+ const { manifest: response, path } = yield loadAppManifest(env, pkg, {
84
+ file: configSourceFiles.manifest,
85
+ });
86
+ response.entry = `/${entry}`;
87
+ return { response, path, statusCode: 200 };
88
+ }
89
+ else if (data) {
90
+ const { manifest: response, path } = yield createManifest(env, data, {
91
+ file: configSourceFiles.manifest,
92
+ });
93
+ response.entry = `/${entry}`;
94
+ path && spinner.info('created manifest from ', formatPath(path));
95
+ return { response, path };
96
+ }
97
+ }
98
+ }),
99
+ }, {
100
+ target: portal,
101
+ staticAssets: [{ path: devPortalPath }],
102
+ });
103
+ server.use(vite.middlewares);
104
+ server.use('*', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
105
+ const htmlRaw = readFileSync(resolveRelativePath('public/index.html'), 'utf-8');
106
+ const html = yield vite.transformIndexHtml(req.url, htmlRaw);
107
+ res.send(html);
108
+ }), rateLimit({
109
+ max: 10,
110
+ }));
111
+ const serverPort = port !== null && port !== void 0 ? port : (yield portFinder.getPortPromise({ port: 3000 }));
112
+ spinner.start('🚀 start server');
113
+ server.listen(serverPort);
114
+ spinner.succeed();
115
+ spinner.succeed('🔗', chalk.underline.green(new URL(`/apps/${appKey}`, `http://localhost:${serverPort}`).href));
116
+ });
117
+ //# sourceMappingURL=create-dev-serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-dev-serve.js","sourceRoot":"","sources":["../../src/bin/create-dev-serve.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAkB,YAAY,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;A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V,CAAC,CACL,CAAC;IAGF,MAAM,UAAU,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,CAAC,MAAM,UAAU,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACjC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,OAAO,CAAC,OAAO,CACX,IAAI,EACJ,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,SAAS,MAAM,EAAE,EAAE,oBAAoB,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAC3F,CAAC;AACN,CAAC,CAAA,CAAC"}
@@ -0,0 +1,51 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import nodeFs from 'node:fs';
11
+ import { writeFile } from 'node:fs/promises';
12
+ import { dirname } from 'node:path';
13
+ import { chalk, formatPath } from './utils/format.js';
14
+ import { Spinner } from './utils/spinner.js';
15
+ import { loadPackage } from './utils/load-package.js';
16
+ import { loadAppConfig } from './utils/load-app-config.js';
17
+ export const createExportConfig = (options) => __awaiter(void 0, void 0, void 0, function* () {
18
+ var _a;
19
+ const { command = 'build', outputFile } = options !== null && options !== void 0 ? options : {};
20
+ const spinner = Spinner.Global({ prefixText: chalk.dim('config') });
21
+ const pkg = yield loadPackage();
22
+ const env = {
23
+ command,
24
+ mode: (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'development',
25
+ root: pkg.root,
26
+ };
27
+ const { config } = yield loadAppConfig(env, pkg, {
28
+ file: options === null || options === void 0 ? void 0 : options.configFile,
29
+ });
30
+ if (outputFile) {
31
+ spinner.start(`outputting config to ${formatPath(outputFile)}`);
32
+ try {
33
+ const dir = dirname(outputFile).trim();
34
+ if (!nodeFs.existsSync(dirname(outputFile))) {
35
+ nodeFs.mkdirSync(dir, { recursive: true });
36
+ }
37
+ writeFile(outputFile, JSON.stringify(config));
38
+ spinner.succeed();
39
+ }
40
+ catch (err) {
41
+ spinner.fail();
42
+ throw err;
43
+ }
44
+ }
45
+ else {
46
+ console.log(config);
47
+ }
48
+ return config;
49
+ });
50
+ export default createExportConfig;
51
+ //# sourceMappingURL=create-export-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-export-config.js","sourceRoot":"","sources":["../../src/bin/create-export-config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAO,OAIxC,EAAE,EAAE;;IACD,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAExD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEpE,MAAM,GAAG,GAAG,MAAM,WAAW,EAAE,CAAC;IAEhC,MAAM,GAAG,GAAsB;QAC3B,OAAO;QACP,IAAI,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,aAAa;QAC3C,IAAI,EAAE,GAAG,CAAC,IAAI;KACjB,CAAC;IAEF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE;QAC7C,IAAI,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;KAC5B,CAAC,CAAC;IAEH,IAAI,UAAU,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,wBAAwB,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAChE,IAAI;YACA,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE;gBACzC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAC9C;YACD,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9C,OAAO,CAAC,OAAO,EAAE,CAAC;SACrB;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,GAAG,CAAC;SACb;KACJ;SAAM;QACH,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACvB;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,60 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import nodeFs from 'node:fs';
11
+ import { writeFile } from 'node:fs/promises';
12
+ import assert from 'node:assert';
13
+ import { SemVer, parse as parseSemver } from 'semver';
14
+ import { chalk, formatPath } from './utils/format.js';
15
+ import { Spinner } from './utils/spinner.js';
16
+ import { loadAppManifest } from './utils/load-manifest.js';
17
+ import { loadPackage } from './utils/load-package.js';
18
+ import { dirname } from 'node:path';
19
+ export const normalizeVersion = (version) => {
20
+ const semverVersion = parseSemver(version);
21
+ assert(semverVersion instanceof SemVer, 'expected version in AppManifest to be SemVer');
22
+ const { major, minor, patch } = semverVersion;
23
+ return { major, minor, patch };
24
+ };
25
+ export const createExportManifest = (options) => __awaiter(void 0, void 0, void 0, function* () {
26
+ var _a;
27
+ const { command = 'build', outputFile } = options !== null && options !== void 0 ? options : {};
28
+ const spinner = Spinner.Global({ prefixText: chalk.dim('manifest') });
29
+ const pkg = yield loadPackage();
30
+ const env = {
31
+ command,
32
+ mode: (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'development',
33
+ root: pkg.root,
34
+ };
35
+ const { manifest } = yield loadAppManifest(env, pkg, {
36
+ file: options === null || options === void 0 ? void 0 : options.configFile,
37
+ });
38
+ const manifestExport = Object.assign(Object.assign({}, manifest), { version: normalizeVersion(manifest.version) });
39
+ if (outputFile) {
40
+ spinner.start(`outputting manifest to ${formatPath(outputFile)}`);
41
+ try {
42
+ const dir = dirname(outputFile).trim();
43
+ if (!nodeFs.existsSync(dirname(outputFile))) {
44
+ nodeFs.mkdirSync(dir, { recursive: true });
45
+ }
46
+ writeFile(outputFile, JSON.stringify(manifestExport));
47
+ spinner.succeed();
48
+ }
49
+ catch (err) {
50
+ spinner.fail();
51
+ throw err;
52
+ }
53
+ }
54
+ else {
55
+ console.log(manifestExport);
56
+ }
57
+ return manifestExport;
58
+ });
59
+ export default createExportManifest;
60
+ //# sourceMappingURL=create-export-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-export-manifest.js","sourceRoot":"","sources":["../../src/bin/create-export-manifest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;IAChD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,aAAa,YAAY,MAAM,EAAE,8CAA8C,CAAC,CAAC;IAExF,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;IAC9C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC,CAAC;AAUF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAO,OAI1C,EAAE,EAAE;;IACD,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,aAAP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Ac,CAAC,CAAC;KAC/B;IACD,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAA,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Subscription } from 'rxjs';
4
+ import { useFramework } from '@equinor/fusion-framework-react';
5
+ import { useObservableState } from '@equinor/fusion-observable/react';
6
+ import { AppManifestError } from '@equinor/fusion-framework-module-app/errors.js';
7
+ import { ErrorViewer } from './ErrorViewer';
8
+ import EquinorLoader from './EquinorLoader';
9
+ export const AppLoader = (props) => {
10
+ const { appKey } = props;
11
+ const fusion = useFramework();
12
+ const ref = useRef(null);
13
+ const [loading, setLoading] = useState(false);
14
+ const [error, setError] = useState();
15
+ const { value: currentApp } = useObservableState(useMemo(() => fusion.modules.app.current$, [fusion.modules.app]));
16
+ useEffect(() => {
17
+ fusion.modules.app.setCurrentApp(appKey);
18
+ }, [appKey, fusion]);
19
+ useEffect(() => {
20
+ setLoading(true);
21
+ setError(undefined);
22
+ const subscription = new Subscription();
23
+ subscription.add(currentApp === null || currentApp === void 0 ? void 0 : currentApp.initialize().subscribe({
24
+ next: ({ manifest, script, config }) => {
25
+ var _a, _b;
26
+ const [basename] = (_a = window.location.pathname.match(/\/?apps\/[a-z|-]+(\/)?/g)) !== null && _a !== void 0 ? _a : [''];
27
+ const el = document.createElement('div');
28
+ if (!ref.current) {
29
+ throw Error('Missing application mounting point');
30
+ }
31
+ ref.current.appendChild(el);
32
+ const render = (_b = script.renderApp) !== null && _b !== void 0 ? _b : script.default;
33
+ subscription.add(render(el, { fusion, env: { basename, config, manifest } }));
34
+ subscription.add(() => el.remove());
35
+ },
36
+ complete: () => {
37
+ setLoading(false);
38
+ },
39
+ error: (err) => {
40
+ setError(err);
41
+ },
42
+ }));
43
+ return () => subscription.unsubscribe();
44
+ }, [fusion, currentApp, ref]);
45
+ if (error) {
46
+ if (error.cause instanceof AppManifestError) {
47
+ return (_jsxs("div", { children: [_jsx("h2", { children: "\uD83D\uDD25 Failed to load application manifest \uD83E\uDD2C" }), _jsx("h3", { children: error.cause.type }), _jsx(ErrorViewer, { error: error }), ";"] }));
48
+ }
49
+ return (_jsxs("div", { children: [_jsx("h2", { children: "\uD83D\uDD25 Failed to load application \uD83E\uDD2C" }), _jsx(ErrorViewer, { error: error }), ";"] }));
50
+ }
51
+ return (_jsx("section", { id: "application-content", ref: ref, children: loading && _jsx(EquinorLoader, { text: "Loading Application" }) }));
52
+ };
53
+ export default AppLoader;
54
+ //# sourceMappingURL=AppLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppLoader.js","sourceRoot":"","sources":["../../../src/bin/dev-portal/AppLoader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAS5C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,MAAM,MAAM,GAAG,YAAY,EAAe,CAAC;IAG3C,MAAM,GAAG,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IAEtC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ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