@hubspot/ui-extensions-dev-server 0.10.2 → 1.0.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 (95) hide show
  1. package/README.md +23 -4
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +4 -45
  4. package/dist/lib/DevModeInterface.d.ts +2 -2
  5. package/dist/lib/DevModeInterface.js +12 -28
  6. package/dist/lib/DevModeParentInterface.d.ts +2 -2
  7. package/dist/lib/DevModeParentInterface.js +138 -154
  8. package/dist/lib/DevModeUnifiedInterface.d.ts +2 -2
  9. package/dist/lib/DevModeUnifiedInterface.js +28 -49
  10. package/dist/lib/DevServerState.d.ts +9 -5
  11. package/dist/lib/DevServerState.js +37 -18
  12. package/dist/lib/ExtensionsWebSocket.d.ts +25 -0
  13. package/dist/lib/ExtensionsWebSocket.js +110 -0
  14. package/dist/lib/__mocks__/config.d.ts +2 -0
  15. package/dist/lib/__mocks__/config.js +5 -0
  16. package/dist/lib/__mocks__/isExtensionFile.d.ts +5 -0
  17. package/dist/lib/__mocks__/isExtensionFile.js +11 -0
  18. package/dist/lib/__tests__/DevModeInterface.spec.d.ts +1 -0
  19. package/dist/lib/__tests__/DevModeInterface.spec.js +155 -0
  20. package/dist/lib/__tests__/DevModeParentInterface.spec.d.ts +1 -0
  21. package/dist/lib/__tests__/DevModeParentInterface.spec.js +179 -0
  22. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.d.ts +1 -0
  23. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +236 -0
  24. package/dist/lib/__tests__/ExtensionsWebSocket.spec.d.ts +1 -0
  25. package/dist/lib/__tests__/ExtensionsWebSocket.spec.js +304 -0
  26. package/dist/lib/__tests__/ast.spec.d.ts +1 -0
  27. package/dist/lib/__tests__/ast.spec.js +737 -0
  28. package/dist/lib/__tests__/build.spec.d.ts +1 -0
  29. package/dist/lib/__tests__/build.spec.js +159 -0
  30. package/dist/lib/__tests__/config.spec.d.ts +1 -0
  31. package/dist/lib/__tests__/config.spec.js +291 -0
  32. package/dist/lib/__tests__/dev.spec.d.ts +1 -0
  33. package/dist/lib/__tests__/dev.spec.js +80 -0
  34. package/dist/lib/__tests__/extensionsService.spec.d.ts +1 -0
  35. package/dist/lib/__tests__/extensionsService.spec.js +150 -0
  36. package/dist/lib/__tests__/factories.d.ts +48 -0
  37. package/dist/lib/__tests__/factories.js +32 -0
  38. package/dist/lib/__tests__/fixtures/extensionConfig.d.ts +182 -0
  39. package/dist/lib/__tests__/fixtures/extensionConfig.js +304 -0
  40. package/dist/lib/__tests__/fixtures/urls.d.ts +4 -0
  41. package/dist/lib/__tests__/fixtures/urls.js +4 -0
  42. package/dist/lib/__tests__/parsing-utils.spec.d.ts +1 -0
  43. package/dist/lib/__tests__/parsing-utils.spec.js +467 -0
  44. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.d.ts +1 -0
  45. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.js +112 -0
  46. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.d.ts +1 -0
  47. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.js +82 -0
  48. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.d.ts +1 -0
  49. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +256 -0
  50. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.d.ts +1 -0
  51. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.js +65 -0
  52. package/dist/lib/__tests__/plugins/manifestPlugin.spec.d.ts +1 -0
  53. package/dist/lib/__tests__/plugins/manifestPlugin.spec.js +455 -0
  54. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.d.ts +1 -0
  55. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.js +81 -0
  56. package/dist/lib/__tests__/server.spec.d.ts +1 -0
  57. package/dist/lib/__tests__/server.spec.js +152 -0
  58. package/dist/lib/__tests__/test-utils/ast.d.ts +1 -0
  59. package/dist/lib/__tests__/test-utils/ast.js +4 -0
  60. package/dist/lib/__tests__/utils.spec.d.ts +1 -0
  61. package/dist/lib/__tests__/utils.spec.js +176 -0
  62. package/dist/lib/ast.d.ts +1 -1
  63. package/dist/lib/ast.js +22 -29
  64. package/dist/lib/bin/cli.js +52 -72
  65. package/dist/lib/build.d.ts +1 -1
  66. package/dist/lib/build.js +60 -78
  67. package/dist/lib/config.d.ts +1 -1
  68. package/dist/lib/config.js +31 -34
  69. package/dist/lib/constants.d.ts +0 -2
  70. package/dist/lib/constants.js +20 -27
  71. package/dist/lib/dev.d.ts +1 -1
  72. package/dist/lib/dev.js +52 -69
  73. package/dist/lib/extensionsService.d.ts +1 -1
  74. package/dist/lib/extensionsService.js +21 -15
  75. package/dist/lib/parsing-utils.d.ts +1 -1
  76. package/dist/lib/parsing-utils.js +7 -11
  77. package/dist/lib/plugins/codeBlockingPlugin.d.ts +1 -1
  78. package/dist/lib/plugins/codeBlockingPlugin.js +5 -8
  79. package/dist/lib/plugins/codeCheckingPlugin.d.ts +1 -1
  80. package/dist/lib/plugins/codeCheckingPlugin.js +10 -11
  81. package/dist/lib/plugins/devBuildPlugin.d.ts +2 -2
  82. package/dist/lib/plugins/devBuildPlugin.js +74 -99
  83. package/dist/lib/plugins/friendlyLoggingPlugin.d.ts +2 -2
  84. package/dist/lib/plugins/friendlyLoggingPlugin.js +4 -12
  85. package/dist/lib/plugins/manifestPlugin.d.ts +1 -1
  86. package/dist/lib/plugins/manifestPlugin.js +46 -26
  87. package/dist/lib/plugins/relevantModulesPlugin.d.ts +2 -2
  88. package/dist/lib/plugins/relevantModulesPlugin.js +4 -7
  89. package/dist/lib/server.d.ts +7 -2
  90. package/dist/lib/server.js +85 -84
  91. package/dist/lib/types.d.ts +1 -1
  92. package/dist/lib/types.js +4 -7
  93. package/dist/lib/utils.d.ts +1 -1
  94. package/dist/lib/utils.js +23 -40
  95. package/package.json +44 -31
