@equinor/fusion-framework-cli 10.0.0-alpha-8601e3ca5d5b2d11057913cdfc04bbc5e908a598 → 10.0.0-alpha-8ca2072f748f36baccdefa6e0d6544f474e92730

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 (52) hide show
  1. package/CHANGELOG.md +53 -17
  2. package/dist/bin/build-application.js +18 -1
  3. package/dist/bin/build-application.js.map +1 -1
  4. package/dist/bin/create-dev-serve.js +3 -3
  5. package/dist/bin/create-dev-serve.js.map +1 -1
  6. package/dist/bin/public/assets/{index-CptNv55Q.js → index-_o_I3W6T.js} +354 -354
  7. package/dist/bin/public/index.html +1 -1
  8. package/dist/bin/utils/load-manifest.js +1 -1
  9. package/dist/bin/utils/load-manifest.js.map +1 -1
  10. package/dist/bin/utils/uploadAppBundle.js +2 -0
  11. package/dist/bin/utils/uploadAppBundle.js.map +1 -1
  12. package/dist/lib/app-manifest.js +5 -0
  13. package/dist/lib/app-manifest.js.map +1 -1
  14. package/dist/lib/plugins/app-assets/app-asset-plugin.js +102 -0
  15. package/dist/lib/plugins/app-assets/app-asset-plugin.js.map +1 -0
  16. package/dist/lib/plugins/app-assets/emit-asset.js +41 -0
  17. package/dist/lib/plugins/app-assets/emit-asset.js.map +1 -0
  18. package/dist/lib/plugins/app-assets/extension-filter-pattern.js +20 -0
  19. package/dist/lib/plugins/app-assets/extension-filter-pattern.js.map +1 -0
  20. package/dist/lib/plugins/app-assets/index.js +4 -0
  21. package/dist/lib/plugins/app-assets/index.js.map +1 -0
  22. package/dist/lib/plugins/app-assets/read-asset-content.js +34 -0
  23. package/dist/lib/plugins/app-assets/read-asset-content.js.map +1 -0
  24. package/dist/lib/plugins/app-assets/resolve-asset-id.js +63 -0
  25. package/dist/lib/plugins/app-assets/resolve-asset-id.js.map +1 -0
  26. package/dist/lib/plugins/app-assets/static.js +15 -0
  27. package/dist/lib/plugins/app-assets/static.js.map +1 -0
  28. package/dist/{bin/plugins/app-proxy.js → lib/plugins/app-proxy/app-proxy-plugin.js} +3 -3
  29. package/dist/lib/plugins/app-proxy/app-proxy-plugin.js.map +1 -0
  30. package/dist/lib/plugins/app-proxy/index.js +2 -0
  31. package/dist/lib/plugins/app-proxy/index.js.map +1 -0
  32. package/dist/{bin/plugins/external-public.js → lib/plugins/external-public/external-public-plugin.js} +43 -7
  33. package/dist/lib/plugins/external-public/external-public-plugin.js.map +1 -0
  34. package/dist/lib/plugins/external-public/index.js +2 -0
  35. package/dist/lib/plugins/external-public/index.js.map +1 -0
  36. package/dist/types/lib/plugins/app-assets/app-asset-plugin.d.ts +36 -0
  37. package/dist/types/lib/plugins/app-assets/emit-asset.d.ts +18 -0
  38. package/dist/types/lib/plugins/app-assets/extension-filter-pattern.d.ts +14 -0
  39. package/dist/types/lib/plugins/app-assets/index.d.ts +3 -0
  40. package/dist/types/lib/plugins/app-assets/read-asset-content.d.ts +14 -0
  41. package/dist/types/lib/plugins/app-assets/resolve-asset-id.d.ts +16 -0
  42. package/dist/types/lib/plugins/app-assets/static.d.ts +5 -0
  43. package/dist/types/lib/plugins/app-proxy/index.d.ts +1 -0
  44. package/dist/types/{bin/plugins/external-public.d.ts → lib/plugins/external-public/external-public-plugin.d.ts} +12 -4
  45. package/dist/types/lib/plugins/external-public/index.d.ts +1 -0
  46. package/dist/types/version.d.ts +1 -1
  47. package/dist/version.js +1 -1
  48. package/dist/version.js.map +1 -1
  49. package/package.json +19 -14
  50. package/dist/bin/plugins/app-proxy.js.map +0 -1
  51. package/dist/bin/plugins/external-public.js.map +0 -1
  52. /package/dist/types/{bin/plugins/app-proxy.d.ts → lib/plugins/app-proxy/app-proxy-plugin.d.ts} +0 -0
