@hubspot/ui-extensions-dev-server 1.0.2 → 1.1.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.
Files changed (95) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -4
  3. package/dist/index.js +0 -4
  4. package/dist/lib/DevModeInterface.d.ts +0 -9
  5. package/dist/lib/DevModeInterface.js +0 -36
  6. package/dist/lib/DevModeParentInterface.d.ts +0 -19
  7. package/dist/lib/DevModeParentInterface.js +0 -181
  8. package/dist/lib/DevModeUnifiedInterface.d.ts +0 -9
  9. package/dist/lib/DevModeUnifiedInterface.js +0 -118
  10. package/dist/lib/DevServerState.d.ts +0 -44
  11. package/dist/lib/DevServerState.js +0 -95
  12. package/dist/lib/ExtensionsWebSocket.d.ts +0 -25
  13. package/dist/lib/ExtensionsWebSocket.js +0 -110
  14. package/dist/lib/__mocks__/config.d.ts +0 -2
  15. package/dist/lib/__mocks__/config.js +0 -5
  16. package/dist/lib/__mocks__/isExtensionFile.d.ts +0 -5
  17. package/dist/lib/__mocks__/isExtensionFile.js +0 -11
  18. package/dist/lib/__tests__/DevModeInterface.spec.d.ts +0 -1
  19. package/dist/lib/__tests__/DevModeInterface.spec.js +0 -155
  20. package/dist/lib/__tests__/DevModeParentInterface.spec.d.ts +0 -1
  21. package/dist/lib/__tests__/DevModeParentInterface.spec.js +0 -179
  22. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.d.ts +0 -1
  23. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +0 -236
  24. package/dist/lib/__tests__/ExtensionsWebSocket.spec.d.ts +0 -1
  25. package/dist/lib/__tests__/ExtensionsWebSocket.spec.js +0 -304
  26. package/dist/lib/__tests__/ast.spec.d.ts +0 -1
  27. package/dist/lib/__tests__/ast.spec.js +0 -737
  28. package/dist/lib/__tests__/build.spec.d.ts +0 -1
  29. package/dist/lib/__tests__/build.spec.js +0 -159
  30. package/dist/lib/__tests__/config.spec.d.ts +0 -1
  31. package/dist/lib/__tests__/config.spec.js +0 -291
  32. package/dist/lib/__tests__/dev.spec.d.ts +0 -1
  33. package/dist/lib/__tests__/dev.spec.js +0 -80
  34. package/dist/lib/__tests__/extensionsService.spec.d.ts +0 -1
  35. package/dist/lib/__tests__/extensionsService.spec.js +0 -150
  36. package/dist/lib/__tests__/factories.d.ts +0 -48
  37. package/dist/lib/__tests__/factories.js +0 -32
  38. package/dist/lib/__tests__/fixtures/extensionConfig.d.ts +0 -182
  39. package/dist/lib/__tests__/fixtures/extensionConfig.js +0 -304
  40. package/dist/lib/__tests__/fixtures/urls.d.ts +0 -4
  41. package/dist/lib/__tests__/fixtures/urls.js +0 -4
  42. package/dist/lib/__tests__/parsing-utils.spec.d.ts +0 -1
  43. package/dist/lib/__tests__/parsing-utils.spec.js +0 -467
  44. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.d.ts +0 -1
  45. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.js +0 -112
  46. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.d.ts +0 -1
  47. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.js +0 -111
  48. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.d.ts +0 -1
  49. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +0 -256
  50. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.d.ts +0 -1
  51. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.js +0 -65
  52. package/dist/lib/__tests__/plugins/manifestPlugin.spec.d.ts +0 -1
  53. package/dist/lib/__tests__/plugins/manifestPlugin.spec.js +0 -455
  54. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.d.ts +0 -1
  55. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.js +0 -81
  56. package/dist/lib/__tests__/server.spec.d.ts +0 -1
  57. package/dist/lib/__tests__/server.spec.js +0 -152
  58. package/dist/lib/__tests__/test-utils/ast.d.ts +0 -1
  59. package/dist/lib/__tests__/test-utils/ast.js +0 -4
  60. package/dist/lib/__tests__/utils.spec.d.ts +0 -1
  61. package/dist/lib/__tests__/utils.spec.js +0 -176
  62. package/dist/lib/ast.d.ts +0 -16
  63. package/dist/lib/ast.js +0 -281
  64. package/dist/lib/bin/cli.d.ts +0 -2
  65. package/dist/lib/bin/cli.js +0 -143
  66. package/dist/lib/build.d.ts +0 -24
  67. package/dist/lib/build.js +0 -73
  68. package/dist/lib/config.d.ts +0 -7
  69. package/dist/lib/config.js +0 -124
  70. package/dist/lib/constants.d.ts +0 -32
  71. package/dist/lib/constants.js +0 -43
  72. package/dist/lib/dev.d.ts +0 -2
  73. package/dist/lib/dev.js +0 -58
  74. package/dist/lib/extensionsService.d.ts +0 -10
  75. package/dist/lib/extensionsService.js +0 -45
  76. package/dist/lib/parsing-utils.d.ts +0 -31
  77. package/dist/lib/parsing-utils.js +0 -289
  78. package/dist/lib/plugins/codeBlockingPlugin.d.ts +0 -8
  79. package/dist/lib/plugins/codeBlockingPlugin.js +0 -45
  80. package/dist/lib/plugins/codeCheckingPlugin.d.ts +0 -8
  81. package/dist/lib/plugins/codeCheckingPlugin.js +0 -89
  82. package/dist/lib/plugins/devBuildPlugin.d.ts +0 -8
  83. package/dist/lib/plugins/devBuildPlugin.js +0 -201
  84. package/dist/lib/plugins/friendlyLoggingPlugin.d.ts +0 -14
  85. package/dist/lib/plugins/friendlyLoggingPlugin.js +0 -36
  86. package/dist/lib/plugins/manifestPlugin.d.ts +0 -12
  87. package/dist/lib/plugins/manifestPlugin.js +0 -158
  88. package/dist/lib/plugins/relevantModulesPlugin.d.ts +0 -13
  89. package/dist/lib/plugins/relevantModulesPlugin.js +0 -25
  90. package/dist/lib/server.d.ts +0 -13
  91. package/dist/lib/server.js +0 -99
  92. package/dist/lib/types.d.ts +0 -290
  93. package/dist/lib/types.js +0 -12
  94. package/dist/lib/utils.d.ts +0 -25
  95. package/dist/lib/utils.js +0 -113