@@ -1,27 +1,13 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- const node_fs_1 = __importDefault(require("node:fs"));
17
- const node_path_1 = __importDefault(require("node:path"));
18
- const node_util_1 = require("node:util");
19
- const node_child_process_1 = require("node:child_process");
20
- const commander_1 = require("commander");
21
- const ora_1 = __importDefault(require("ora"));
22
- const chalk_1 = __importDefault(require("chalk"));
23
- const build_1 = require("../build");
24
- const program = new commander_1.Command()
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { promisify } from 'node:util';
5
+ import { exec } from 'node:child_process';
6
+ import { Command } from 'commander';
7
+ import ora from 'ora';
8
+ import chalk from 'chalk';
9
+ import { remoteBuild } from "../build.js";
10
+ const program = new Command()
25
11
  .name('ui-extension-tools')
26
12
  .alias('uie')
27
13
  .description('Tools for managing and building HubSpot UI Extensions.');
@@ -49,34 +35,32 @@ program
49
35
  .option('-v, --profile-variables <path>', 'path to a json file with profile variables')
50
36
  .command('build <module>', { isDefault: true })
51
37
  .description('Build extension source code.')
52
- .action((module) => __awaiter(void 0, void 0, void 0, function* () {
38
+ .action(async (module) => {
53
39
  const options = getOptions(module);
54
- yield runCommand('lockfile', options);
55
- yield runCommand('install', options);
56
- yield runCommand('build', options);
57
- }));
40
+ await runCommand('lockfile', options);
41
+ await runCommand('install', options);
42
+ await runCommand('build', options);
43
+ });
58
44
  program.parse(process.argv);
