@vendure/ui-devkit 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +5 -0
  3. package/client/devkit-client-api.d.ts +51 -0
  4. package/client/index.d.ts +1 -0
  5. package/client/index.js +1 -0
  6. package/compiler/compile.d.ts +9 -0
  7. package/compiler/compile.js +218 -0
  8. package/compiler/compile.js.map +1 -0
  9. package/compiler/constants.d.ts +6 -0
  10. package/compiler/constants.js +10 -0
  11. package/compiler/constants.js.map +1 -0
  12. package/compiler/helpers.d.ts +23 -0
  13. package/compiler/helpers.js +48 -0
  14. package/compiler/helpers.js.map +1 -0
  15. package/compiler/index.d.ts +3 -0
  16. package/compiler/index.js +16 -0
  17. package/compiler/index.js.map +1 -0
  18. package/compiler/scaffold.d.ts +3 -0
  19. package/compiler/scaffold.js +219 -0
  20. package/compiler/scaffold.js.map +1 -0
  21. package/compiler/translations.d.ts +12 -0
  22. package/compiler/translations.js +136 -0
  23. package/compiler/translations.js.map +1 -0
  24. package/compiler/types.d.ts +219 -0
  25. package/compiler/types.js +3 -0
  26. package/compiler/types.js.map +1 -0
  27. package/compiler/utils.d.ts +33 -0
  28. package/compiler/utils.js +125 -0
  29. package/compiler/utils.js.map +1 -0
  30. package/package.json +64 -0
  31. package/scaffold/README.md +7 -0
  32. package/scaffold/angular.json +119 -0
  33. package/scaffold/package.json +11 -0
  34. package/scaffold/src/app.module.ts +19 -0
  35. package/scaffold/src/app.routes.ts +49 -0
  36. package/scaffold/src/environment.prod.ts +3 -0
  37. package/scaffold/src/environment.ts +6 -0
  38. package/scaffold/src/extension.routes.ts +1 -0
  39. package/scaffold/src/global-styles.scss +1 -0
  40. package/scaffold/src/main.ts +17 -0
  41. package/scaffold/src/shared-extensions.module.ts +7 -0
  42. package/scaffold/src/tsconfig.app.json +18 -0
  43. package/scaffold/tsconfig.json +26 -0
