@equinor/fusion-framework-cli 10.0.0-widget-b2daf10f → 10.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.
- package/CHANGELOG.md +636 -39
- package/README.md +31 -9
- package/dist/bin/build-application.js +23 -3
- package/dist/bin/build-application.js.map +1 -1
- package/dist/bin/bundle-application.js +9 -12
- package/dist/bin/bundle-application.js.map +1 -1
- package/dist/bin/create-dev-serve.js +89 -123
- package/dist/bin/create-dev-serve.js.map +1 -1
- package/dist/bin/create-export-config.js +5 -6
- package/dist/bin/create-export-config.js.map +1 -1
- package/dist/bin/create-export-manifest.js +44 -27
- package/dist/bin/create-export-manifest.js.map +1 -1
- package/dist/bin/dev-portal/AppLoader.js +26 -4
- package/dist/bin/dev-portal/AppLoader.js.map +1 -1
- package/dist/bin/dev-portal/ContextSelector/ContextSelector.js +41 -0
- package/dist/bin/dev-portal/ContextSelector/ContextSelector.js.map +1 -0
- package/dist/bin/dev-portal/ContextSelector/index.js +2 -0
- package/dist/bin/dev-portal/ContextSelector/index.js.map +1 -0
- package/dist/bin/dev-portal/ContextSelector/useContextResolver.js +171 -0
- package/dist/bin/dev-portal/ContextSelector/useContextResolver.js.map +1 -0
- package/dist/bin/dev-portal/Header.js +3 -2
- package/dist/bin/dev-portal/Header.js.map +1 -1
- package/dist/bin/dev-portal/PersonSideSheet/index.js +7 -2
- package/dist/bin/dev-portal/PersonSideSheet/index.js.map +1 -1
- package/dist/bin/dev-portal/PersonSideSheet/sheets/FeatureSheetContent.js +4 -0
- package/dist/bin/dev-portal/PersonSideSheet/sheets/FeatureSheetContent.js.map +1 -1
- package/dist/bin/dev-portal/PersonSideSheet/sheets/FeatureTogglerApp.js +3 -0
- package/dist/bin/dev-portal/PersonSideSheet/sheets/FeatureTogglerApp.js.map +1 -1
- package/dist/bin/dev-portal/PersonSideSheet/sheets/FeatureTogglerPortal.js +3 -0
- package/dist/bin/dev-portal/PersonSideSheet/sheets/FeatureTogglerPortal.js.map +1 -1
- package/dist/bin/dev-portal/PersonSideSheet/sheets/LandingSheetContent.js +3 -0
- package/dist/bin/dev-portal/PersonSideSheet/sheets/LandingSheetContent.js.map +1 -1
- package/dist/bin/dev-portal/Router.js +17 -1
- package/dist/bin/dev-portal/Router.js.map +1 -1
- package/dist/bin/dev-portal/config.js +7 -4
- package/dist/bin/dev-portal/config.js.map +1 -1
- package/dist/bin/dev-portal/main.js +1 -2
- package/dist/bin/dev-portal/main.js.map +1 -1
- package/dist/bin/dev-portal/useAppContextNavigation.js +68 -0
- package/dist/bin/dev-portal/useAppContextNavigation.js.map +1 -0
- package/dist/bin/main.app.js +92 -14
- package/dist/bin/main.app.js.map +1 -1
- package/dist/bin/main.js +5 -5
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/public/assets/index-D0eBBcR8.js +5235 -0
- package/dist/bin/public/index.html +1 -5
- package/dist/bin/publish-application.js +104 -0
- package/dist/bin/publish-application.js.map +1 -0
- package/dist/bin/tag-application.js +82 -0
- package/dist/bin/tag-application.js.map +1 -0
- package/dist/bin/upload-application.js +72 -0
- package/dist/bin/upload-application.js.map +1 -0
- package/dist/bin/upload-export-config.js +87 -0
- package/dist/bin/upload-export-config.js.map +1 -0
- package/dist/bin/utils/{execute-commant.js → execute-command.js} +5 -2
- package/dist/bin/utils/execute-command.js.map +1 -0
- package/dist/bin/utils/format.js +1 -1
- package/dist/bin/utils/format.js.map +1 -1
- package/dist/bin/utils/getEndpointUrl.js +49 -0
- package/dist/bin/utils/getEndpointUrl.js.map +1 -0
- package/dist/bin/utils/index.js +14 -0
- package/dist/bin/utils/index.js.map +1 -0
- package/dist/bin/utils/isAppRegistered.js +35 -0
- package/dist/bin/utils/isAppRegistered.js.map +1 -0
- package/dist/bin/utils/load-app-config.js +3 -2
- package/dist/bin/utils/load-app-config.js.map +1 -1
- package/dist/bin/utils/load-manifest.js +9 -4
- package/dist/bin/utils/load-manifest.js.map +1 -1
- package/dist/bin/utils/load-vite-config.js.map +1 -1
- package/dist/bin/utils/proxy-request-logger.js +34 -0
- package/dist/bin/utils/proxy-request-logger.js.map +1 -0
- package/dist/bin/utils/publishAppConfig.js +36 -0
- package/dist/bin/utils/publishAppConfig.js.map +1 -0
- package/dist/bin/utils/requireToken.js +10 -0
- package/dist/bin/utils/requireToken.js.map +1 -0
- package/dist/bin/utils/spinner.js +10 -0
- package/dist/bin/utils/spinner.js.map +1 -1
- package/dist/bin/utils/tagAppBundle.js +35 -0
- package/dist/bin/utils/tagAppBundle.js.map +1 -0
- package/dist/bin/utils/uploadAppBundle.js +54 -0
- package/dist/bin/utils/uploadAppBundle.js.map +1 -0
- package/dist/lib/app-config.js +5 -17
- package/dist/lib/app-config.js.map +1 -1
- package/dist/lib/app-manifest.js +97 -15
- package/dist/lib/app-manifest.js.map +1 -1
- package/dist/lib/app-package.js +52 -5
- package/dist/lib/app-package.js.map +1 -1
- package/dist/lib/index.js +2 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/plugins/app-assets/app-asset-plugin.js +102 -0
- package/dist/lib/plugins/app-assets/app-asset-plugin.js.map +1 -0
- package/dist/lib/plugins/app-assets/emit-asset.js +41 -0
- package/dist/lib/plugins/app-assets/emit-asset.js.map +1 -0
- package/dist/lib/plugins/app-assets/extension-filter-pattern.js +20 -0
- package/dist/lib/plugins/app-assets/extension-filter-pattern.js.map +1 -0
- package/dist/lib/plugins/app-assets/index.js +4 -0
- package/dist/lib/plugins/app-assets/index.js.map +1 -0
- package/dist/lib/plugins/app-assets/read-asset-content.js +34 -0
- package/dist/lib/plugins/app-assets/read-asset-content.js.map +1 -0
- package/dist/lib/plugins/app-assets/resolve-asset-id.js +63 -0
- package/dist/lib/plugins/app-assets/resolve-asset-id.js.map +1 -0
- package/dist/lib/plugins/app-assets/static.js +15 -0
- package/dist/lib/plugins/app-assets/static.js.map +1 -0
- package/dist/lib/plugins/app-proxy/app-proxy-plugin.js +127 -0
- package/dist/lib/plugins/app-proxy/app-proxy-plugin.js.map +1 -0
- package/dist/lib/plugins/app-proxy/index.js +2 -0
- package/dist/lib/plugins/app-proxy/index.js.map +1 -0
- package/dist/lib/plugins/external-public/external-public-plugin.js +103 -0
- package/dist/lib/plugins/external-public/external-public-plugin.js.map +1 -0
- package/dist/lib/plugins/external-public/index.js +2 -0
- package/dist/lib/plugins/external-public/index.js.map +1 -0
- package/dist/lib/utils/assert.js +2 -1
- package/dist/lib/utils/assert.js.map +1 -1
- package/dist/lib/utils/config.js +5 -0
- package/dist/lib/utils/config.js.map +1 -1
- package/dist/lib/utils/file-exists.js.map +1 -1
- package/dist/lib/utils/ts-transpile.js.map +1 -1
- package/dist/lib/vite-config.js +7 -8
- package/dist/lib/vite-config.js.map +1 -1
- package/dist/lib/vite-logger.js +2 -0
- package/dist/lib/vite-logger.js.map +1 -1
- package/dist/schemas.js +14 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types/bin/build-application.d.ts +3 -3
- package/dist/types/bin/bundle-application.d.ts +0 -1
- package/dist/types/bin/create-dev-serve.d.ts +1 -4
- package/dist/types/bin/create-export-config.d.ts +9 -3
- package/dist/types/bin/create-export-manifest.d.ts +7 -11
- package/dist/types/bin/dev-portal/AppLoader.d.ts +7 -0
- package/dist/types/bin/dev-portal/ContextSelector/ContextSelector.d.ts +8 -0
- package/dist/types/bin/dev-portal/ContextSelector/index.d.ts +1 -0
- package/dist/types/bin/dev-portal/ContextSelector/useContextResolver.d.ts +15 -0
- package/dist/types/bin/dev-portal/FusionLogo.d.ts +0 -1
- package/dist/types/bin/dev-portal/PersonSideSheet/index.d.ts +4 -0
- package/dist/types/bin/dev-portal/PersonSideSheet/sheets/FeatureSheetContent.d.ts +4 -0
- package/dist/types/bin/dev-portal/PersonSideSheet/sheets/FeatureTogglerApp.d.ts +3 -0
- package/dist/types/bin/dev-portal/PersonSideSheet/sheets/FeatureTogglerPortal.d.ts +3 -0
- package/dist/types/bin/dev-portal/PersonSideSheet/sheets/LandingSheetContent.d.ts +3 -0
- package/dist/types/bin/dev-portal/PersonSideSheet/sheets/Styled.d.ts +4 -1088
- package/dist/types/bin/dev-portal/useAppContextNavigation.d.ts +5 -0
- package/dist/types/bin/publish-application.d.ts +6 -0
- package/dist/types/bin/tag-application.d.ts +12 -0
- package/dist/types/bin/upload-application.d.ts +6 -0
- package/dist/types/bin/upload-export-config.d.ts +10 -0
- package/dist/types/bin/utils/execute-command.d.ts +8 -0
- package/dist/types/bin/utils/format.d.ts +0 -1
- package/dist/types/bin/utils/getEndpointUrl.d.ts +10 -0
- package/dist/types/bin/utils/index.d.ts +14 -0
- package/dist/types/bin/utils/isAppRegistered.d.ts +5 -0
- package/dist/types/bin/utils/load-app-config.d.ts +3 -2
- package/dist/types/bin/utils/load-manifest.d.ts +3 -2
- package/dist/types/bin/utils/proxy-request-logger.d.ts +15 -0
- package/dist/types/bin/utils/publishAppConfig.d.ts +9 -0
- package/dist/types/bin/utils/requireToken.d.ts +4 -0
- package/dist/types/bin/utils/spinner.d.ts +1 -0
- package/dist/types/bin/utils/tagAppBundle.d.ts +7 -0
- package/dist/types/bin/utils/uploadAppBundle.d.ts +7 -0
- package/dist/types/lib/app-config.d.ts +13 -14
- package/dist/types/lib/app-manifest.d.ts +30 -14
- package/dist/types/lib/app-package.d.ts +35 -4
- package/dist/types/lib/index.d.ts +2 -5
- package/dist/types/lib/plugins/app-assets/app-asset-plugin.d.ts +36 -0
- package/dist/types/lib/plugins/app-assets/emit-asset.d.ts +18 -0
- package/dist/types/lib/plugins/app-assets/extension-filter-pattern.d.ts +14 -0
- package/dist/types/lib/plugins/app-assets/index.d.ts +3 -0
- package/dist/types/lib/plugins/app-assets/read-asset-content.d.ts +14 -0
- package/dist/types/lib/plugins/app-assets/resolve-asset-id.d.ts +16 -0
- package/dist/types/lib/plugins/app-assets/static.d.ts +5 -0
- package/dist/types/lib/plugins/app-proxy/app-proxy-plugin.d.ts +71 -0
- package/dist/types/lib/plugins/app-proxy/index.d.ts +1 -0
- package/dist/types/lib/plugins/external-public/external-public-plugin.d.ts +30 -0
- package/dist/types/lib/plugins/external-public/index.d.ts +1 -0
- package/dist/types/lib/utils/assert.d.ts +2 -1
- package/dist/types/lib/utils/config.d.ts +9 -6
- package/dist/types/lib/utils/expect.d.ts +1 -1
- package/dist/types/lib/vite-config.d.ts +1 -1
- package/dist/types/schemas.d.ts +30 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/version.js +2 -1
- package/dist/version.js.map +1 -1
- package/package.json +52 -42
- package/dist/bin/bundle-widget.js +0 -61
- package/dist/bin/bundle-widget.js.map +0 -1
- package/dist/bin/create-export-manifest-widget.js +0 -68
- package/dist/bin/create-export-manifest-widget.js.map +0 -1
- package/dist/bin/dev-portal/ContextSelector.js +0 -107
- package/dist/bin/dev-portal/ContextSelector.js.map +0 -1
- package/dist/bin/dev-portal/usePersonResolver.js +0 -40
- package/dist/bin/dev-portal/usePersonResolver.js.map +0 -1
- package/dist/bin/dev-proxy.js +0 -86
- package/dist/bin/dev-proxy.js.map +0 -1
- package/dist/bin/main.widget.js +0 -78
- package/dist/bin/main.widget.js.map +0 -1
- package/dist/bin/public/assets/index-UrNngCGF.js +0 -4083
- package/dist/bin/utils/execute-commant.js.map +0 -1
- package/dist/bin/utils/load-dev-proxy.js +0 -54
- package/dist/bin/utils/load-dev-proxy.js.map +0 -1
- package/dist/bin/utils/load-widget-manifest.js +0 -35
- package/dist/bin/utils/load-widget-manifest.js.map +0 -1
- package/dist/bin/utils/load-widget-package.js +0 -24
- package/dist/bin/utils/load-widget-package.js.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/lib/dev-config.js +0 -9
- package/dist/lib/dev-config.js.map +0 -1
- package/dist/lib/widget-config.js +0 -57
- package/dist/lib/widget-config.js.map +0 -1
- package/dist/lib/widget-manifest.js +0 -73
- package/dist/lib/widget-manifest.js.map +0 -1
- package/dist/lib/widget-package.js +0 -33
- package/dist/lib/widget-package.js.map +0 -1
- package/dist/types/bin/bundle-widget.d.ts +0 -5
- package/dist/types/bin/create-export-manifest-widget.d.ts +0 -20
- package/dist/types/bin/dev-portal/ContextSelector.d.ts +0 -2
- package/dist/types/bin/dev-portal/usePersonResolver.d.ts +0 -1
- package/dist/types/bin/dev-proxy.d.ts +0 -36
- package/dist/types/bin/main.widget.d.ts +0 -3
- package/dist/types/bin/utils/execute-commant.d.ts +0 -8
- package/dist/types/bin/utils/load-dev-proxy.d.ts +0 -3
- package/dist/types/bin/utils/load-widget-manifest.d.ts +0 -8
- package/dist/types/bin/utils/load-widget-package.d.ts +0 -5
- package/dist/types/index.d.ts +0 -4
- package/dist/types/lib/dev-config.d.ts +0 -13
- package/dist/types/lib/widget-config.d.ts +0 -26
- package/dist/types/lib/widget-manifest.d.ts +0 -53
- package/dist/types/lib/widget-package.d.ts +0 -23
|
@@ -0,0 +1,102 @@
|
|
|
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 { createFilter } from 'vite';
|
|
11
|
+
import { emitAssetSync } from './emit-asset.js';
|
|
12
|
+
import { resolveAssetId } from './resolve-asset-id.js';
|
|
13
|
+
import { createExtensionFilterPattern } from './extension-filter-pattern.js';
|
|
14
|
+
import { ASSET_EXTENSIONS, PLUGIN_NAME } from './static.js';
|
|
15
|
+
const defaultInclude = createExtensionFilterPattern(ASSET_EXTENSIONS);
|
|
16
|
+
/**
|
|
17
|
+
* A Vite plugin to handle external resources in a library build.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Configuration options for the plugin.
|
|
20
|
+
* @param options.name - Optional name for the emitted assets.
|
|
21
|
+
* @param options.include - Filter pattern to include specific files.
|
|
22
|
+
* @param options.exclude - Filter pattern to exclude specific files.
|
|
23
|
+
* @returns A Vite plugin object.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* This plugin is intended to be used only during the Vite library build process.
|
|
27
|
+
* It resolves asset IDs, emits assets, and exports them as URLs.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // vite.config.ts
|
|
32
|
+
* import { ExternalAppAssetPlugin } from '@equinor/fusion-framework-cli/plugins/app-assets-plugin';
|
|
33
|
+
*
|
|
34
|
+
* export default {
|
|
35
|
+
* plugins: [
|
|
36
|
+
* ExternalAppAssetPlugin({
|
|
37
|
+
* name: 'my-asset',
|
|
38
|
+
* include: ['svg', 'png'],
|
|
39
|
+
* exclude: 'node_modules/**',
|
|
40
|
+
* }),
|
|
41
|
+
* ],
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const AppAssetExportPlugin = (options = {}) => {
|
|
46
|
+
const { name, include = defaultInclude, exclude } = options;
|
|
47
|
+
let viteConfig;
|
|
48
|
+
const assetsPathMap = new Map();
|
|
49
|
+
const filter = createFilter(include, exclude);
|
|
50
|
+
return {
|
|
51
|
+
name: PLUGIN_NAME,
|
|
52
|
+
enforce: 'pre',
|
|
53
|
+
apply: 'build',
|
|
54
|
+
configResolved(config) {
|
|
55
|
+
viteConfig = config;
|
|
56
|
+
},
|
|
57
|
+
resolveId(source_1) {
|
|
58
|
+
return __awaiter(this, arguments, void 0, function* (source, importer = '', opts) {
|
|
59
|
+
var _a;
|
|
60
|
+
if (viteConfig.build.lib === false) {
|
|
61
|
+
this.warn(`this plugin is only for vite build lib`);
|
|
62
|
+
}
|
|
63
|
+
// skip resolves triggered by plugin self
|
|
64
|
+
if (((_a = opts.custom) === null || _a === void 0 ? void 0 : _a.caller) === PLUGIN_NAME) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// resolve asset ID, the ID should refer to the actual asset file
|
|
68
|
+
const assetId = yield resolveAssetId(this, source, importer, Object.assign(Object.assign({}, opts), { custom: Object.assign(Object.assign({}, opts.custom), { caller: PLUGIN_NAME }) }));
|
|
69
|
+
// skip if asset is not found or filtered out
|
|
70
|
+
const { id } = assetId !== null && assetId !== void 0 ? assetId : {};
|
|
71
|
+
const shouldIncludeAsset = id && filter(id);
|
|
72
|
+
if (!shouldIncludeAsset) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
// emit asset and index the asset path
|
|
77
|
+
const { outDir, assetsDir } = viteConfig.build;
|
|
78
|
+
const assetPath = emitAssetSync(this, id, {
|
|
79
|
+
name,
|
|
80
|
+
outDir,
|
|
81
|
+
assetsDir,
|
|
82
|
+
});
|
|
83
|
+
assetsPathMap.set(id, assetPath);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
this.warn(err.message);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
load(id) {
|
|
92
|
+
// lookup asset path and export as URL
|
|
93
|
+
const assetPath = assetsPathMap.get(id);
|
|
94
|
+
if (assetPath) {
|
|
95
|
+
// ensure asset path is relative from the script load path
|
|
96
|
+
return `export default new URL(/* @vite-ignore */'${assetPath}', import.meta.url).href`;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export default AppAssetExportPlugin;
|
|
102
|
+
//# sourceMappingURL=app-asset-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-asset-plugin.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets/app-asset-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EA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KACP,MAAM,kCACC,IAAI,CAAC,MAAM,KACd,MAAM,EAAE,WAAW,OAEzB,CAAC;gBAEH,6CAA6C;gBAC7C,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;gBAC7B,MAAM,kBAAkB,GAAG,EAAE,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;gBAC5C,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBACtB,OAAO,IAAI,CAAC;gBAChB,CAAC;gBAED,IAAI,CAAC;oBACD,sCAAsC;oBACtC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;oBAC/C,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE;wBACtC,IAAI;wBACJ,MAAM;wBACN,SAAS;qBACZ,CAAC,CAAC;oBACH,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,SAAU,CAAC,CAAC;gBACtC,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACX,IAAI,CAAC,IAAI,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;oBAClC,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;SAAA;QACD,IAAI,CAAC,EAAE;YACH,sCAAsC;YACtC,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACxC,IAAI,SAAS,EAAE,CAAC;gBACZ,0DAA0D;gBAC1D,OAAO,6CAA6C,SAAS,0BAA0B,CAAC;YAC5F,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { interpolateName } from 'loader-utils';
|
|
3
|
+
import { readAssetContentSync } from './read-asset-content.js';
|
|
4
|
+
/**
|
|
5
|
+
* Synchronously emits an asset file based on the provided context and options.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The plugin context used for emitting the file and logging warnings.
|
|
8
|
+
* @param id - The identifier of the asset, which may include a resource query.
|
|
9
|
+
* @param options - Optional parameters for customizing the emitted asset.
|
|
10
|
+
* @param options.name - The name template for the emitted asset file. Defaults to '[name].[ext]'.
|
|
11
|
+
* @param options.outDir - The output directory where the asset will be emitted. Defaults to 'dist'.
|
|
12
|
+
* @param options.assetsDir - The directory within the output directory where assets will be stored. Defaults to 'assets'.
|
|
13
|
+
* @returns The path of the emitted asset relative to the assets directory, or null if the asset content could not be read.
|
|
14
|
+
*/
|
|
15
|
+
export const emitAssetSync = (context, id, options = {}) => {
|
|
16
|
+
const { outDir = 'dist', assetsDir = 'assets', name = '[name].[ext]' } = options;
|
|
17
|
+
const [originalFileName, resourceQuery] = id.split('?');
|
|
18
|
+
// read asset content, early return if not found
|
|
19
|
+
const content = readAssetContentSync(id);
|
|
20
|
+
if (!content || content.byteLength === 0) {
|
|
21
|
+
throw new Error(`Could not read asset content for ${id}`);
|
|
22
|
+
}
|
|
23
|
+
// generate asset file name
|
|
24
|
+
const url = interpolateName({
|
|
25
|
+
resourcePath: originalFileName,
|
|
26
|
+
resourceQuery,
|
|
27
|
+
}, name, { content });
|
|
28
|
+
const assetPath = path.posix.join(assetsDir, url);
|
|
29
|
+
const fileName = assetPath.replace(`?${resourceQuery}`, '');
|
|
30
|
+
const fullName = path.join(path.isAbsolute(outDir) ? process.cwd() : '', outDir, assetPath);
|
|
31
|
+
// write asset to file
|
|
32
|
+
context.emitFile({
|
|
33
|
+
fileName,
|
|
34
|
+
name: fullName,
|
|
35
|
+
type: 'asset',
|
|
36
|
+
source: content,
|
|
37
|
+
});
|
|
38
|
+
return assetPath;
|
|
39
|
+
};
|
|
40
|
+
export default emitAssetSync;
|
|
41
|
+
//# sourceMappingURL=emit-asset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-asset.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets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AO,CAAC,QAAQ,CAAC;QACb,QAAQ;QACR,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes the leading dot from a file extension string.
|
|
3
|
+
* `.` are a RegExp special character, so it needs to be escaped.
|
|
4
|
+
*/
|
|
5
|
+
const trimLeadingDot = (ext) => ext.replace(/^\./, '');
|
|
6
|
+
/**
|
|
7
|
+
* Creates a regular expression pattern to filter files based on their extensions.
|
|
8
|
+
*
|
|
9
|
+
* @param exts - An array of file extensions to include in the pattern.
|
|
10
|
+
* @returns A RegExp object that matches files with the specified extensions.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const pattern = createExtensionFilterPattern(['.js', '.ts']);
|
|
15
|
+
* console.log(pattern); // Output: /\.(js|ts)(\?.*)?$/
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const createExtensionFilterPattern = (exts) => new RegExp(`\\.(${exts.map(trimLeadingDot).join('|')})(\\?.*)?$`);
|
|
19
|
+
export default createExtensionFilterPattern;
|
|
20
|
+
//# sourceMappingURL=extension-filter-pattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-filter-pattern.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets/extension-filter-pattern.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAc,EAAE,EAAE,CAC3D,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAEtE,eAAe,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,IAAI,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* Cache for the content of assets.
|
|
4
|
+
*/
|
|
5
|
+
const assetsContentMap = new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Reads the content of an asset synchronously.
|
|
8
|
+
*
|
|
9
|
+
* @param id - The identifier of the asset, which can include a query string.
|
|
10
|
+
* @returns The content of the asset as a Buffer if it exists, otherwise null.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* - If the asset content is already cached, it returns the cached content.
|
|
14
|
+
* - The function extracts the filename from the identifier by removing any query string.
|
|
15
|
+
* - If the file exists, it reads the content, caches it, and then returns it.
|
|
16
|
+
* - If the file does not exist, it logs a warning and returns null.
|
|
17
|
+
*/
|
|
18
|
+
export const readAssetContentSync = (id) => {
|
|
19
|
+
// check if the asset is already loaded
|
|
20
|
+
if (assetsContentMap.has(id)) {
|
|
21
|
+
return assetsContentMap.get(id);
|
|
22
|
+
}
|
|
23
|
+
// extract the filename without query
|
|
24
|
+
const [pureId] = id.split('?');
|
|
25
|
+
// if the file exists, read, cache and return content
|
|
26
|
+
if (existsSync(pureId)) {
|
|
27
|
+
const content = readFileSync(pureId);
|
|
28
|
+
assetsContentMap.set(id, content);
|
|
29
|
+
return content;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
export default readAssetContentSync;
|
|
34
|
+
//# sourceMappingURL=read-asset-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-asset-content.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets/read-asset-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAU,EAAiB,EAAE;IAC9D,uCAAuC;IACvC,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QAC3B,OAAO,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;IACrC,CAAC;IAED,qCAAqC;IACrC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE/B,qDAAqD;IACrD,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACrC,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { PLUGIN_NAME } from './static.js';
|
|
13
|
+
/**
|
|
14
|
+
* Try to resolve the assets directly based on the ID and importer.
|
|
15
|
+
*/
|
|
16
|
+
const localResolve = (id, importer) => {
|
|
17
|
+
if (path.isAbsolute(id)) {
|
|
18
|
+
return { id, external: 'absolute', resolvedBy: PLUGIN_NAME };
|
|
19
|
+
}
|
|
20
|
+
else if (id.startsWith('.')) {
|
|
21
|
+
return {
|
|
22
|
+
id: path.resolve(path.dirname(importer), id),
|
|
23
|
+
external: 'relative',
|
|
24
|
+
resolvedBy: PLUGIN_NAME,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the asset ID based on the provided context, ID, importer, and options.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The plugin context used for resolving the ID.
|
|
33
|
+
* @param id - The asset ID to resolve.
|
|
34
|
+
* @param importer - The path of the module that is importing the asset.
|
|
35
|
+
* @param options - Optional resolution options.
|
|
36
|
+
* @returns A promise that resolves to a `PartialResolvedId` object or `null`.
|
|
37
|
+
*
|
|
38
|
+
* The function handles three cases:
|
|
39
|
+
* 1. If the ID is an absolute path, it returns an object with the ID, marked as external and resolved by the plugin.
|
|
40
|
+
* 2. If the ID is a relative path, it resolves the path relative to the importer and returns an object with the resolved ID, marked as external and resolved by the plugin.
|
|
41
|
+
* 3. For all other cases, it delegates the resolution to the context's resolve method.
|
|
42
|
+
*/
|
|
43
|
+
export const resolveAssetId = (context, id, importer, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const resolve = localResolve(id, importer);
|
|
45
|
+
/**
|
|
46
|
+
* Check if the asset can be resolved locally.
|
|
47
|
+
* If the asset is found, return the resolved asset.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* The Id alone might not be enough to resolve the asset.
|
|
51
|
+
* Rollup only gives the ID as the import from the source.
|
|
52
|
+
*
|
|
53
|
+
* For example, if the import is `import svgData from './assets/image.svg';`,
|
|
54
|
+
* the actual file is `./assets/image.svg.js`.
|
|
55
|
+
*
|
|
56
|
+
* In this we try to as the context to resolve the ID.
|
|
57
|
+
*/
|
|
58
|
+
if (resolve && fs.existsSync(resolve.id)) {
|
|
59
|
+
return resolve;
|
|
60
|
+
}
|
|
61
|
+
return yield context.resolve(id, importer, options);
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=resolve-asset-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-asset-id.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets/resolve-asset-id.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,QAAgB,EAA4B,EAAE;IAC5E,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IACjE,CAAC;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YAC5C,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,WAAW;SAC1B,CAAC;IACN,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,OAAsB,EACtB,EAAU,EACV,QAAgB,EAChB,OAAiD,EAChB,EAAE;IACnC,MAAM,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC3C;;;;;;;;;;;;OAYG;IACH,IAAI,OAAO,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const PLUGIN_NAME = 'vite:fusion:app-assets';
|
|
2
|
+
/**
|
|
3
|
+
* General asset extensions.
|
|
4
|
+
*/
|
|
5
|
+
export const ASSET_EXTENSIONS = [
|
|
6
|
+
// Images
|
|
7
|
+
...['png', 'jpg', 'jpeg', 'gif', 'svg', 'ico', 'webp'],
|
|
8
|
+
// Videos and audio
|
|
9
|
+
...['mp4', 'webm', 'mp3'],
|
|
10
|
+
// Fonts
|
|
11
|
+
...['woff2', 'woff', 'eot', 'ttf', 'otf'],
|
|
12
|
+
// Documents
|
|
13
|
+
...['pdf', 'md', 'txt'],
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-assets/static.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,SAAS;IACT,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;IACtD,mBAAmB;IACnB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;IACzB,QAAQ;IACR,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;IACzC,YAAY;IACZ,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* Preserve token for executing proxy assets
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This assumes the client will execute a api call using bearer token before
|
|
15
|
+
* acquiring a asset. By default the Framework will execute a rest call to load
|
|
16
|
+
* application manifest for resolving build assets to import.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This is a quick and dirty method to authorize requests without bearer token
|
|
20
|
+
* like browser `import`.
|
|
21
|
+
* The correct way would be to have a auth controller within the dev-server,
|
|
22
|
+
* but since the token is only exposed to the plugin and the cli is a tool for local
|
|
23
|
+
* development, this should be sufficient.
|
|
24
|
+
*/
|
|
25
|
+
let __APP_API_TOKEN__ = '';
|
|
26
|
+
/**
|
|
27
|
+
* The `appProxyPlugin` function creates a Vite plugin that configures a proxy for API and bundle requests
|
|
28
|
+
* to the Fusion apps backend. It also serves the app manifest, config, and local bundles if an app is provided.
|
|
29
|
+
*
|
|
30
|
+
* @param {AppProxyPluginOptions} options - The options for configuring the app proxy plugin.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Plugin} - The configured Vite plugin.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const plugin = appProxyPlugin({
|
|
37
|
+
* proxy: {
|
|
38
|
+
* path: '/app-proxy',
|
|
39
|
+
* target: 'https://fusion-s-apps-ci.azurewebsites.net/',
|
|
40
|
+
* onProxyReq: (proxyReq, req, res) => {
|
|
41
|
+
* proxyReq.on('response', (res) => { console.log(res.statusCode) });
|
|
42
|
+
* },
|
|
43
|
+
* },
|
|
44
|
+
* app: {
|
|
45
|
+
* key: 'my-app',
|
|
46
|
+
* version: '1.0.0',
|
|
47
|
+
* generateConfig: async () => ({}),
|
|
48
|
+
* generateManifest: async () => ({}),
|
|
49
|
+
* },
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // api calls
|
|
53
|
+
* fetch('/app-proxy/apps/my-app/builds/1.0.0/config'); // will generate app config by provided function
|
|
54
|
+
* fetch('/app-proxy/apps/my-app/builds/0.0.9/config'); // will proxy to the target, since version does not match
|
|
55
|
+
* fetch('/app-proxy/apps/other-app/builds/1.0.0/config'); // will proxy to the target, since app key does not match
|
|
56
|
+
*
|
|
57
|
+
* // asset calls
|
|
58
|
+
* fetch('/app-proxy/bundles/my-app/builds/1.0.0/index.js'); // will generate bundle by provided function
|
|
59
|
+
* fetch('/app-proxy/bundles/my-app/builds/0.0.9/index.js'); // will proxy to the target, since version does not match
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
export const appProxyPlugin = (options) => {
|
|
64
|
+
const { proxy: { onProxyReq = () => void 0, path: proxyPath, target }, } = options;
|
|
65
|
+
return {
|
|
66
|
+
name: 'fusion:app-proxy',
|
|
67
|
+
apply: 'serve',
|
|
68
|
+
config(config) {
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = config.server) !== null && _a !== void 0 ? _a : (config.server = {});
|
|
71
|
+
config.server.proxy = {
|
|
72
|
+
// proxy all api calls to the fusion apps backend
|
|
73
|
+
[proxyPath]: {
|
|
74
|
+
target,
|
|
75
|
+
changeOrigin: true,
|
|
76
|
+
secure: false,
|
|
77
|
+
rewrite: (path) => path.replace(proxyPath, ''),
|
|
78
|
+
configure: (proxy) => {
|
|
79
|
+
proxy.on('proxyReq', (proxyReq) => {
|
|
80
|
+
const token = proxyReq.getHeader('authorization');
|
|
81
|
+
if (typeof token === 'string') {
|
|
82
|
+
// preserve token for executing proxy assets
|
|
83
|
+
__APP_API_TOKEN__ = token;
|
|
84
|
+
}
|
|
85
|
+
else if (__APP_API_TOKEN__) {
|
|
86
|
+
// apply token to proxy request
|
|
87
|
+
proxyReq.setHeader('authorization', __APP_API_TOKEN__);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
proxy.on('proxyReq', onProxyReq);
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
configureServer(server) {
|
|
96
|
+
const { app } = options;
|
|
97
|
+
// disable local assets if no app configuration provided
|
|
98
|
+
if (!app)
|
|
99
|
+
return;
|
|
100
|
+
// serve app config if request matches the current app and version
|
|
101
|
+
const configPath = `${proxyPath}/apps/${app.key}/builds/${app.version}/config`;
|
|
102
|
+
server.middlewares.use(configPath, (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
res.setHeader('content-type', 'application/json');
|
|
104
|
+
res.end(JSON.stringify(yield app.generateConfig()));
|
|
105
|
+
}));
|
|
106
|
+
// serve app manifest if request matches the current app
|
|
107
|
+
// todo this should have version
|
|
108
|
+
const manifestPath = `${proxyPath}/apps/${app.key}`;
|
|
109
|
+
server.middlewares.use(manifestPath, (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
res.setHeader('content-type', 'application/json');
|
|
111
|
+
res.end(JSON.stringify(yield app.generateManifest()));
|
|
112
|
+
}));
|
|
113
|
+
// serve local bundles if request matches the current app and version
|
|
114
|
+
const bundlePath = `${proxyPath}/bundles/apps/${app.key}/${app.version}`;
|
|
115
|
+
server.middlewares.use((req, _res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
var _a;
|
|
117
|
+
if ((_a = req.url) === null || _a === void 0 ? void 0 : _a.match(bundlePath)) {
|
|
118
|
+
// remove proxy path from url
|
|
119
|
+
req.url = req.url.replace(bundlePath, '');
|
|
120
|
+
}
|
|
121
|
+
next();
|
|
122
|
+
}));
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export default appProxyPlugin;
|
|
127
|
+
//# sourceMappingURL=app-proxy-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-proxy-plugin.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-proxy/app-proxy-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAQA;;;;;;;;;;;;;;GAcG;AACH,IAAI,iBAAiB,GAAG,EAAE,CAAC;AA+B3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAA8B,EAAU,EAAE;IACrE,MAAM,EACF,KAAK,EAAE,EAAE,UAAU,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAChE,GAAG,OAAO,CAAC;IACZ,OAAO;QACH,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,OAAO;QACd,MAAM,CAAC,MAAM;;YACT,MAAA,MAAM,CAAC,MAAM,oCAAb,MAAM,CAAC,MAAM,GAAK,EAAE,EAAC;YACrB,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG;gBAClB,iDAAiD;gBACjD,CAAC,SA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AAC,CAAA,CAAC,CAAC;YAEH,wDAAwD;YACxD,gCAAgC;YAChC,MAAM,YAAY,GAAG,GAAG,SAAS,SAAS,GAAG,CAAC,GAAG,EAAE,CAAC;YACpD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,CAAO,IAAI,EAAE,GAAG,EAAE,EAAE;gBACrD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;gBAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC,CAAA,CAAC,CAAC;YAEH,qEAAqE;YACrE,MAAM,UAAU,GAAG,GAAG,SAAS,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACzE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;;gBAC7C,IAAI,MAAA,GAAG,CAAC,GAAG,0CAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC7B,6BAA6B;oBAC7B,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAC/C,CAAC;gBACD,IAAI,EAAE,CAAC;YACX,CAAC,CAAA,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-proxy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAA8B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
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 { join } from 'node:path';
|
|
11
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
12
|
+
import mime from 'mime';
|
|
13
|
+
import { createFilter } from 'vite';
|
|
14
|
+
/**
|
|
15
|
+
* Creates a plugin that serves an external public directory.
|
|
16
|
+
*
|
|
17
|
+
* This plugin is useful when you want to serve a static site from a different directory than the one where the Vite server is running.
|
|
18
|
+
* Vite`s built in `mode: 'spa'` will only look for the `index.html` file in the configured `root` directory,
|
|
19
|
+
* so this plugin is necessary to serve the `index.html` file from a different directory.
|
|
20
|
+
*
|
|
21
|
+
* @param path - The path to the external public directory.
|
|
22
|
+
* @param options - Optional filter patterns to include or exclude specific assets.
|
|
23
|
+
* @param options.include - A filter pattern to include specific assets.
|
|
24
|
+
* @param options.exclude - A filter pattern to exclude specific assets.
|
|
25
|
+
* @returns A Vite plugin object.
|
|
26
|
+
*
|
|
27
|
+
* The plugin:
|
|
28
|
+
* - Sets the `path` configuration to the provided path.
|
|
29
|
+
* - Adds a middleware to the server that serves static assets from the specified path.
|
|
30
|
+
* - Adds a middleware to the server that serves the `index.html` file from the specified path.
|
|
31
|
+
*
|
|
32
|
+
* The middleware:
|
|
33
|
+
* - Checks if the request is for a static asset and serves it from the specified path.
|
|
34
|
+
* - Reads the `index.html` file from the specified path.
|
|
35
|
+
* - Transforms the HTML using the server's `transformIndexHtml` method.
|
|
36
|
+
* - Responds with the transformed HTML, setting appropriate headers.
|
|
37
|
+
*/
|
|
38
|
+
export const externalPublicPlugin = (path, options) => {
|
|
39
|
+
let viteConfig;
|
|
40
|
+
const assetFilter = createFilter(options === null || options === void 0 ? void 0 : options.include, options === null || options === void 0 ? void 0 : options.exclude);
|
|
41
|
+
return {
|
|
42
|
+
name: 'fusion:external-public',
|
|
43
|
+
apply: 'serve',
|
|
44
|
+
configResolved(config) {
|
|
45
|
+
viteConfig = config;
|
|
46
|
+
},
|
|
47
|
+
configureServer(server) {
|
|
48
|
+
// serve the static assets from the provided path
|
|
49
|
+
server.middlewares.use((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a;
|
|
51
|
+
const [urlPath] = req.url.split('?');
|
|
52
|
+
const assetPath = join(path, urlPath);
|
|
53
|
+
if (!assetFilter(assetPath) ||
|
|
54
|
+
(
|
|
55
|
+
// skip if the request is for index.html
|
|
56
|
+
(_a = req.url) === null || _a === void 0 ? void 0 : _a.match('index.html')) ||
|
|
57
|
+
// skip if request is for a source file
|
|
58
|
+
existsSync(join(viteConfig.root, urlPath)) ||
|
|
59
|
+
// skip if asset is in publicDir
|
|
60
|
+
existsSync(join(viteConfig.publicDir, urlPath)) ||
|
|
61
|
+
// skip if asset does not exist
|
|
62
|
+
!existsSync(assetPath)) {
|
|
63
|
+
return next();
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const content = readFileSync(assetPath);
|
|
67
|
+
const contentType = mime.getType(assetPath) || 'application/octet-stream';
|
|
68
|
+
res.writeHead(200, Object.assign({ 'content-type': contentType, 'content-length': Buffer.byteLength(content), 'cache-control': 'no-cache' }, server.config.server.headers));
|
|
69
|
+
res.end(content);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
next(e);
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
// intercept requests to serve the index.html file
|
|
76
|
+
server.middlewares.use((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
var _a;
|
|
78
|
+
if (
|
|
79
|
+
// Only accept GET or HEAD
|
|
80
|
+
(req.method !== 'GET' && req.method !== 'HEAD') ||
|
|
81
|
+
// Only accept text/html
|
|
82
|
+
!((_a = req.headers.accept) === null || _a === void 0 ? void 0 : _a.includes('text/html'))) {
|
|
83
|
+
return next();
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
// load the raw html from provided path
|
|
87
|
+
const htmlRaw = readFileSync(join(path, 'index.html'), 'utf-8');
|
|
88
|
+
// transform the html, this is where vite plugin hooks are applied
|
|
89
|
+
const html = yield server.transformIndexHtml(req.url, htmlRaw, req.originalUrl);
|
|
90
|
+
// apply content headers and configured additional headers
|
|
91
|
+
res.writeHead(200, Object.assign({ 'content-type': 'text/html', 'content-length': Buffer.byteLength(html), 'cache-control': 'no-cache' }, server.config.server.headers));
|
|
92
|
+
// send the transformed html and end the response
|
|
93
|
+
res.end(html);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
next(e);
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export default externalPublicPlugin;
|
|
103
|
+
//# sourceMappingURL=external-public-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-public-plugin.js","sourceRoot":"","sources":["../../../../src/lib/plugins/external-public/external-public-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAwD,MAAM,MAAM,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAChC,IAAY,EACZ,OAGC,EACK,EAAE;IACR,IAAI,UAA0B,CAAC;IAE/B,MAAM,WAAW,GAAG,YAA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T,IAAI,CAAC,CAAC,CAAC,CAAC;gBACZ,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/plugins/external-public/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/lib/utils/assert.js
CHANGED
|
@@ -13,7 +13,8 @@ export function assertObject(value, message) {
|
|
|
13
13
|
function assertObjectEntryValue(value, prop, message) {
|
|
14
14
|
assert(!!value, message !== null && message !== void 0 ? message : `missing value of property ${prop}`);
|
|
15
15
|
}
|
|
16
|
-
export function assertObjectEntries(
|
|
16
|
+
export function assertObjectEntries(// extends Record<string, unknown> = unknown>(
|
|
17
|
+
value, options) {
|
|
17
18
|
var _a, _b, _c;
|
|
18
19
|
const preMessage = (_a = options === null || options === void 0 ? void 0 : options.preMessage) !== null && _a !== void 0 ? _a : '';
|
|
19
20
|
assert(typeof value === 'object', `${preMessage} to be an <object>`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/lib/utils/assert.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAElC,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,OAAgB;IACzD,MAAM,CACF,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EACpB,IAAI,cAAc,CAAC;QACf,OAAO;QACP,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,UAAU;KACvB,CAAC,CACL,CAAC;AACN,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,OAAwB;IAChE,MAAM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CAAC;IACrE,MAAM,SAAS,GACX,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,sBAAsB,CAAC;IACjD,MAAM,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,IAAI,IAAI,KAAK,EAAE,GAAG,UAAU,sBAAsB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1E,SAAS,CACL,KAAK,CAAC,IAAe,CAAC,EACtB,IAAoB,EACpB,GAAG,UAAU,cAAc,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAC3D,CAAC;IACN,CAAC;AACL,CAAC"}
|
package/dist/lib/utils/config.js
CHANGED
|
@@ -27,6 +27,9 @@ import { pathToFileURL } from 'node:url';
|
|
|
27
27
|
import { transpile } from './ts-transpile.js';
|
|
28
28
|
import { fileExists } from './file-exists.js';
|
|
29
29
|
export const supportedExt = ['.ts', '.mjs', '.js', '.json'];
|
|
30
|
+
/**
|
|
31
|
+
* @param filename name if config file without extension
|
|
32
|
+
*/
|
|
30
33
|
export const findConfigs = (filename, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
34
|
const _a = options !== null && options !== void 0 ? options : {}, { extensions } = _a, findOptions = __rest(_a, ["extensions"]);
|
|
32
35
|
extensions && assertConfigFileType(extensions);
|
|
@@ -68,6 +71,8 @@ export const loadConfig = (file) => __awaiter(void 0, void 0, void 0, function*
|
|
|
68
71
|
case '.json': {
|
|
69
72
|
return () => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield readFile(file, 'utf-8')); });
|
|
70
73
|
}
|
|
74
|
+
default:
|
|
75
|
+
throw Error('unsupported file type');
|
|
71
76
|
}
|
|
72
77
|
});
|
|
73
78
|
export function initiateConfig(config, ...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/utils/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAW,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/utils/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAW,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAU,CAAC;AAkCrE;;GAEG;AACH,MAAM,CAA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