59
- function runCommand(command, options) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const { start, fn, success, error } = buildSteps[command];
62
- const spinner = (0, ora_1.default)();
63
- try {
64
- spinner.start(start);
65
- yield fn(options);
66
- spinner.succeed(chalk_1.default.green(success));
67
- }
68
- catch (err) {
69
- spinner.fail(chalk_1.default.red(error));
70
- process.exit(1);
71
- }
72
- finally {
73
- spinner.stop();
74
- }
75
- });
45
+ async function runCommand(command, options) {
46
+ const { start, fn, success, error } = buildSteps[command];
47
+ const spinner = ora();
48
+ try {
49
+ spinner.start(start);
50
+ await fn(options);
51
+ spinner.succeed(chalk.green(success));
52
+ }
53
+ catch (err) {
54
+ spinner.fail(chalk.red(error));
55
+ process.exit(1);
56
+ }
57
+ finally {
58
+ spinner.stop();
59
+ }
76
60
  }
77
61
  // Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L59-L63
78
62
  function build({ extensionRoot, extensionDist, entrypoint, profileVariables, }) {
79
- return (0, build_1.remoteBuild)({
63
+ return remoteBuild({
80
64
  root: extensionRoot,
81
65
  entryPoint: entrypoint,
82
66
  outputDir: extensionDist,
@@ -86,43 +70,39 @@ function build({ extensionRoot, extensionDist, entrypoint, profileVariables, })
86
70
  });
87
71
  }
88
72
  // Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L53-L57
89
- function installDeps(options) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- yield execAsync('npm ci --ignore-scripts --no-audit --no-optional --no-fund', options);
92
- });
73
+ async function installDeps(options) {
74
+ await execAsync('npm ci --ignore-scripts --no-audit --no-optional --no-fund', options);
93
75
  }
94
76
  // Mirrors: https://git.hubteam.com/HubSpot/Artifactor/blob/f5cbea91d7a7dfb6278e878ae583e69022384fb5/ArtifactorFunctions/functions/node_18x/uie-remote-build/index.js#L131-L136
95
- function generateLockfile(options) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const { extensionRoot, spinner } = options;
98
- if (node_fs_1.default.existsSync(node_path_1.default.join(extensionRoot, 'package-lock.json'))) {
99
- spinner.info('Existing lockfile found, skipping generation');
100
- }
101
- else {
102
- spinner.info('No lockfile found, generating...');
103
- yield execAsync('npm install --package-lock-only', options);
104
- }
105
- });
77
+ async function generateLockfile(options) {
78
+ const { extensionRoot, spinner } = options;
79
+ if (fs.existsSync(path.join(extensionRoot, 'package-lock.json'))) {
80
+ spinner.info('Existing lockfile found, skipping generation');
81
+ }
82
+ else {
83
+ spinner.info('No lockfile found, generating...');
84
+ await execAsync('npm install --package-lock-only', options);
85
+ }
106
86
  }