package/dist/lib/utils.js DELETED
@@ -1,113 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs';
3
- import { MANIFEST_FILE } from "./constants.js";
4
- export function getUrlSafeFileName(filePath) {
5
- const { name } = path.parse(filePath);
6
- return encodeURIComponent(`${name}.js`);
7
- }
8
- // Strips ANSI color codes out of strings because we don't want to pass them to the browser
9
- export function stripAnsiColorCodes(stringWithColorCodes) {
10
- if (!stringWithColorCodes) {
11
- return null;
12
- }
13
- return stringWithColorCodes.replace(
14
- // eslint-disable-next-line no-control-regex
15
- /[\u001b][[]*([0-9]{1,4};?)*[m]/g, '');
16
- }
17
- export function loadManifest(outputDir, output) {
18
- try {
19
- return JSON.parse(fs
20
- .readFileSync(path.join(outputDir, `${output}-${MANIFEST_FILE}`))
21
- .toString());
22
- }
23
- catch (e) {
24
- return {};
25
- }
26
- }
27
- export function buildSourceId(appConfig, extensionConfig) {
28
- if (appConfig.uid && extensionConfig.data.uid) {
29
- return `${appConfig.uid}::${extensionConfig.data.uid}`;
30
- }
31
- return null;
32
- }
33
- export function isNodeModule(filepath) {
34
- if (!filepath) {
35
- return false;
36
- }
37
- const directory = path.parse(filepath).dir;
38
- return directory.includes('node_modules');
39
- }
40
- /**
41
- * Check if a given file is within the extension path
42
- */
43
- export function isExtensionFile(filepath, extensionPath) {
44
- if (!filepath) {
45
- return false;
46
- }
47
- try {
48
- const absoluteFilePath = fs.realpathSync(filepath);
49
- const absoluteExtensionDirPath = fs.realpathSync(extensionPath);
50
- const relativePath = path.relative(absoluteExtensionDirPath, absoluteFilePath);
51
- return !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
52
- }
53
- catch (e) {
54
- console.log(`Error checking if ${filepath} is in extension path: ${e}`);
55
- // If there's an error, we can't determine if the file is in the extension path, so return false.
56
- return false;
57
- }
58
- }
59
- export class UnhandledPlatformVersionError extends Error {
60
- constructor(platformVersion) {
61
- super(`Unsupported platform version "${platformVersion}"`);
62
- }
63
- }
64
- export function throwUnhandledPlatformVersionError(platformVersion) {
65
- throw new UnhandledPlatformVersionError(platformVersion);
66
- }
67
- export function extractAllowedUrls(appConfig) {
68
- if (!appConfig || !('allowedUrls' in appConfig) || !appConfig.allowedUrls) {
69
- return [];
70
- }
71
- return appConfig.allowedUrls;
72
- }
73
- function simpleHash(input) {
74
- let hash = 0;
75
- for (let i = 0; i < input.length; i++) {
76
- const char = input.charCodeAt(i);
77
- hash = (hash * 31 + char) % 2147483647;
78
- }
79
- return Math.abs(hash).toString(16);
80
- }
81
- /**
82
- * This function generates a deterministic hash from any number of arguments
83
- * Arrays and objects are stringified to ensure it works for all types.
84
- * Uses the same simple hash algorithm as the browser version for consistency.
85
- */
86
- export function generateHash(...args) {
87
- try {
88
- // First make sure all the values are strings
89
- const normalizedArgs = args.map((arg) => {
90
- if (Array.isArray(arg)) {
91
- return [...arg].sort().join('-');
92
- }
93
- if (arg && typeof arg === 'object') {
94
- return JSON.stringify(arg, Object.keys(arg).sort());
95
- }
96
- return String(arg);
97
- });
98
- // Return the hash of the joined strings.
99
- const input = [...normalizedArgs].join('::');
100
- return simpleHash(input);
101
- }
102
- catch (e) {
103
- console.error('Error generating hash: ', e);
104
- // Just return an empty string if anything goes wrong.
105
- return '';
106
- }
107
- }
108
- /**
109
- * Check if a given URL is an image (of a type we support)
110
- */
111
- export function isImage(url) {
112
- return /\.(png|jpg|jpeg|gif|svg|webp|avif|raw|url|inline)$/.test(url);
113
- }