@@ -0,0 +1 @@
1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,EAAE,CAAC;aACb;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { LanguageCode } from '@vendure/common/lib/generated-types';
2
+ import { TranslationExtension } from './types';
3
+ /**
4
+ * Given an array of extensions, returns a map of languageCode to all files specified by the
5
+ * configured globs.
6
+ */
7
+ export declare function getAllTranslationFiles(extensions: TranslationExtension[]): {
8
+ [languageCode in LanguageCode]?: string[];
9
+ };
10
+ export declare function mergeExtensionTranslations(outputPath: string, translationFiles: {
11
+ [languageCode in LanguageCode]?: string[];
12
+ }): Promise<void>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.mergeExtensionTranslations = exports.getAllTranslationFiles = void 0;
26
+ const fs = __importStar(require("fs-extra"));
27
+ const glob_1 = __importDefault(require("glob"));
28
+ const path = __importStar(require("path"));
29
+ const utils_1 = require("./utils");
30
+ /**
31
+ * Given an array of extensions, returns a map of languageCode to all files specified by the
32
+ * configured globs.
33
+ */
34
+ function getAllTranslationFiles(extensions) {
35
+ // First collect all globs by language
36
+ const allTranslationsWithGlobs = {};
37
+ for (const extension of extensions) {
38
+ for (const [languageCode, globPattern] of Object.entries(extension.translations || {})) {
39
+ const code = languageCode;
40
+ if (globPattern) {
41
+ if (!allTranslationsWithGlobs[code]) {
42
+ allTranslationsWithGlobs[code] = [globPattern];
43
+ }
44
+ else {
45
+ // tslint:disable-next-line:no-non-null-assertion
46
+ allTranslationsWithGlobs[code].push(globPattern);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ const allTranslationsWithFiles = {};
52
+ for (const [languageCode, globs] of Object.entries(allTranslationsWithGlobs)) {
53
+ const code = languageCode;
54
+ allTranslationsWithFiles[code] = [];
55
+ if (!globs) {
56
+ continue;
57
+ }
58
+ for (const pattern of globs) {
59
+ const files = glob_1.default.sync(pattern);
60
+ // tslint:disable-next-line:no-non-null-assertion
61
+ allTranslationsWithFiles[code].push(...files);
62
+ }
63
+ }
64
+ return allTranslationsWithFiles;
65
+ }
66
+ exports.getAllTranslationFiles = getAllTranslationFiles;
67
+ async function mergeExtensionTranslations(outputPath, translationFiles) {
68
+ // Now merge them into the final language-speicific json files
69
+ const i18nMessagesDir = path.join(outputPath, 'src/i18n-messages');
70
+ for (const [languageCode, files] of Object.entries(translationFiles)) {
71
+ if (!files) {
72
+ continue;
73
+ }
74
+ const translationFile = path.join(i18nMessagesDir, `${languageCode}.json`);
75
+ const translationBackupFile = path.join(i18nMessagesDir, `${languageCode}.json.bak`);
76
+ if (fs.existsSync(translationBackupFile)) {
77
+ // restore the original translations from the backup
78
+ await fs.copy(translationBackupFile, translationFile);
79
+ }
80
+ let translations = {};
81
+ if (fs.existsSync(translationFile)) {
82
+ // create a backup of the original (unextended) translations
83
+ await fs.copy(translationFile, translationBackupFile);
84
+ try {
85
+ translations = await fs.readJson(translationFile);
86
+ }
87
+ catch (e) {
88
+ utils_1.logger.error(`Could not load translation file: ${translationFile}`);
89
+ utils_1.logger.error(e);
90
+ }
91
+ }
92
+ for (const file of files) {
93
+ try {
94
+ const contents = await fs.readJson(file);
95
+ translations = mergeTranslations(translations, contents);
96
+ }
97
+ catch (e) {
98
+ utils_1.logger.error(`Could not load translation file: ${translationFile}`);
99
+ utils_1.logger.error(e);
100
+ }
101
+ }
102
+ // write the final translation files to disk
103
+ const sortedTranslations = sortTranslationKeys(translations);
104
+ await fs.writeFile(translationFile, JSON.stringify(sortedTranslations, null, 2), 'utf8');
105
+ }
106
+ }
107
+ exports.mergeExtensionTranslations = mergeExtensionTranslations;
108
+ /**
109
+ * Sorts the contents of the translation files so the sections & keys are alphabetical.
110
+ */
111
+ function sortTranslationKeys(translations) {
112
+ const result = {};
113
+ const sections = Object.keys(translations).sort();
114
+ for (const section of sections) {
115
+ const sortedTokens = Object.entries(translations[section])
116
+ .sort(([keyA], [keyB]) => (keyA < keyB ? -1 : 1))
117
+ .reduce((output, [key, val]) => ({ ...output, [key]: val }), {});
118
+ result[section] = sortedTokens;
119
+ }
120
+ return result;
121
+ }
122
+ /**
123
+ * Merges the second set of translations into the first, returning a new translations
124
+ * object.
125
+ */
126
+ function mergeTranslations(t1, t2) {
127
+ const result = { ...t1 };
128
+ for (const [section, translations] of Object.entries(t2)) {
129
+ result[section] = {
130
+ ...t1[section],
131
+ ...translations,
132
+ };
133
+ }
134
+ return result;
135
+ }
136
+ //# sourceMappingURL=translations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.js","sourceRoot":"","sources":["../src/compiler/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA+B;AAC/B,gDAAwB;AACxB,2CAA6B;AAG7B,mCAAiC;AAEjC;;;GAGG;AACH,SAAgB,sBAAsB,CAClC,UAAkC;IAElC,sCAAsC;IACtC,MAAM,wBAAwB,GAAkD,EAAE,CAAC;IACnF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAChC,KAAK,MAAM,CA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ib/generated-types';
2
+ export declare type Extension = AdminUiExtension | TranslationExtension | StaticAssetExtension | GlobalStylesExtension;
3
+ /**
4
+ * @description
5
+ * Defines extensions to the Admin UI translations. Can be used as a stand-alone extension definition which only adds translations
6
+ * without adding new UI functionality, or as part of a full {@link AdminUiExtension}.
7
+ *
8
+ * @docsCategory UiDevkit
9
+ * @docsPage AdminUiExtension
10
+ */
11
+ export interface TranslationExtension {
12
+ /**
13
+ * @description
14
+ * Optional object defining any translation files for the Admin UI. The value should be an object with
15
+ * the key as a 2-character [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes),
16
+ * and the value being a [glob](https://github.com/isaacs/node-glob) for any relevant
17
+ * translation files in JSON format.
18
+ *
19
+ * @example
20
+ * ```TypeScript
21
+ * translations: {
22
+ * en: path.join(__dirname, 'translations/*.en.json'),
23
+ * de: path.join(__dirname, 'translations/*.de.json'),
24
+ * }
25
+ * ```
26
+ */
27
+ translations: {
28
+ [languageCode in LanguageCode]?: string;
29
+ };
30
+ }
31
+ /**
32
+ * @description
33
+ * Defines extensions which copy static assets to the custom Admin UI application source asset directory.
34
+ *
35
+ * @docsCategory UiDevkit
36
+ * @docsPage AdminUiExtension
37
+ */
38
+ export interface StaticAssetExtension {
39
+ /**
40
+ * @description
41
+ * Optional array of paths to static assets which will be copied over to the Admin UI app's `/static`
42
+ * directory.
43
+ */
44
+ staticAssets: StaticAssetDefinition[];
45
+ }
46
+ /**
47
+ * @description
48
+ * Defines extensions which add global styles to the custom Admin UI application.
49
+ *
50
+ * @docsCategory UiDevkit
51
+ * @docsPage AdminUiExtension
52
+ */
53
+ export interface GlobalStylesExtension {
54
+ /**
55
+ * @description
56
+ * Specifies a path (or array of paths) to global style files (css or Sass) which will be
57
+ * incorporated into the Admin UI app global stylesheet.
58
+ */
59
+ globalStyles: string[] | string;
60
+ }
61
+ /**
62
+ * @description
63
+ * Defines extensions to the Admin UI application by specifying additional
64
+ * Angular [NgModules](https://angular.io/guide/ngmodules) which are compiled
65
+ * into the application.
66
+ *
67
+ * See [Extending the Admin UI](/docs/plugins/extending-the-admin-ui/) for
68
+ * detailed instructions.
69
+ *
70
+ * @docsCategory UiDevkit
71
+ * @docsPage AdminUiExtension
72
+ * @docsWeight 0
73
+ */
74
+ export interface AdminUiExtension extends Partial<TranslationExtension>, Partial<StaticAssetExtension>, Partial<GlobalStylesExtension> {
75
+ /**
76
+ * @description
77
+ * An optional ID for the extension module. Only used internally for generating
78
+ * import paths to your module. If not specified, a unique hash will be used as the id.
79
+ */
80
+ id?: string;
81
+ /**
82
+ * @description
83
+ * The path to the directory containing the extension module(s). The entire contents of this directory
84
+ * will be copied into the Admin UI app, including all TypeScript source files, html templates,
85
+ * scss style sheets etc.
86
+ */
87
+ extensionPath: string;
88
+ /**
89
+ * @description
90
+ * One or more Angular modules which extend the default Admin UI.
91
+ */
92
+ ngModules: Array<AdminUiExtensionSharedModule | AdminUiExtensionLazyModule>;
93
+ }
94
+ /**
95
+ * @description
96
+ * A static asset can be provided as a path to the asset, or as an object containing a path and a new
97
+ * name, which will cause the compiler to copy and then rename the asset.
98
+ *
99
+ * @docsCategory UiDevkit
100
+ * @docsPage AdminUiExtension
101
+ */
102
+ export declare type StaticAssetDefinition = string | {
103
+ path: string;
104
+ rename: string;
105
+ };
106
+ /**
107
+ * @description
108
+ * Configuration defining a single NgModule with which to extend the Admin UI.
109
+ *
110
+ * @docsCategory UiDevkit
111
+ * @docsPage AdminUiExtension
112
+ */
113
+ export interface AdminUiExtensionSharedModule {
114
+ /**
115
+ * @description
116
+ * Shared modules are directly imported into the main AppModule of the Admin UI
117
+ * and should be used to declare custom form components and define custom
118
+ * navigation items.
119
+ */
120
+ type: 'shared';
121
+ /**
122
+ * @description
123
+ * The name of the file containing the extension module class.
124
+ */
125
+ ngModuleFileName: string;
126
+ /**
127
+ * @description
128
+ * The name of the extension module class.
129
+ */
130
+ ngModuleName: string;
131
+ }
132
+ /**
133
+ * @description
134
+ * Configuration defining a single NgModule with which to extend the Admin UI.
135
+ *
136
+ * @docsCategory UiDevkit
137
+ * @docsPage AdminUiExtension
138
+ */
139
+ export interface AdminUiExtensionLazyModule {
140
+ /**
141
+ * @description
142
+ * Lazy modules are lazy-loaded at the `/extensions/` route and should be used for
143
+ * modules which define new views for the Admin UI.
144
+ */
145
+ type: 'lazy';
146
+ /**
147
+ * @description
148
+ * The route specifies the route at which the module will be lazy-loaded. E.g. a value
149
+ * of `'foo'` will cause the module to lazy-load when the `/extensions/foo` route
150
+ * is activated.
151
+ */
152
+ route: string;
153
+ /**
154
+ * @description
155
+ * The name of the file containing the extension module class.
156
+ */
157
+ ngModuleFileName: string;
158
+ /**
159
+ * @description
160
+ * The name of the extension module class.
161
+ */
162
+ ngModuleName: string;
163
+ }
164
+ /**
165
+ * @description
166
+ * Options to configure how the Admin UI should be compiled.
167
+ *
168
+ * @docsCategory UiDevkit
169
+ */
170
+ export interface UiExtensionCompilerOptions {
171
+ /**
172
+ * @description
173
+ * The directory into which the sources for the extended Admin UI will be copied.
174
+ */
175
+ outputPath: string;
176
+ /**
177
+ * @description
178
+ * An array of objects which configure Angular modules and/or
179
+ * translations with which to extend the Admin UI.
180
+ */
181
+ extensions: Extension[];
182
+ /**
183
+ * @description
184
+ * Set to `true` in order to compile the Admin UI in development mode (using the Angular CLI
185
+ * [ng serve](https://angular.io/cli/serve) command). When in dev mode, any changes to
186
+ * UI extension files will be watched and trigger a rebuild of the Admin UI with live
187
+ * reloading.
188
+ *
189
+ * @default false
190
+ */
191
+ devMode?: boolean;
192
+ /**
193
+ * @description
194
+ * Allows the baseHref of the compiled Admin UI app to be set. This determines the prefix
195
+ * of the app, for example with the default value of `'/admin/'`, the Admin UI app
196
+ * will be configured to be served from `http://<host>/admin/`.
197
+ *
198
+ * @default '/admin/'
199
+ */
200
+ baseHref?: string;
201
+ /**
202
+ * @description
203
+ * In watch mode, allows the port of the dev server to be specified. Defaults to the Angular CLI default
204
+ * of `4200`.
205
+ *
206
+ * @default 4200 | undefined
207
+ */
208
+ watchPort?: number;
209
+ }
210
+ export declare type Translations = {
211
+ [section: string]: {
212
+ [token: string]: string;
213
+ };
214
+ };
215
+ export interface BrandingOptions {
216
+ smallLogoPath?: string;
217
+ largeLogoPath?: string;
218
+ faviconPath?: string;
219
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/compiler/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { AdminUiExtension, Extension, GlobalStylesExtension, StaticAssetDefinition, StaticAssetExtension, TranslationExtension } from './types';
2
+ export declare const logger: {
3
+ log: (message: string) => void;
4
+ error: (message: string) => void;
5
+ };
6
+ /**
7
+ * Checks for the global yarn binary and returns true if found.
8
+ */
9
+ export declare function shouldUseYarn(): boolean;
10
+ /**
11
+ * Returns the string path of a static asset
12
+ */
13
+ export declare function getStaticAssetPath(staticAssetDef: StaticAssetDefinition): string;
14
+ /**
15
+ * Copy the @vendure/ui-devkit files to the static assets dir.
16
+ */
17
+ export declare function copyUiDevkit(outputPath: string): void;
18
+ /**
19
+ * Copies over any files defined by the extensions' `staticAssets` array to the shared
20
+ * static assets directory. When the app is built by the ng cli, this assets directory is
21
+ * the copied over to the final static assets location (i.e. http://domain/admin/assets/)
22
+ */
23
+ export declare function copyStaticAsset(outputPath: string, staticAssetDef: StaticAssetDefinition): Promise<void>;
24
+ /**
25
+ * Ensures each extension has an ID and a value for the optional properties.
26
+ * If not defined by the user, a deterministic ID is generated
27
+ * from a hash of the extension config.
28
+ */
29
+ export declare function normalizeExtensions(extensions?: AdminUiExtension[]): Array<Required<AdminUiExtension>>;
30
+ export declare function isAdminUiExtension(input: Extension): input is AdminUiExtension;
31
+ export declare function isTranslationExtension(input: Extension): input is TranslationExtension;
32
+ export declare function isStaticAssetExtension(input: Extension): input is StaticAssetExtension;
33
+ export declare function isGlobalStylesExtension(input: Extension): input is GlobalStylesExtension;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.isGlobalStylesExtension = exports.isStaticAssetExtension = exports.isTranslationExtension = exports.isAdminUiExtension = exports.normalizeExtensions = exports.copyStaticAsset = exports.copyUiDevkit = exports.getStaticAssetPath = exports.shouldUseYarn = exports.logger = void 0;
26
+ /* tslint:disable:no-console */
27
+ const chalk_1 = __importDefault(require("chalk"));
28
+ const child_process_1 = require("child_process");
29
+ const crypto_1 = require("crypto");
30
+ const fs = __importStar(require("fs-extra"));
31
+ const path = __importStar(require("path"));
32
+ const constants_1 = require("./constants");
33
+ exports.logger = {
34
+ log: (message) => console.log(chalk_1.default.green(message)),
35
+ error: (message) => console.log(chalk_1.default.red(message)),
36
+ };
37
+ /**
38
+ * Checks for the global yarn binary and returns true if found.
39
+ */
40
+ function shouldUseYarn() {
41
+ try {
42
+ child_process_1.execSync('yarnpkg --version', { stdio: 'ignore' });
43
+ return true;
44
+ }
45
+ catch (e) {
46
+ return false;
47
+ }
48
+ }
49
+ exports.shouldUseYarn = shouldUseYarn;
50
+ /**
51
+ * Returns the string path of a static asset
52
+ */
53
+ function getStaticAssetPath(staticAssetDef) {
54
+ return typeof staticAssetDef === 'string' ? staticAssetDef : staticAssetDef.path;
55
+ }
56
+ exports.getStaticAssetPath = getStaticAssetPath;
57
+ /**
58
+ * Copy the @vendure/ui-devkit files to the static assets dir.
59
+ */
60
+ function copyUiDevkit(outputPath) {
61
+ const devkitDir = path.join(outputPath, constants_1.STATIC_ASSETS_OUTPUT_DIR, 'devkit');
62
+ fs.ensureDirSync(devkitDir);
63
+ fs.copySync(require.resolve('@vendure/ui-devkit'), path.join(devkitDir, 'ui-devkit.js'));
64
+ }
65
+ exports.copyUiDevkit = copyUiDevkit;
66
+ /**
67
+ * Copies over any files defined by the extensions' `staticAssets` array to the shared
68
+ * static assets directory. When the app is built by the ng cli, this assets directory is
69
+ * the copied over to the final static assets location (i.e. http://domain/admin/assets/)
70
+ */
71
+ async function copyStaticAsset(outputPath, staticAssetDef) {
72
+ const staticAssetPath = getStaticAssetPath(staticAssetDef);
73
+ let assetOutputPath;
74
+ const assetBasename = path.basename(staticAssetPath);
75
+ assetOutputPath = path.join(outputPath, constants_1.STATIC_ASSETS_OUTPUT_DIR, assetBasename);
76
+ fs.copySync(staticAssetPath, assetOutputPath);
77
+ if (typeof staticAssetDef !== 'string') {
78
+ // The asset is being renamed
79
+ const newName = path.join(path.dirname(assetOutputPath), staticAssetDef.rename);
80
+ try {
81
+ // We use copy, remove rather than rename due to problems with the
82
+ // EPERM error in Windows.
83
+ await fs.copy(assetOutputPath, newName);
84
+ await fs.remove(assetOutputPath);
85
+ }
86
+ catch (e) {
87
+ exports.logger.log(e);
88
+ }
89
+ }
90
+ }
91
+ exports.copyStaticAsset = copyStaticAsset;
92
+ /**
93
+ * Ensures each extension has an ID and a value for the optional properties.
94
+ * If not defined by the user, a deterministic ID is generated
95
+ * from a hash of the extension config.
96
+ */
97
+ function normalizeExtensions(extensions) {
98
+ return (extensions || []).map(e => {
99
+ let id = e.id;
100
+ if (!id) {
101
+ const hash = crypto_1.createHash('sha256');
102
+ hash.update(JSON.stringify(e));
103
+ id = hash.digest('hex');
104
+ }
105
+ return { staticAssets: [], translations: {}, globalStyles: [], ...e, id };
106
+ });
107
+ }
108
+ exports.normalizeExtensions = normalizeExtensions;
109
+ function isAdminUiExtension(input) {
110
+ return input.hasOwnProperty('extensionPath');
111
+ }
112
+ exports.isAdminUiExtension = isAdminUiExtension;
113
+ function isTranslationExtension(input) {
114
+ return input.hasOwnProperty('translations');
115
+ }
116
+ exports.isTranslationExtension = isTranslationExtension;
117
+ function isStaticAssetExtension(input) {
118
+ return input.hasOwnProperty('staticAssets');
119
+ }
120
+ exports.isStaticAssetExtension = isStaticAssetExtension;
121
+ function isGlobalStylesExtension(input) {
122
+ return input.hasOwnProperty('globalStyles');
123
+ }
124
+ exports.isGlobalStylesExtension = isGlobalStylesExtension;
125
+ //# sourceMappingURL=utils.js.map