107
87
  function getOptions(modulePath) {
108
- const entrypoint = node_path_1.default.isAbsolute(modulePath)
88
+ const entrypoint = path.isAbsolute(modulePath)
109
89
  ? modulePath
110
- : node_path_1.default.resolve(process.cwd(), modulePath);
111
- const extensionRoot = node_path_1.default.dirname(entrypoint);
112
- const extensionDist = node_path_1.default.join(extensionRoot, 'dist');
113
- const spinner = (0, ora_1.default)();
90
+ : path.resolve(process.cwd(), modulePath);
91
+ const extensionRoot = path.dirname(entrypoint);
92
+ const extensionDist = path.join(extensionRoot, 'dist');
93
+ const spinner = ora();
114
94
  // The Artifactor changes related to this are not yet available.
115
95
  // When it is, this will mirror the process where if applicable, a profile-variables.json file is available in the build bundle.
116
96
  const programOptions = program.opts();
117
97
  let profileVariables = {};
118
98
  if (programOptions.profileVariables) {
119
99
  const profileVariablePath = programOptions.profileVariables;
120
- const profileVariableFullPath = node_path_1.default.isAbsolute(profileVariablePath)
100
+ const profileVariableFullPath = path.isAbsolute(profileVariablePath)
121
101
  ? profileVariablePath
122
- : node_path_1.default.resolve(process.cwd(), profileVariablePath);
123
- if (node_fs_1.default.existsSync(profileVariableFullPath) &&
124
- node_path_1.default.extname(profileVariableFullPath) === '.json') {
125
- profileVariables = JSON.parse(node_fs_1.default.readFileSync(profileVariableFullPath, 'utf-8'));
102
+ : path.resolve(process.cwd(), profileVariablePath);
103
+ if (fs.existsSync(profileVariableFullPath) &&
104
+ path.extname(profileVariableFullPath) === '.json') {
105
+ profileVariables = JSON.parse(fs.readFileSync(profileVariableFullPath, 'utf-8'));
126
106
  }
127
107
  }
128
108
  return {
@@ -134,5 +114,5 @@ function getOptions(modulePath) {
134
114
  };
135
115
  }
136
116
  function execAsync(command, options) {
137
- return (0, node_util_1.promisify)(node_child_process_1.exec)(command, { cwd: options.extensionRoot });
117
+ return promisify(exec)(command, { cwd: options.extensionRoot });
138
118
  }
@@ -1,5 +1,5 @@
1
1
  import { InlineConfig } from 'vite';
2
- import { ManifestConfig } from './types';
2
+ import { ManifestConfig } from './types.ts';
3
3
  interface BuildSingleExtensionArgs {
4
4
  file: string;
5
5
  outputDir?: string;
package/dist/lib/build.js CHANGED
@@ -1,85 +1,67 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.extensionErrorBaseMessage = void 0;
16
- exports.buildSingleExtension = buildSingleExtension;
17
- exports.remoteBuild = remoteBuild;
18
- const vite_1 = require("vite");
19
- const constants_1 = require("./constants");
20
- const manifestPlugin_1 = __importDefault(require("./plugins/manifestPlugin"));
21
- const path_1 = __importDefault(require("path"));
22
- const utils_1 = require("./utils");
23
- const codeBlockingPlugin_1 = __importDefault(require("./plugins/codeBlockingPlugin"));
24
- const friendlyLoggingPlugin_1 = __importDefault(require("./plugins/friendlyLoggingPlugin"));
1
+ import { build } from 'vite';
2
+ import { ROLLUP_OPTIONS, OUTPUT_DIR } from "./constants.js";
3
+ import manifestPlugin from "./plugins/manifestPlugin.js";
4
+ import path from 'path';
5
+ import { getUrlSafeFileName } from "./utils.js";
6
+ import codeBlockingPlugin from "./plugins/codeBlockingPlugin.js";
7
+ import friendlyLoggingPlugin from "./plugins/friendlyLoggingPlugin.js";
25
8
  const allowedExtensions = ['.js', '.ts', '.tsx', '.jsx'];
26
- exports.extensionErrorBaseMessage = `Supported file extensions are [${allowedExtensions.join(', ')}], received:`;
27
- function buildSingleExtension(_a) {
28
- return __awaiter(this, arguments, void 0, function* ({ file, outputDir = constants_1.OUTPUT_DIR, emptyOutDir = true, minify = false, root = process.cwd(), // This is the vite default, so using that as our default
29
- logLevel = 'info', appConfig, }) {
30
- const output = (0, utils_1.getUrlSafeFileName)(file);
31
- yield (0, vite_1.build)({
32
- logLevel,
33
- root,
34
- define: {
35
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
9
+ export const extensionErrorBaseMessage = `Supported file extensions are [${allowedExtensions.join(', ')}], received:`;
10
+ export async function buildSingleExtension({ file, outputDir = OUTPUT_DIR, emptyOutDir = true, minify = false, root = process.cwd(), // This is the vite default, so using that as our default
11
+ logLevel = 'info', appConfig, }) {
12
+ const output = getUrlSafeFileName(file);
13
+ await build({
14
+ logLevel,
15
+ root,
16
+ define: {
17
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
18
+ },
19
+ build: {
20
+ lib: {
21
+ entry: file,
22
+ name: output,
23
+ formats: ['iife'],
24
+ fileName: () => output,
36
25
  },
37
- build: {
38
- lib: {
39
- entry: file,
40
- name: output,
41
- formats: ['iife'],
42
- fileName: () => output,
43
- },
44
- rollupOptions: Object.assign(Object.assign({}, constants_1.ROLLUP_OPTIONS), { plugins: [
45
- (0, manifestPlugin_1.default)({
46
- output,
47
- extensionPath: root,
48
- logger: console,
49
- manifestConfig: appConfig,
50
- }),
51
- (0, friendlyLoggingPlugin_1.default)({ logger: console }),
52
- (0, codeBlockingPlugin_1.default)({ logger: console, extensionPath: root }),
53
- ] }),
54
- outDir: outputDir,
55
- emptyOutDir,
56
- minify,
26
+ rollupOptions: {
27
+ ...ROLLUP_OPTIONS,
28
+ plugins: [
29
+ manifestPlugin({
30
+ output,
31
+ extensionPath: root,
32
+ logger: console,
33
+ manifestConfig: appConfig,
34
+ }),
35
+ friendlyLoggingPlugin({ logger: console }),
36
+ codeBlockingPlugin({ logger: console, extensionPath: root }),
37
+ ],
57
38
  },
58
- });
39
+ outDir: outputDir,
40
+ emptyOutDir,
41
+ minify,
42
+ },
59
43
  });
60
44
  }
61
- function remoteBuild(args) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const { root, entryPoint, outputDir = constants_1.OUTPUT_DIR, logLevel, appConfig, } = args;
64
- if (!root) {
65
- console.error('remoteBuild Error: root is required');
66
- return;
67
- }
68
- if (!entryPoint) {
69
- console.error('remoteBuild Error: entryPoint is required');
70
- return;
71
- }
72
- const fileInfo = path_1.default.parse(entryPoint);
73
- if (!allowedExtensions.includes(fileInfo.ext)) {
74
- throw new Error(`${exports.extensionErrorBaseMessage} ${fileInfo.ext}`);
75
- }
76
- yield buildSingleExtension({
77
- file: entryPoint,
78
- outputDir,
79
- minify: true,
80
- root,
81
- logLevel,
82
- appConfig,
83
- });
45
+ export async function remoteBuild(args) {
46
+ const { root, entryPoint, outputDir = OUTPUT_DIR, logLevel, appConfig, } = args;
47
+ if (!root) {
48
+ console.error('remoteBuild Error: root is required');
49
+ return;
50
+ }
51
+ if (!entryPoint) {
52
+ console.error('remoteBuild Error: entryPoint is required');
53
+ return;
54
+ }
55
+ const fileInfo = path.parse(entryPoint);
56
+ if (!allowedExtensions.includes(fileInfo.ext)) {
57
+ throw new Error(`${extensionErrorBaseMessage} ${fileInfo.ext}`);
58
+ }
59
+ await buildSingleExtension({
60
+ file: entryPoint,
61
+ outputDir,
62
+ minify: true,
63
+ root,
64
+ logLevel,
65
+ appConfig,
84
66
  });
85
67
  }
@@ -1,4 +1,4 @@
1
- import { AppConfig, ExtensionConfigMap, LocalAppConfig, Logger } from './types';
1
+ import { AppConfig, ExtensionConfigMap, LocalAppConfig, Logger } from './types.ts';
2
2
  export declare function loadConfigByPath<T = unknown>(configPath: string): T;
3
3
  export declare function validateCardConfig(config?: unknown): Error | true;
4
4
  export declare function loadExtensionConfig(appConfig: AppConfig, appPath: string): ExtensionConfigMap;
@@ -1,24 +1,11 @@
1
- "use strict";
2
- /* hs-eslint ignored failing-rules */
3
- /* eslint-disable hubspot-dev/no-unsupported-ts-syntax */
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.loadConfigByPath = loadConfigByPath;
9
- exports.validateCardConfig = validateCardConfig;
10
- exports.loadExtensionConfig = loadExtensionConfig;
11
- exports.validateProxyConfigKey = validateProxyConfigKey;
12
- exports.validateProxyConfigValue = validateProxyConfigValue;
13
- exports.loadLocalConfig = loadLocalConfig;
14
- const fs_1 = __importDefault(require("fs"));
15
- const path_1 = __importDefault(require("path"));
16
- const utils_1 = require("./utils");
17
- function loadConfigByPath(configPath) {
18
- const source = fs_1.default.readFileSync(configPath).toString();
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { buildSourceId, getUrlSafeFileName } from "./utils.js";
4
+ export function loadConfigByPath(configPath) {
5
+ const source = fs.readFileSync(configPath).toString();
19
6
  return JSON.parse(source);
20
7
  }
21
- function validateCardConfig(config) {
8
+ export function validateCardConfig(config) {
22
9
  if (!config || typeof config !== 'object') {
23
10
  return new Error('Card config must be an object');
24
11
  }
@@ -54,16 +41,14 @@ function validateCardConfig(config) {
54
41
  }
55
42
  return true;
56
43
  }
57
- function loadExtensionConfig(appConfig, appPath) {
58
- var _a, _b;
59
- const crmCardsSubConfigFiles = (_b = (_a = appConfig === null || appConfig === void 0 ? void 0 : appConfig.extensions) === null || _a === void 0 ? void 0 : _a.crm) === null || _b === void 0 ? void 0 : _b.cards;
44
+ export function loadExtensionConfig(appConfig, appPath) {
45
+ const crmCardsSubConfigFiles = appConfig?.extensions?.crm?.cards;
60
46
  if (!crmCardsSubConfigFiles) {
61
47
  throw new Error("Unable to find extensions files, make sure the 'extensions.crm.cards' array is defined in the application configuration file");
62
48
  }
63
49
  const outputConfig = {};
64
50
  crmCardsSubConfigFiles.forEach((card) => {
65
- var _a, _b;
66
- const cardConfigPath = path_1.default.join(appPath, card.file);
51
+ const cardConfigPath = path.join(appPath, card.file);
67
52
  try {
68
53
  const cardConfig = loadConfigByPath(cardConfigPath);
69
54
  const validation = validateCardConfig(cardConfig);
@@ -71,11 +56,23 @@ function loadExtensionConfig(appConfig, appPath) {
71
56
  console.error(`[DevServer] Extension config ${cardConfigPath} is invalid: ${validation.message}`);
72
57
  }
73
58
  if (cardConfig && cardConfig.data) {
74
- const cardConfigDir = path_1.default.parse(cardConfigPath).dir;
75
- const entryPointPath = path_1.default.join(cardConfigDir, (_b = (_a = cardConfig.data) === null || _a === void 0 ? void 0 : _a.module) === null || _b === void 0 ? void 0 : _b.file);
59
+ const cardConfigDir = path.parse(cardConfigPath).dir;
60
+ const entryPointPath = path.join(cardConfigDir, cardConfig.data?.module?.file);
76
61
  cardConfig.data.module.file = entryPointPath;
77
- const sourceId = (0, utils_1.buildSourceId)(appConfig, cardConfig);
78
- outputConfig[sourceId || `${entryPointPath}-${cardConfig.data.location}`] = Object.assign(Object.assign({}, cardConfig), { output: (0, utils_1.getUrlSafeFileName)(entryPointPath), path: appPath, extensionPath: path_1.default.parse(entryPointPath).dir, extensionConfigPath: cardConfigPath, data: Object.assign(Object.assign({}, cardConfig.data), { appName: appConfig.name, sourceId }), appConfig });
62
+ const sourceId = buildSourceId(appConfig, cardConfig);
63
+ outputConfig[sourceId || `${entryPointPath}-${cardConfig.data.location}`] = {
64
+ ...cardConfig,
65
+ output: getUrlSafeFileName(entryPointPath),
66
+ path: appPath,
67
+ extensionPath: path.parse(entryPointPath).dir,
68
+ extensionConfigPath: cardConfigPath,
69
+ data: {
70
+ ...cardConfig.data,
71
+ appName: appConfig.name,
72
+ sourceId,
73
+ },
74
+ appConfig,
75
+ };
79
76
  }
80
77
  }
81
78
  catch (e) {
@@ -84,7 +81,7 @@ function loadExtensionConfig(appConfig, appPath) {
84
81
  });
85
82
  return outputConfig;
86
83
  }
87
- function validateProxyConfigKey(urlKey, logger, localConfigPath) {
84
+ export function validateProxyConfigKey(urlKey, logger, localConfigPath) {
88
85
  try {
89
86
  const url = new URL(urlKey);
90
87
  if (url.pathname !== '/') {
@@ -95,7 +92,7 @@ function validateProxyConfigKey(urlKey, logger, localConfigPath) {
95
92
  logger.warn(`The key "${urlKey}" in "${localConfigPath}" is an invalid url`);
96
93
  }
97
94
  }
98
- function validateProxyConfigValue(value, key, logger, localConfigPath) {
95
+ export function validateProxyConfigValue(value, key, logger, localConfigPath) {
99
96
  try {
100
97
  // eslint-disable-next-line no-new
101
98
  new URL(value);
@@ -104,14 +101,14 @@ function validateProxyConfigValue(value, key, logger, localConfigPath) {
104
101
  logger.warn(`The value "${value}" for key "${key}" in "${localConfigPath}" is an invalid url`);
105
102
  }
106
103
  }
107
- function loadLocalConfig(appPath, logger) {
104
+ export function loadLocalConfig(appPath, logger) {
108
105
  const localConfigFilename = 'local.json';
109
- const localConfigPath = path_1.default.join(appPath, localConfigFilename);
110
- if (!fs_1.default.existsSync(localConfigPath)) {
106
+ const localConfigPath = path.join(appPath, localConfigFilename);
107
+ if (!fs.existsSync(localConfigPath)) {
111
108
  return undefined;
112
109
  }
113
110
  try {
114
- const localConfig = JSON.parse(fs_1.default.readFileSync(localConfigPath).toString());
111
+ const localConfig = JSON.parse(fs.readFileSync(localConfigPath).toString());
115
112
  const { proxy = {} } = localConfig;
116
113
  Object.entries(proxy).forEach((entry) => {
117
114
  const [key, value] = entry;
@@ -1,9 +1,7 @@
1
1
  export declare const OUTPUT_DIR = "dist";
2
2
  export declare const MANIFEST_FILE = "manifest.json";
3
3
  export declare const EXPRESS_SERVER_ID = "ui-extensions-dev-server";
4
- export declare const VITE_DEV_SERVER_ID = "ui-extensions-vite-dev-server";
5
4
  export declare const EXPRESS_DEFAULT_PORT = 5173;
6
- export declare const WEBSOCKET_DEFAULT_PORT = 5174;
7
5
  export declare const ROLLUP_OPTIONS: {
8
6
  external: string[];
9
7
  output: {
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUPPORTED_EXTENSION_TYPES = exports.SUPPORTED_APP_TYPES = exports.PAGE_EXTENSION = exports.SETTINGS_EXTENSION = exports.CARD_EXTENSION = exports.PRIVATE_APP = exports.PUBLIC_APP = exports.PLATFORM_VERSION = exports.SERVER_CAPABILITIES = exports.PROXY_CAPABILITY = exports.WEBSOCKET_MESSAGE_VERSION = exports.EXTENSIONS_MESSAGE_VERSION = exports.ROLLUP_OPTIONS = exports.WEBSOCKET_DEFAULT_PORT = exports.EXPRESS_DEFAULT_PORT = exports.VITE_DEV_SERVER_ID = exports.EXPRESS_SERVER_ID = exports.MANIFEST_FILE = exports.OUTPUT_DIR = void 0;
4
- exports.OUTPUT_DIR = 'dist';
5
- exports.MANIFEST_FILE = 'manifest.json';
6
- exports.EXPRESS_SERVER_ID = 'ui-extensions-dev-server';
7
- exports.VITE_DEV_SERVER_ID = 'ui-extensions-vite-dev-server';
8
- exports.EXPRESS_DEFAULT_PORT = 5173;
9
- exports.WEBSOCKET_DEFAULT_PORT = 5174;
10
- exports.ROLLUP_OPTIONS = {
1
+ export const OUTPUT_DIR = 'dist';
2
+ export const MANIFEST_FILE = 'manifest.json';
3
+ export const EXPRESS_SERVER_ID = 'ui-extensions-dev-server';
4
+ export const EXPRESS_DEFAULT_PORT = 5173;
5
+ export const ROLLUP_OPTIONS = {
11
6
  // Deps to exclude from the bundle
12
7
  external: ['react', 'react-dom', '@remote-ui/react'],
13
8
  output: {
@@ -19,32 +14,30 @@ exports.ROLLUP_OPTIONS = {
19
14
  extend: true,
20
15
  },
21
16
  };
22
- exports.EXTENSIONS_MESSAGE_VERSION = 2;
23
- exports.WEBSOCKET_MESSAGE_VERSION = 1;
24
- exports.PROXY_CAPABILITY = 'app-backend-proxy-server';
25
- exports.SERVER_CAPABILITIES = [
17
+ export const EXTENSIONS_MESSAGE_VERSION = 2;
18
+ export const WEBSOCKET_MESSAGE_VERSION = 1;
19
+ export const PROXY_CAPABILITY = 'app-backend-proxy-server';
20
+ export const SERVER_CAPABILITIES = [
26
21
  // Supports running app functions locally
27
22
  'app-functions-local-dev',
28
23
  'source-id',
29
24
  'account-id',
30
25
  ];
31
- exports.PLATFORM_VERSION = {
26
+ export const PLATFORM_VERSION = {
32
27
  V20231: '2023.1',
33
28
  V20232: '2023.2',
34
29
  V20251: '2025.1',
35
30
  V20252: '2025.2',
36
31
  UNSTABLE: 'unstable',
37
32
  };
38
- exports.PUBLIC_APP = 'public-app';
39
- // You gotta be kidding me linter
40
- // eslint-disable-next-line hubspot-dev/no-private-classes
41
- exports.PRIVATE_APP = 'private-app';
42
- exports.CARD_EXTENSION = 'CARD';
43
- exports.SETTINGS_EXTENSION = 'SETTINGS';
44
- exports.PAGE_EXTENSION = 'PAGE';
45
- exports.SUPPORTED_APP_TYPES = [exports.PUBLIC_APP, exports.PRIVATE_APP];
46
- exports.SUPPORTED_EXTENSION_TYPES = [
47
- exports.CARD_EXTENSION,
48
- exports.SETTINGS_EXTENSION,
49
- exports.PAGE_EXTENSION,
33
+ export const PUBLIC_APP = 'public-app';
34
+ export const PRIVATE_APP = 'private-app';
35
+ export const CARD_EXTENSION = 'CARD';
36
+ export const SETTINGS_EXTENSION = 'SETTINGS';
37
+ export const PAGE_EXTENSION = 'PAGE';
38
+ export const SUPPORTED_APP_TYPES = [PUBLIC_APP, PRIVATE_APP];
39
+ export const SUPPORTED_EXTENSION_TYPES = [
40
+ CARD_EXTENSION,
41
+ SETTINGS_EXTENSION,
42
+ PAGE_EXTENSION,
50
43
  ];
package/dist/lib/dev.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { DevServerState } from './DevServerState';
1
+ import { DevServerState } from './DevServerState.ts';
2
2
  export declare function startDevMode(devServerState: DevServerState): Promise<() => Promise<void>>;