@@ -28,7 +28,7 @@
28
28
  }
29
29
  </style>
30
30
 
31
- <script type="module" crossorigin src="/assets/index-CptNv55Q.js"></script>
31
+ <script type="module" crossorigin src="/assets/index-_o_I3W6T.js"></script>
32
32
 
33
33
  <body>
34
34
  <div id="root"></div>
@@ -17,7 +17,7 @@ export const loadAppManifest = (env, pkg, options) => __awaiter(void 0, void 0,
17
17
  const baseManifest = yield createManifestFromPackage(pkg);
18
18
  spinner.info('created application manifest from package.json');
19
19
  // TODO - this need to come from the config
20
- if (env.mode !== 'development') {
20
+ if (env.command !== 'serve') {
21
21
  baseManifest.build.entryPoint =
22
22
  pkg.packageJson.type === 'module' ? 'app-bundle.js' : 'app-bundle.mjs';
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"load-manifest.js","sourceRoot":"","sources":["../../../src/bin/utils/load-manifest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAOtF,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,GAAsB,EACtB,GAAuB,EACvB,OAEC,EACgD,EAAE;IACnD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAChC,IAAI,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,MAAM,yBAAyB,CAAC,GAAG,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAE/D,2CAA2C;QAC3C,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAC7B,YAAY,CAAC,KAAM,CAAC,UAAU;gBAC1B,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAC/E,CAAC;QAED,OAAO,CAAC,IAAI,CACR,4BAA4B,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,KAAK,CAAC,KAAK,CAAC,GAAG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OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CACjF,CAAC;QACF,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -45,6 +45,8 @@ export const uploadAppBundle = (endpoint, bundle) => __awaiter(void 0, void 0, v
45
45
  throw new Error(`This app is deleted. HTTP message: ${requestBundle.statusText}`);
46
46
  }
47
47
  if (!requestBundle.ok) {
48
+ const json = yield requestBundle.json();
49
+ console.error(json);
48
50
  throw new Error(`Failed to publish bundle. HTTP status ${requestBundle.status}, ${requestBundle.statusText}`);
49
51
  }
50
52
  return yield requestBundle.json();
@@ -1 +1 @@
1
- {"version":3,"file":"uploadAppBundle.js","sourceRoot":"","sources":["../../../src/bin/utils/uploadAppBundle.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAO,QAAgB,EAAE,MAAc,EAAE,EAAE;IACtE,MAAM,KAAK,GAA8B;QACrC,MAAM,EAAE,IAAI;KACf,CAAC;IAEF,IAAI,CAAC;QACD,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAAC,WAAM,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,kBAAkB,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;QACxC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,KAAK,CAAC,MAAM;QAClB,OAAO,EAAE;YACL,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;YACnD,cAAc,EAAE,iBAAiB;SACpC;KACJ,CAAC,CAAC;IAEH,IAAI,aAAa,CAAC,MAAM,KAAK,GAAG,IAAI,aAA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veEntryPoint, } from './app-package.js';
13
13
  import { loadConfig, initiateConfig, resolveConfig, } from './utils/config.js';
14
14
  import { AssertionError, assert, assertObject } from './utils/assert.js';
15
15
  import { parse as parseSemver } from 'semver';
16
+ import { StandardIncludeAssetExtensions } from './plugins/app-assets/index.js';
16
17
  /** base filename for configuration files */
17
18
  export const manifestConfigFilename = 'app.manifest.config';
18
19
  /**
@@ -128,7 +129,11 @@ export const createManifestFromPackage = (pkg) => {
128
129
  timestamp: new Date().toISOString(),
129
130
  githubRepo: resolveGithubRepo(packageJson),
130
131
  commitSha: resolveGitCommitSha(),
132
+ annotations: packageJson.annotations,
131
133
  projectPage: packageJson.homepage,
134
+ allowedExtensions: StandardIncludeAssetExtensions.map(
135
+ // TODO: @jaysencpp, this is just 🫤, extensions should not require leading dot
136
+ (ext) => `.${ext}`),
132
137
  },
133
138
  };
134
139
  return manifest;
@@ -1 +1 @@
1
- {"version":3,"file":"app-manifest.js","sourceRoot":"","sources":["../../src/lib/app-manifest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAEH,aAAa,EAEb,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,UAAU,EACV,cAAc,EACd,aAAa,GAIhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAa9C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAiB,EAAE,EAAE,CAAC,EAAE,CAAC;AAE3D,MAAM,UAAU,iBAAiB,CAAC,KA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E,CACrB;SACJ;KACJ,CAAC;IACF,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,GAAsB,EACtB,IAAiB,EACjB,OAA6B,EACoB,EAAE;IACnD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,kBAAkB,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,kBAAkB,aAAlB,kBAAkB,cAAlB,kBAAkB,GAAI,EAAE,CAAgB,CAAC;QAC1E,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC7C,CAAC;SAAM,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,cAAc,CAAC;YACrB,OAAO,EAAE,kCAAkC,OAAO,CAAC,IAAI,EAAE;YACzD,QAAQ,EAAE,YAAY;SACzB,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC9B,CAAC,CAAA,CAAC"}
@@ -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,EAAE,YAAY,EAAwD,MAAM,MAAM,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,cAAc,GAAG,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MA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,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/emit-asset.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CACzB,OAAsB,EACtB,EAAU,EACV,UAII,EAAE,EACO,EAAE;IACf,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE,IAAI,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IACjF,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAExD,gDAAgD;IAChD,MAAM,OAAO,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACzC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,2BAA2B;IAC3B,MAAM,GAAG,GAAG,eAAe,CACvB;QACI,YAAY,EAAE,gBAAgB;QAC9B,aAAa;KACC,EAClB,IAAI,EACJ,EAAE,OAAO,EAAE,CACd,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAE5F,sBAAsB;IACtB,OAAO,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,4 @@
1
+ export { default, AppAssetExportPlugin } from './app-asset-plugin.js';
2
+ export { createExtensionFilterPattern } from './extension-filter-pattern.js';
3
+ export { ASSET_EXTENSIONS as StandardIncludeAssetExtensions } from './static.js';
4
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -78,12 +78,12 @@ export const appProxyPlugin = (options) => {
78
78
  configure: (proxy) => {
79
79
  proxy.on('proxyReq', (proxyReq) => {
80
80
  const token = proxyReq.getHeader('authorization');
81
- // preserve token for executing proxy assets
82
81
  if (typeof token === 'string') {
82
+ // preserve token for executing proxy assets
83
83
  __APP_API_TOKEN__ = token;
84
- // apply token to proxy request
85
84
  }
86
85
  else if (__APP_API_TOKEN__) {
86
+ // apply token to proxy request
87
87
  proxyReq.setHeader('authorization', __APP_API_TOKEN__);
88
88
  }
89
89
  });
@@ -124,4 +124,4 @@ export const appProxyPlugin = (options) => {
124
124
  };
125
125
  };
126
126
  export default appProxyPlugin;
127
- //# sourceMappingURL=app-proxy.js.map
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":";;;;;;;;;AAKA;;;;;;;;;;;;;;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,SAAS,CAAC,EAAE;oBACT,MAAM;oBACN,YAAY,EAAE,IAAI;oBAClB,MAAM,EAAE,KAAK;oBACb,OAAO,EAAE,CAAC,IAAI,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,OAAO,SAAS,CAAC;YAC/E,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,CAAO,IAAI,EAAE,GAAG,EAAE,EAAE;gBACnD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;gBAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;YACxD,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,2 @@
1
+ export { default, appProxyPlugin } from './app-proxy-plugin.js';
2
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -8,7 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { join } from 'node:path';
11
- import { readFileSync } from 'node:fs';
11
+ import { readFileSync, existsSync } from 'node:fs';
12
+ import mime from 'mime';
13
+ import { createFilter } from 'vite';
12
14
  /**
13
15
  * Creates a plugin that serves an external public directory.
14
16
  *
@@ -17,25 +19,59 @@ import { readFileSync } from 'node:fs';
17
19
  * so this plugin is necessary to serve the `index.html` file from a different directory.
18
20
  *
19
21
  * @param path - The path to the external public directory.
20
- * @returns A Plugin object configured to serve the specified 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.
21
26
  *
22
27
  * The plugin:
23
- * - Sets the `publicDir` configuration to the provided path.
28
+ * - Sets the `path` configuration to the provided path.
29
+ * - Adds a middleware to the server that serves static assets from the specified path.
24
30
  * - Adds a middleware to the server that serves the `index.html` file from the specified path.
25
31
  *
26
32
  * The middleware:
33
+ * - Checks if the request is for a static asset and serves it from the specified path.
27
34
  * - Reads the `index.html` file from the specified path.
28
35
  * - Transforms the HTML using the server's `transformIndexHtml` method.
29
36
  * - Responds with the transformed HTML, setting appropriate headers.
30
37
  */
31
- export const externalPublicPlugin = (path) => {
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);
32
41
  return {
33
42
  name: 'fusion:external-public',
34
43
  apply: 'serve',
35
- config(config) {
36
- config.publicDir = path;
44
+ configResolved(config) {
45
+ viteConfig = config;
37
46
  },
38
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
+ }));
39
75
  // intercept requests to serve the index.html file
40
76
  server.middlewares.use((req, res, next) => __awaiter(this, void 0, void 0, function* () {
41
77
  var _a;
@@ -64,4 +100,4 @@ export const externalPublicPlugin = (path) => {
64
100
  };
65
101
  };
66
102
  export default externalPublicPlugin;
67
- //# sourceMappingURL=external-public.js.map
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,YAAY,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;IAErE,OAAO;QACH,IAAI,EAAE,wBAAwB;QAC9B,KAAK,EAAE,OAAO;QACd,cA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} from './external-public-plugin.js';
2
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -0,0 +1,36 @@
1
+ import { type FilterPattern, type Plugin } from 'vite';
2
+ /**
3
+ * A Vite plugin to handle external resources in a library build.
4
+ *
5
+ * @param options - Configuration options for the plugin.
6
+ * @param options.name - Optional name for the emitted assets.
7
+ * @param options.include - Filter pattern to include specific files.
8
+ * @param options.exclude - Filter pattern to exclude specific files.
9
+ * @returns A Vite plugin object.
10
+ *
11
+ * @remarks
12
+ * This plugin is intended to be used only during the Vite library build process.
13
+ * It resolves asset IDs, emits assets, and exports them as URLs.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // vite.config.ts
18
+ * import { ExternalAppAssetPlugin } from '@equinor/fusion-framework-cli/plugins/app-assets-plugin';
19
+ *
20
+ * export default {
21
+ * plugins: [
22
+ * ExternalAppAssetPlugin({
23
+ * name: 'my-asset',
24
+ * include: ['svg', 'png'],
25
+ * exclude: 'node_modules/**',
26
+ * }),
27
+ * ],
28
+ * };
29
+ * ```
30
+ */
31
+ export declare const AppAssetExportPlugin: (options?: {
32
+ name?: string;
33
+ include?: FilterPattern;
34
+ exclude?: FilterPattern;
35
+ }) => Plugin;
36
+ export default AppAssetExportPlugin;
@@ -0,0 +1,18 @@
1
+ import { type PluginContext } from 'rollup';
2
+ /**
3
+ * Synchronously emits an asset file based on the provided context and options.
4
+ *
5
+ * @param context - The plugin context used for emitting the file and logging warnings.
6
+ * @param id - The identifier of the asset, which may include a resource query.
7
+ * @param options - Optional parameters for customizing the emitted asset.
8
+ * @param options.name - The name template for the emitted asset file. Defaults to '[name].[ext]'.
9
+ * @param options.outDir - The output directory where the asset will be emitted. Defaults to 'dist'.
10
+ * @param options.assetsDir - The directory within the output directory where assets will be stored. Defaults to 'assets'.
11
+ * @returns The path of the emitted asset relative to the assets directory, or null if the asset content could not be read.
12
+ */
13
+ export declare const emitAssetSync: (context: PluginContext, id: string, options?: {
14
+ name?: string;
15
+ outDir?: string;
16
+ assetsDir?: string;
17
+ }) => string | null;
18
+ export default emitAssetSync;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Creates a regular expression pattern to filter files based on their extensions.
3
+ *
4
+ * @param exts - An array of file extensions to include in the pattern.
5
+ * @returns A RegExp object that matches files with the specified extensions.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const pattern = createExtensionFilterPattern(['.js', '.ts']);
10
+ * console.log(pattern); // Output: /\.(js|ts)(\?.*)?$/
11
+ * ```
12
+ */
13
+ export declare const createExtensionFilterPattern: (exts: string[]) => RegExp;
14
+ export default createExtensionFilterPattern;
@@ -0,0 +1,3 @@
1
+ export { default, AppAssetExportPlugin } from './app-asset-plugin.js';
2
+ export { createExtensionFilterPattern } from './extension-filter-pattern.js';
3
+ export { ASSET_EXTENSIONS as StandardIncludeAssetExtensions } from './static.js';