@equinor/fusion-framework-cli 0.0.0-next-20230915111233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +994 -0
- package/LICENSE +21 -0
- package/README.md +78 -0
- package/bin/cli.mjs +2 -0
- package/dist/bin/build-application.js +44 -0
- package/dist/bin/build-application.js.map +1 -0
- package/dist/bin/bundle-application.js +55 -0
- package/dist/bin/bundle-application.js.map +1 -0
- package/dist/bin/create-dev-serve.js +117 -0
- package/dist/bin/create-dev-serve.js.map +1 -0
- package/dist/bin/create-export-config.js +51 -0
- package/dist/bin/create-export-config.js.map +1 -0
- package/dist/bin/create-export-manifest.js +60 -0
- package/dist/bin/create-export-manifest.js.map +1 -0
- package/dist/bin/dev-portal/AppLoader.js +55 -0
- package/dist/bin/dev-portal/AppLoader.js.map +1 -0
- package/dist/bin/dev-portal/BookMarkSideSheet.js +15 -0
- package/dist/bin/dev-portal/BookMarkSideSheet.js.map +1 -0
- package/dist/bin/dev-portal/ContextSelector.js +107 -0
- package/dist/bin/dev-portal/ContextSelector.js.map +1 -0
- package/dist/bin/dev-portal/EquinorLoader.js +14 -0
- package/dist/bin/dev-portal/EquinorLoader.js.map +1 -0
- package/dist/bin/dev-portal/ErrorViewer.js +7 -0
- package/dist/bin/dev-portal/ErrorViewer.js.map +1 -0
- package/dist/bin/dev-portal/FusionLogo.js +4 -0
- package/dist/bin/dev-portal/FusionLogo.js.map +1 -0
- package/dist/bin/dev-portal/Header.js +31 -0
- package/dist/bin/dev-portal/Header.js.map +1 -0
- package/dist/bin/dev-portal/Router.js +43 -0
- package/dist/bin/dev-portal/Router.js.map +1 -0
- package/dist/bin/dev-portal/config.js +47 -0
- package/dist/bin/dev-portal/config.js.map +1 -0
- package/dist/bin/dev-portal/main.js +12 -0
- package/dist/bin/dev-portal/main.js.map +1 -0
- package/dist/bin/dev-portal/usePersonResolver.js +40 -0
- package/dist/bin/dev-portal/usePersonResolver.js.map +1 -0
- package/dist/bin/dev-proxy.js +75 -0
- package/dist/bin/dev-proxy.js.map +1 -0
- package/dist/bin/main.app.js +78 -0
- package/dist/bin/main.app.js.map +1 -0
- package/dist/bin/main.js +18 -0
- package/dist/bin/main.js.map +1 -0
- package/dist/bin/public/assets/index-45698c38.js +2864 -0
- package/dist/bin/public/index.html +42 -0
- package/dist/bin/utils/execute-commant.js +20 -0
- package/dist/bin/utils/execute-commant.js.map +1 -0
- package/dist/bin/utils/format.js +17 -0
- package/dist/bin/utils/format.js.map +1 -0
- package/dist/bin/utils/load-app-config.js +34 -0
- package/dist/bin/utils/load-app-config.js.map +1 -0
- package/dist/bin/utils/load-manifest.js +35 -0
- package/dist/bin/utils/load-manifest.js.map +1 -0
- package/dist/bin/utils/load-package.js +24 -0
- package/dist/bin/utils/load-package.js.map +1 -0
- package/dist/bin/utils/load-vite-config.js +54 -0
- package/dist/bin/utils/load-vite-config.js.map +1 -0
- package/dist/bin/utils/spinner.js +67 -0
- package/dist/bin/utils/spinner.js.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/app-config.js +54 -0
- package/dist/lib/app-config.js.map +1 -0
- package/dist/lib/app-manifest.js +70 -0
- package/dist/lib/app-manifest.js.map +1 -0
- package/dist/lib/app-package.js +33 -0
- package/dist/lib/app-package.js.map +1 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/utils/assert.js +27 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/lib/utils/config.js +76 -0
- package/dist/lib/utils/config.js.map +1 -0
- package/dist/lib/utils/expect.js +27 -0
- package/dist/lib/utils/expect.js.map +1 -0
- package/dist/lib/utils/file-exists.js +27 -0
- package/dist/lib/utils/file-exists.js.map +1 -0
- package/dist/lib/utils/types.js +2 -0
- package/dist/lib/utils/types.js.map +1 -0
- package/dist/lib/vite-config.js +81 -0
- package/dist/lib/vite-config.js.map +1 -0
- package/dist/lib/vite-logger.js +14 -0
- package/dist/lib/vite-logger.js.map +1 -0
- package/dist/types/bin/build-application.d.ts +12 -0
- package/dist/types/bin/bundle-application.d.ts +4 -0
- package/dist/types/bin/create-dev-serve.d.ts +10 -0
- package/dist/types/bin/create-export-config.d.ts +7 -0
- package/dist/types/bin/create-export-manifest.d.ts +20 -0
- package/dist/types/bin/dev-portal/AppLoader.d.ts +4 -0
- package/dist/types/bin/dev-portal/BookMarkSideSheet.d.ts +6 -0
- package/dist/types/bin/dev-portal/ContextSelector.d.ts +2 -0
- package/dist/types/bin/dev-portal/EquinorLoader.d.ts +5 -0
- package/dist/types/bin/dev-portal/ErrorViewer.d.ts +4 -0
- package/dist/types/bin/dev-portal/FusionLogo.d.ts +6 -0
- package/dist/types/bin/dev-portal/Header.d.ts +3 -0
- package/dist/types/bin/dev-portal/Router.d.ts +1 -0
- package/dist/types/bin/dev-portal/config.d.ts +3 -0
- package/dist/types/bin/dev-portal/main.d.ts +1 -0
- package/dist/types/bin/dev-portal/usePersonResolver.d.ts +1 -0
- package/dist/types/bin/dev-proxy.d.ts +27 -0
- package/dist/types/bin/main.app.d.ts +3 -0
- package/dist/types/bin/main.d.ts +1 -0
- package/dist/types/bin/utils/execute-commant.d.ts +8 -0
- package/dist/types/bin/utils/format.d.ts +9 -0
- package/dist/types/bin/utils/load-app-config.d.ts +9 -0
- package/dist/types/bin/utils/load-manifest.d.ts +9 -0
- package/dist/types/bin/utils/load-package.d.ts +5 -0
- package/dist/types/bin/utils/load-vite-config.d.ts +10 -0
- package/dist/types/bin/utils/spinner.d.ts +19 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/lib/app-config.d.ts +27 -0
- package/dist/types/lib/app-manifest.d.ts +35 -0
- package/dist/types/lib/app-package.d.ts +23 -0
- package/dist/types/lib/index.d.ts +3 -0
- package/dist/types/lib/utils/assert.d.ts +10 -0
- package/dist/types/lib/utils/config.d.ts +26 -0
- package/dist/types/lib/utils/expect.d.ts +4 -0
- package/dist/types/lib/utils/file-exists.d.ts +6 -0
- package/dist/types/lib/utils/types.d.ts +6 -0
- package/dist/types/lib/vite-config.d.ts +17 -0
- package/dist/types/lib/vite-logger.d.ts +2 -0
- package/dist/types/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +104 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Equinor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Fusion Framework CLI
|
|
2
|
+
|
|
3
|
+
[](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.config.{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.config.{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
ADDED
|
@@ -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;IACv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;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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-application.js","sourceRoot":"","sources":["../../src/bin/bundle-application.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,oBAAoB,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CA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Y,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;KACxC;SAAM;QACH,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACrC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;QAC5B,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC;KACvC;SAAM;QACH,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;KACpC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEzB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3D,OAAO,CAAC,OAAO,EAAE,CAAC;AACtB,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
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 { 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,YA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M,CAAC,GAAG,CACN,GAAG,EACH,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QAEf,MAAM,OAAO,GAAG,YAAY,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,CAAC;QAChF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAA,EACD,SAAS,CAAC;QACN,GAAG,EAAE,EAAE;KACV,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,OAAO,cAAP,OAAO,GAAI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ACD,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAA,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
el.style.display = 'contents';
|
|
29
|
+
if (!ref.current) {
|
|
30
|
+
throw Error('Missing application mounting point');
|
|
31
|
+
}
|
|
32
|
+
ref.current.appendChild(el);
|
|
33
|
+
const render = (_b = script.renderApp) !== null && _b !== void 0 ? _b : script.default;
|
|
34
|
+
subscription.add(render(el, { fusion, env: { basename, config, manifest } }));
|
|
35
|
+
subscription.add(() => el.remove());
|
|
36
|
+
},
|
|
37
|
+
complete: () => {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
},
|
|
40
|
+
error: (err) => {
|
|
41
|
+
setError(err);
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
return () => subscription.unsubscribe();
|
|
45
|
+
}, [fusion, currentApp, ref]);
|
|
46
|
+
if (error) {
|
|
47
|
+
if (error.cause instanceof AppManifestError) {
|
|
48
|
+
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 }), ";"] }));
|
|
49
|
+
}
|
|
50
|
+
return (_jsxs("div", { children: [_jsx("h2", { children: "\uD83D\uDD25 Failed to load application \uD83E\uDD2C" }), _jsx(ErrorViewer, { error: error }), ";"] }));
|
|
51
|
+
}
|
|
52
|
+
return (_jsx("section", { id: "application-content", ref: ref, children: loading && _jsx(EquinorLoader, { text: "Loading Application" }) }));
|
|
53
|
+
};
|
|
54
|
+
export default AppLoader;
|
|
55
|
+
//# 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,W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AAyC,EACzC,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,GAAI,SAC3B,CACT,CAAC;KACL;IAED,OAAO,CACH,kBAAS,EAAE,EAAC,qBAAqB,EAAC,GAAG,EAAE,GAAG,YACrC,OAAO,IAAI,KAAC,aAAa,IAAC,IAAI,EAAC,qBAAqB,GAAG,GAClD,CACb,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Icon } from '@equinor/eds-core-react';
|
|
3
|
+
import { useFramework } from '@equinor/fusion-framework-react';
|
|
4
|
+
import { Bookmark } from '@equinor/fusion-framework-react-components-bookmark';
|
|
5
|
+
import { useHasBookmark } from '@equinor/fusion-framework-react-module-bookmark/portal';
|
|
6
|
+
import { SideSheet } from '@equinor/fusion-react-side-sheet';
|
|
7
|
+
export const BookmarkSideSheet = ({ isOpen, onClose }) => {
|
|
8
|
+
const hasBookmark = useHasBookmark();
|
|
9
|
+
const { event } = useFramework().modules;
|
|
10
|
+
return (_jsxs(SideSheet, { isOpen: isOpen, onClose: onClose, isDismissable: true, enableFullscreen: true, children: [_jsx(SideSheet.Indicator, { color: '#258800' }), _jsx(SideSheet.Title, { title: "Bookmarks" }), _jsx(SideSheet.SubTitle, { subTitle: 'Application bookmarks' }), _jsx(SideSheet.Actions, { children: _jsxs(Button, { disabled: !hasBookmark, variant: "ghost", onClick: () => {
|
|
11
|
+
onClose();
|
|
12
|
+
event.dispatchEvent('onBookmarkOpen', { detail: true });
|
|
13
|
+
}, children: [_jsx(Icon, { name: "add" }), " Add Bookmark"] }) }), _jsx(SideSheet.Content, { children: _jsx(Bookmark, {}) })] }));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=BookMarkSideSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BookMarkSideSheet.js","sourceRoot":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