@hubspot/ui-extensions-dev-server 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -17
- package/dist/lib/DevModeParentInterface.d.ts +1 -1
- package/dist/lib/DevModeParentInterface.js +15 -10
- package/dist/lib/ast.d.ts +3 -7
- package/dist/lib/ast.js +206 -57
- package/dist/lib/build.js +8 -8
- package/dist/lib/config.js +7 -6
- package/dist/lib/dev.js +2 -1
- package/dist/lib/plugins/codeBlockingPlugin.js +2 -1
- package/dist/lib/plugins/devBuildPlugin.js +9 -19
- package/dist/lib/plugins/manifestPlugin.js +1 -1
- package/dist/lib/plugins/relevantModulesPlugin.js +2 -1
- package/dist/lib/server.js +4 -4
- package/dist/lib/types.d.ts +5 -2
- package/dist/lib/utils.js +11 -11
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
exports.DevModeUnifiedInterfaceNonSingleton = exports.DevModeUnifiedInterface = exports.DevModeInterfaceNonSingleton = exports.DevModeInterface = exports.buildSingleExtension = exports.remoteBuild = void 0;
|
|
37
27
|
const build_1 = require("./lib/build");
|
|
@@ -12,7 +12,7 @@ export declare abstract class DevModeParentInterface {
|
|
|
12
12
|
protected abstract _generateAppExtensionMappings(components: ProjectComponentMap | UnifiedProjectComponentMap): AppExtensionMapping[];
|
|
13
13
|
_getPlatformVersion(projectConfig?: ProjectConfig): PlatformVersion;
|
|
14
14
|
_reset(): void;
|
|
15
|
-
parentSetup({ onUploadRequired,
|
|
15
|
+
parentSetup({ onUploadRequired, logger, urls, setActiveApp, choices, }: DevModeBaseSetupArguments): Promise<void>;
|
|
16
16
|
start({ requestPorts, accountId, projectConfig, }: DevModeStartArguments): Promise<void>;
|
|
17
17
|
fileChange(filePath: string, __event: unknown): Promise<void>;
|
|
18
18
|
cleanup(): Promise<void>;
|
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.DevModeParentInterface = void 0;
|
|
13
16
|
const constants_1 = require("./constants");
|
|
@@ -16,6 +19,7 @@ const config_1 = require("./config");
|
|
|
16
19
|
const constants_2 = require("./constants");
|
|
17
20
|
const utils_1 = require("./utils");
|
|
18
21
|
const DevServerState_1 = require("./DevServerState");
|
|
22
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
19
23
|
const defaultLogger = {
|
|
20
24
|
info: (...args) => {
|
|
21
25
|
console.log(...args);
|
|
@@ -63,9 +67,9 @@ class DevModeParentInterface {
|
|
|
63
67
|
this.isConfigured = false;
|
|
64
68
|
this.isRunning = false;
|
|
65
69
|
}
|
|
66
|
-
parentSetup(
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
parentSetup({ onUploadRequired, logger, urls, setActiveApp, choices = [], }) {
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
73
|
if (this.isConfigured) {
|
|
70
74
|
logger.debug('Dev server has already been configured, skipping');
|
|
71
75
|
return;
|
|
@@ -80,7 +84,8 @@ class DevModeParentInterface {
|
|
|
80
84
|
this.configs = [choices[0].value];
|
|
81
85
|
}
|
|
82
86
|
else {
|
|
83
|
-
const
|
|
87
|
+
const promptModule = inquirer_1.default.createPromptModule();
|
|
88
|
+
const answers = yield promptModule({
|
|
84
89
|
type: 'checkbox',
|
|
85
90
|
name: 'extensions',
|
|
86
91
|
message: 'Which extension(s) would you like to run?',
|
|
@@ -100,13 +105,13 @@ class DevModeParentInterface {
|
|
|
100
105
|
}
|
|
101
106
|
this.isConfigured = true;
|
|
102
107
|
if (typeof setActiveApp === 'function') {
|
|
103
|
-
yield setActiveApp((
|
|
108
|
+
yield setActiveApp((_c = (_b = (_a = this.configs) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.appConfig) === null || _c === void 0 ? void 0 : _c.uid);
|
|
104
109
|
}
|
|
105
110
|
});
|
|
106
111
|
}
|
|
107
|
-
start(
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
start({ requestPorts, accountId, projectConfig, }) {
|
|
113
|
+
var _a, _b, _c, _d;
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
115
|
this.logger.debug('Start function was invoked', {
|
|
111
116
|
accountId,
|
|
112
117
|
projectConfig,
|
|
@@ -133,7 +138,7 @@ class DevModeParentInterface {
|
|
|
133
138
|
this.logger.debug('Call to port manager failed, using default ports');
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
|
-
const { proxy: localDevUrlMapping } = (0, config_1.loadLocalConfig)(((
|
|
141
|
+
const { proxy: localDevUrlMapping } = (0, config_1.loadLocalConfig)(((_b = (_a = this.configs) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.path) || '', this.logger) || {};
|
|
137
142
|
try {
|
|
138
143
|
this.devServerState = new DevServerState_1.DevServerState({
|
|
139
144
|
localDevUrlMapping,
|
|
@@ -144,7 +149,7 @@ class DevModeParentInterface {
|
|
|
144
149
|
webSocketPort,
|
|
145
150
|
logger: this.logger,
|
|
146
151
|
urls: this.urls,
|
|
147
|
-
appConfig: (
|
|
152
|
+
appConfig: (_d = (_c = this.configs) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.appConfig,
|
|
148
153
|
});
|
|
149
154
|
}
|
|
150
155
|
catch (e) {
|
package/dist/lib/ast.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { SourceCodeMetadata, SourceCodeChecks, Logger } from './types';
|
|
1
|
+
import { SourceCodeMetadata, SourceCodeChecks, Logger, NodeValue } from './types';
|
|
2
2
|
import { Program, Node } from 'estree';
|
|
3
|
-
type NodeValue = string | number | boolean | null | undefined | RegExp | bigint | NodeValue[] | NodeObject;
|
|
4
|
-
type NodeObject = {
|
|
5
|
-
[key: string]: NodeValue;
|
|
6
|
-
};
|
|
7
3
|
/**
|
|
8
4
|
* This is a simple utility function to rebuild the value from a node.
|
|
9
5
|
* It'll work for simple stuff, but it's likely to fail in complicated cases.
|
|
10
6
|
* Use with caution!
|
|
11
7
|
*/
|
|
12
|
-
export declare function getValueFromNode(node: Node): NodeValue;
|
|
8
|
+
export declare function getValueFromNode(node: Node, state: SourceCodeMetadata): NodeValue;
|
|
13
9
|
/**
|
|
14
10
|
* We only support image imports that are within the extension directory.
|
|
15
11
|
* This function will check if an image is out of bounds and collect any that are out of bounds, so we can warn the user before they run into build issues.
|
|
@@ -22,5 +18,5 @@ export declare function traverseAbstractSyntaxTree(ast: Program, checks: SourceC
|
|
|
22
18
|
importedHooks: {};
|
|
23
19
|
dependencies: never[];
|
|
24
20
|
};
|
|
21
|
+
variableDeclarations: Map<string, NodeValue>;
|
|
25
22
|
};
|
|
26
|
-
export {};
|
package/dist/lib/ast.js
CHANGED
|
@@ -4,9 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getValueFromNode =
|
|
8
|
-
|
|
9
|
-
exports.traverseAbstractSyntaxTree = traverseAbstractSyntaxTree;
|
|
7
|
+
exports.traverseAbstractSyntaxTree = exports.checkForOutOfBoundsImageImports = exports.getValueFromNode = void 0;
|
|
8
|
+
const UNSUPPORTED_SPREAD = Symbol('unsupported-spread');
|
|
10
9
|
const path_1 = __importDefault(require("path"));
|
|
11
10
|
// @ts-expect-error no type defs
|
|
12
11
|
const estraverse_1 = require("estraverse");
|
|
@@ -55,12 +54,37 @@ function _checkForFunctionMetadata(node, parent, output, functionName) {
|
|
|
55
54
|
output.functions[functionName].defined = true;
|
|
56
55
|
}
|
|
57
56
|
}
|
|
57
|
+
function _collectVariableDeclarations(node, state) {
|
|
58
|
+
if (!node) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Handle variable declarations (const, let, var)
|
|
62
|
+
if (node.type === 'VariableDeclaration') {
|
|
63
|
+
node.declarations.forEach((declaration) => {
|
|
64
|
+
if (declaration.type === 'VariableDeclarator' &&
|
|
65
|
+
declaration.id.type === 'Identifier' &&
|
|
66
|
+
declaration.init) {
|
|
67
|
+
const variableName = declaration.id.name;
|
|
68
|
+
const value = getValueFromNode(declaration.init, state);
|
|
69
|
+
state.variableDeclarations.set(variableName, value);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Handle assignment expressions for let variables (e.g., myVar = newValue)
|
|
74
|
+
if (node.type === 'AssignmentExpression' && node.left.type === 'Identifier') {
|
|
75
|
+
const variableName = node.left.name;
|
|
76
|
+
if (state.variableDeclarations.has(variableName)) {
|
|
77
|
+
const value = getValueFromNode(node.right, state);
|
|
78
|
+
state.variableDeclarations.set(variableName, value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
58
82
|
/**
|
|
59
83
|
* This is a simple utility function to rebuild the value from a node.
|
|
60
84
|
* It'll work for simple stuff, but it's likely to fail in complicated cases.
|
|
61
85
|
* Use with caution!
|
|
62
86
|
*/
|
|
63
|
-
function getValueFromNode(node) {
|
|
87
|
+
function getValueFromNode(node, state) {
|
|
64
88
|
switch (node.type) {
|
|
65
89
|
case 'Literal':
|
|
66
90
|
return node.value;
|
|
@@ -74,34 +98,161 @@ function getValueFromNode(node) {
|
|
|
74
98
|
case 'Infinity':
|
|
75
99
|
return Infinity;
|
|
76
100
|
default:
|
|
101
|
+
if (state.variableDeclarations.has(name)) {
|
|
102
|
+
return state.variableDeclarations.get(name);
|
|
103
|
+
}
|
|
77
104
|
return name;
|
|
78
105
|
}
|
|
79
106
|
}
|
|
80
|
-
case 'ArrayExpression':
|
|
81
|
-
|
|
107
|
+
case 'ArrayExpression': {
|
|
108
|
+
const arrayValue = [];
|
|
109
|
+
if (node.elements.length === 0) {
|
|
110
|
+
return arrayValue;
|
|
111
|
+
}
|
|
112
|
+
// Arrays have to be built from their elements, to handle special cases like nested arrays from spread operators.
|
|
113
|
+
node.elements.forEach((element) => {
|
|
114
|
+
if (typeof element === 'object' && element !== null) {
|
|
115
|
+
if (element.type === 'SpreadElement') {
|
|
116
|
+
const value = getValueFromNode(element, state);
|
|
117
|
+
if (Array.isArray(value)) {
|
|
118
|
+
arrayValue.push(...value);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
arrayValue.push(value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const value = getValueFromNode(element, state);
|
|
126
|
+
arrayValue.push(value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
arrayValue.push(element);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return arrayValue;
|
|
134
|
+
}
|
|
82
135
|
case 'ObjectExpression': {
|
|
83
136
|
const obj = {};
|
|
84
137
|
node.properties.forEach((prop) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
138
|
+
switch (prop.type) {
|
|
139
|
+
case 'Property': {
|
|
140
|
+
const property = prop;
|
|
141
|
+
let key = undefined;
|
|
142
|
+
if (property.key.type === 'Identifier') {
|
|
143
|
+
key = property.key.name;
|
|
144
|
+
}
|
|
145
|
+
else if (property.key.type === 'Literal') {
|
|
146
|
+
key = String(property.key.value);
|
|
147
|
+
}
|
|
148
|
+
if (key) {
|
|
149
|
+
obj[key] = getValueFromNode(property.value, state);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
93
152
|
}
|
|
94
|
-
|
|
95
|
-
|
|
153
|
+
case 'SpreadElement': {
|
|
154
|
+
const spreadValue = getValueFromNode(prop, state);
|
|
155
|
+
if (spreadValue !== UNSUPPORTED_SPREAD &&
|
|
156
|
+
spreadValue &&
|
|
157
|
+
typeof spreadValue === 'object') {
|
|
158
|
+
Object.assign(obj, spreadValue);
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
96
161
|
}
|
|
162
|
+
default:
|
|
163
|
+
// Ignore unsupported property types, as we don't have a key for them.
|
|
164
|
+
// This could be a computed property or something else we don't handle.
|
|
165
|
+
break;
|
|
97
166
|
}
|
|
98
167
|
});
|
|
99
168
|
return obj;
|
|
100
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Spread elements are a bit tricky. They can be used to directly spread an array or object,
|
|
172
|
+
* or they can be used to spread a variable that is defined elsewhere. Our strategy is to return
|
|
173
|
+
* whatever element should be spread, and then handle the spreading in the parent array or object.
|
|
174
|
+
*
|
|
175
|
+
* There are also trickier cases we don't handle, like spreading a function call that returns an
|
|
176
|
+
* array or object. When the spread element is unsupported, we return a special symbol.
|
|
177
|
+
*/
|
|
178
|
+
case 'SpreadElement':
|
|
179
|
+
if (node.argument) {
|
|
180
|
+
if (node.argument.type === 'Identifier' && node.argument.name) {
|
|
181
|
+
return state.variableDeclarations.get(node.argument.name) || null;
|
|
182
|
+
}
|
|
183
|
+
else if (node.argument.type === 'ArrayExpression' ||
|
|
184
|
+
node.argument.type === 'ObjectExpression') {
|
|
185
|
+
return getValueFromNode(node.argument, state);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return UNSUPPORTED_SPREAD;
|
|
189
|
+
/**
|
|
190
|
+
* Template literals are built of an alternating sequence of static
|
|
191
|
+
* strings and expressions. We will concatenate the static strings and
|
|
192
|
+
* evaluate the expressions to build the final string.
|
|
193
|
+
*/
|
|
194
|
+
case 'TemplateLiteral': {
|
|
195
|
+
let result = '';
|
|
196
|
+
if (node.expressions && node.quasis) {
|
|
197
|
+
const { quasis, expressions } = node;
|
|
198
|
+
for (let i = 0; i < quasis.length; i++) {
|
|
199
|
+
// Prefer cooked value if available, otherwise use raw.
|
|
200
|
+
result += quasis[i].value.cooked || quasis[i].value.raw;
|
|
201
|
+
if (i < expressions.length) {
|
|
202
|
+
const expression = expressions[i];
|
|
203
|
+
const expressionValue = getValueFromNode(expression, state);
|
|
204
|
+
if (expressionValue === null ||
|
|
205
|
+
expressionValue === undefined ||
|
|
206
|
+
typeof expressionValue === 'string' ||
|
|
207
|
+
typeof expressionValue === 'number' ||
|
|
208
|
+
typeof expressionValue === 'boolean') {
|
|
209
|
+
result += String(expressionValue);
|
|
210
|
+
}
|
|
211
|
+
else if (Array.isArray(expressionValue)) {
|
|
212
|
+
result += expressionValue.join(',');
|
|
213
|
+
}
|
|
214
|
+
else if (typeof expressionValue === 'object') {
|
|
215
|
+
result += '[object Object]';
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
case 'UnaryExpression': {
|
|
223
|
+
const arg = getValueFromNode(node.argument, state);
|
|
224
|
+
switch (node.operator) {
|
|
225
|
+
case '-':
|
|
226
|
+
return typeof arg === 'number' ? -arg : NaN;
|
|
227
|
+
case '+':
|
|
228
|
+
return typeof arg === 'number' ? +arg : NaN;
|
|
229
|
+
case '!':
|
|
230
|
+
return !arg;
|
|
231
|
+
case 'typeof':
|
|
232
|
+
return typeof arg;
|
|
233
|
+
default:
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Member expressions are used to access properties of objects.
|
|
238
|
+
case 'MemberExpression': {
|
|
239
|
+
if (node.property.type === 'Identifier' && node.property.name) {
|
|
240
|
+
// We have to recursively get the value of the object, due to the way that nested objects are parsed.
|
|
241
|
+
const objectData = getValueFromNode(node.object, state);
|
|
242
|
+
if (objectData &&
|
|
243
|
+
typeof objectData === 'object' &&
|
|
244
|
+
!Array.isArray(objectData) &&
|
|
245
|
+
!(objectData instanceof RegExp)) {
|
|
246
|
+
return objectData[node.property.name];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
101
251
|
default:
|
|
102
252
|
return `Unsupported node type: ${node.type}`;
|
|
103
253
|
}
|
|
104
254
|
}
|
|
255
|
+
exports.getValueFromNode = getValueFromNode;
|
|
105
256
|
/**
|
|
106
257
|
* We only support image imports that are within the extension directory.
|
|
107
258
|
* This function will check if an image is out of bounds and collect any that are out of bounds, so we can warn the user before they run into build issues.
|
|
@@ -124,6 +275,7 @@ function checkForOutOfBoundsImageImports(node, output, extensionPath) {
|
|
|
124
275
|
}
|
|
125
276
|
}
|
|
126
277
|
}
|
|
278
|
+
exports.checkForOutOfBoundsImageImports = checkForOutOfBoundsImageImports;
|
|
127
279
|
/**
|
|
128
280
|
* This function collects all internal data dependencies for the extension
|
|
129
281
|
* Specifically, it collects dependencies which are using our custom hooks, eg `useCrmProperties`
|
|
@@ -180,53 +332,47 @@ function _collectDataDependencies(node, output, logger) {
|
|
|
180
332
|
// Then we handle each hook individually, as the usages and tracking format are different.
|
|
181
333
|
if (hookName === 'useCrmProperties') {
|
|
182
334
|
const propertyType = 'CrmRecordProperties';
|
|
183
|
-
// Get the first argument, the properties array
|
|
184
335
|
const propertiesNode = node.arguments[0];
|
|
185
336
|
const optionsNode = node.arguments[1];
|
|
186
337
|
const requestedProperties = [];
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
else {
|
|
202
|
-
logger.warn(`Invalid property type in useCrmProperties: ${element ? element.type : 'undefined'}`);
|
|
338
|
+
const resolveValue = (astNode) => {
|
|
339
|
+
if (!astNode)
|
|
340
|
+
return null;
|
|
341
|
+
if (astNode.type === 'Identifier' &&
|
|
342
|
+
output.variableDeclarations.has(astNode.name)) {
|
|
343
|
+
return output.variableDeclarations.get(astNode.name);
|
|
344
|
+
}
|
|
345
|
+
return getValueFromNode(astNode, output);
|
|
346
|
+
};
|
|
347
|
+
const propertiesValue = resolveValue(propertiesNode);
|
|
348
|
+
if (propertiesValue && Array.isArray(propertiesValue)) {
|
|
349
|
+
propertiesValue.forEach((val) => {
|
|
350
|
+
if (typeof val === 'string') {
|
|
351
|
+
requestedProperties.push(val);
|
|
203
352
|
}
|
|
204
353
|
});
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
options = optionsValue;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
output.dataDependencies.dependencies.push({
|
|
218
|
-
/**
|
|
219
|
-
* This refID is a hash of the property type and the requested properties.
|
|
220
|
-
* This should allow us to create the same hash at execution time, to find the correct data from BE.
|
|
221
|
-
*/
|
|
222
|
-
referenceId: (0, utils_1.generateHash)(propertyType, requestedProperties),
|
|
223
|
-
properties: {
|
|
224
|
-
type: propertyType,
|
|
225
|
-
recordProperties: requestedProperties,
|
|
226
|
-
options,
|
|
227
|
-
},
|
|
228
|
-
});
|
|
354
|
+
}
|
|
355
|
+
if (requestedProperties.length > 0) {
|
|
356
|
+
let options = {};
|
|
357
|
+
const optionsValue = resolveValue(optionsNode);
|
|
358
|
+
if (optionsValue &&
|
|
359
|
+
typeof optionsValue === 'object' &&
|
|
360
|
+
!Array.isArray(optionsValue) &&
|
|
361
|
+
!(optionsValue instanceof RegExp)) {
|
|
362
|
+
options = optionsValue;
|
|
229
363
|
}
|
|
364
|
+
output.dataDependencies.dependencies.push({
|
|
365
|
+
/**
|
|
366
|
+
* This referenceId is a hash of the property type and the requested properties.
|
|
367
|
+
* This should allow us to create the same hash at execution time, to find the correct data from BE.
|
|
368
|
+
*/
|
|
369
|
+
referenceId: (0, utils_1.generateHash)(propertyType, requestedProperties),
|
|
370
|
+
properties: {
|
|
371
|
+
type: propertyType,
|
|
372
|
+
recordProperties: requestedProperties,
|
|
373
|
+
options,
|
|
374
|
+
},
|
|
375
|
+
});
|
|
230
376
|
}
|
|
231
377
|
}
|
|
232
378
|
}
|
|
@@ -245,6 +391,7 @@ function traverseAbstractSyntaxTree(ast, checks, extensionPath, logger) {
|
|
|
245
391
|
importedHooks: {},
|
|
246
392
|
dependencies: [],
|
|
247
393
|
},
|
|
394
|
+
variableDeclarations: new Map(),
|
|
248
395
|
};
|
|
249
396
|
try {
|
|
250
397
|
(0, estraverse_1.traverse)(ast, {
|
|
@@ -254,6 +401,7 @@ function traverseAbstractSyntaxTree(ast, checks, extensionPath, logger) {
|
|
|
254
401
|
_checkForFunctionMetadata(node, parent, state, check.functionName);
|
|
255
402
|
});
|
|
256
403
|
checkForOutOfBoundsImageImports(node, state, extensionPath);
|
|
404
|
+
_collectVariableDeclarations(node, state);
|
|
257
405
|
_collectDataDependencies(node, state, logger);
|
|
258
406
|
}
|
|
259
407
|
catch (e) {
|
|
@@ -268,3 +416,4 @@ function traverseAbstractSyntaxTree(ast, checks, extensionPath, logger) {
|
|
|
268
416
|
}
|
|
269
417
|
return state;
|
|
270
418
|
}
|
|
419
|
+
exports.traverseAbstractSyntaxTree = traverseAbstractSyntaxTree;
|
package/dist/lib/build.js
CHANGED
|
@@ -12,9 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.extensionErrorBaseMessage = void 0;
|
|
16
|
-
exports.buildSingleExtension = buildSingleExtension;
|
|
17
|
-
exports.remoteBuild = remoteBuild;
|
|
15
|
+
exports.remoteBuild = exports.buildSingleExtension = exports.extensionErrorBaseMessage = void 0;
|
|
18
16
|
const vite_1 = require("vite");
|
|
19
17
|
const constants_1 = require("./constants");
|
|
20
18
|
const manifestPlugin_1 = __importDefault(require("./plugins/manifestPlugin"));
|
|
@@ -24,9 +22,9 @@ const codeBlockingPlugin_1 = __importDefault(require("./plugins/codeBlockingPlug
|
|
|
24
22
|
const friendlyLoggingPlugin_1 = __importDefault(require("./plugins/friendlyLoggingPlugin"));
|
|
25
23
|
const allowedExtensions = ['.js', '.ts', '.tsx', '.jsx'];
|
|
26
24
|
exports.extensionErrorBaseMessage = `Supported file extensions are [${allowedExtensions.join(', ')}], received:`;
|
|
27
|
-
function buildSingleExtension(
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
function buildSingleExtension({ file, outputDir = constants_1.OUTPUT_DIR, emptyOutDir = true, minify = false, root = process.cwd(), // This is the vite default, so using that as our default
|
|
26
|
+
logLevel = 'info', }) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
28
|
const output = (0, utils_1.getUrlSafeFileName)(file);
|
|
31
29
|
yield (0, vite_1.build)({
|
|
32
30
|
logLevel,
|
|
@@ -53,8 +51,9 @@ function buildSingleExtension(_a) {
|
|
|
53
51
|
});
|
|
54
52
|
});
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
exports.buildSingleExtension = buildSingleExtension;
|
|
55
|
+
function remoteBuild(root, entryPoint, outputDir = constants_1.OUTPUT_DIR, logLevel) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
57
|
const fileInfo = path_1.default.parse(entryPoint);
|
|
59
58
|
if (!allowedExtensions.includes(fileInfo.ext)) {
|
|
60
59
|
throw new Error(`${exports.extensionErrorBaseMessage} ${fileInfo.ext}`);
|
|
@@ -68,3 +67,4 @@ function remoteBuild(root_1, entryPoint_1) {
|
|
|
68
67
|
});
|
|
69
68
|
});
|
|
70
69
|
}
|
|
70
|
+
exports.remoteBuild = remoteBuild;
|
package/dist/lib/config.js
CHANGED
|
@@ -5,12 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.loadConfigByPath =
|
|
9
|
-
exports.validateCardConfig = validateCardConfig;
|
|
10
|
-
exports.loadExtensionConfig = loadExtensionConfig;
|
|
11
|
-
exports.validateProxyConfigKey = validateProxyConfigKey;
|
|
12
|
-
exports.validateProxyConfigValue = validateProxyConfigValue;
|
|
13
|
-
exports.loadLocalConfig = loadLocalConfig;
|
|
8
|
+
exports.loadLocalConfig = exports.validateProxyConfigValue = exports.validateProxyConfigKey = exports.loadExtensionConfig = exports.validateCardConfig = exports.loadConfigByPath = void 0;
|
|
14
9
|
const fs_1 = __importDefault(require("fs"));
|
|
15
10
|
const path_1 = __importDefault(require("path"));
|
|
16
11
|
const utils_1 = require("./utils");
|
|
@@ -18,6 +13,7 @@ function loadConfigByPath(configPath) {
|
|
|
18
13
|
const source = fs_1.default.readFileSync(configPath).toString();
|
|
19
14
|
return JSON.parse(source);
|
|
20
15
|
}
|
|
16
|
+
exports.loadConfigByPath = loadConfigByPath;
|
|
21
17
|
function validateCardConfig(config) {
|
|
22
18
|
if (!config || typeof config !== 'object') {
|
|
23
19
|
return new Error('Card config must be an object');
|
|
@@ -54,6 +50,7 @@ function validateCardConfig(config) {
|
|
|
54
50
|
}
|
|
55
51
|
return true;
|
|
56
52
|
}
|
|
53
|
+
exports.validateCardConfig = validateCardConfig;
|
|
57
54
|
function loadExtensionConfig(appConfig, appPath) {
|
|
58
55
|
var _a, _b;
|
|
59
56
|
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;
|
|
@@ -84,6 +81,7 @@ function loadExtensionConfig(appConfig, appPath) {
|
|
|
84
81
|
});
|
|
85
82
|
return outputConfig;
|
|
86
83
|
}
|
|
84
|
+
exports.loadExtensionConfig = loadExtensionConfig;
|
|
87
85
|
function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
88
86
|
try {
|
|
89
87
|
const url = new URL(urlKey);
|
|
@@ -95,6 +93,7 @@ function validateProxyConfigKey(urlKey, logger, localConfigPath) {
|
|
|
95
93
|
logger.warn(`The key "${urlKey}" in "${localConfigPath}" is an invalid url`);
|
|
96
94
|
}
|
|
97
95
|
}
|
|
96
|
+
exports.validateProxyConfigKey = validateProxyConfigKey;
|
|
98
97
|
function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
99
98
|
try {
|
|
100
99
|
// eslint-disable-next-line no-new
|
|
@@ -104,6 +103,7 @@ function validateProxyConfigValue(value, key, logger, localConfigPath) {
|
|
|
104
103
|
logger.warn(`The value "${value}" for key "${key}" in "${localConfigPath}" is an invalid url`);
|
|
105
104
|
}
|
|
106
105
|
}
|
|
106
|
+
exports.validateProxyConfigValue = validateProxyConfigValue;
|
|
107
107
|
function loadLocalConfig(appPath, logger) {
|
|
108
108
|
const localConfigFilename = 'local.json';
|
|
109
109
|
const localConfigPath = path_1.default.join(appPath, localConfigFilename);
|
|
@@ -125,3 +125,4 @@ function loadLocalConfig(appPath, logger) {
|
|
|
125
125
|
return undefined;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
exports.loadLocalConfig = loadLocalConfig;
|
package/dist/lib/dev.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.startDevMode =
|
|
15
|
+
exports.startDevMode = void 0;
|
|
16
16
|
const vite_1 = require("vite");
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const server_1 = __importDefault(require("./server"));
|
|
@@ -73,3 +73,4 @@ function startDevMode(devServerState) {
|
|
|
73
73
|
return shutdownServer;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
exports.startDevMode = startDevMode;
|
|
@@ -6,7 +6,7 @@ const ast_1 = require("../ast");
|
|
|
6
6
|
const codeBlockingPlugin = ({ logger, extensionPath }) => {
|
|
7
7
|
return {
|
|
8
8
|
name: 'ui-extensions-code-blocking-plugin',
|
|
9
|
-
enforce: 'post',
|
|
9
|
+
enforce: 'post',
|
|
10
10
|
transform(code, filename) {
|
|
11
11
|
if ((0, utils_1.isNodeModule)(filename)) {
|
|
12
12
|
return { code, map: null }; // We don't want to parse node modules
|
|
@@ -18,6 +18,7 @@ const codeBlockingPlugin = ({ logger, extensionPath }) => {
|
|
|
18
18
|
importedHooks: {},
|
|
19
19
|
dependencies: [],
|
|
20
20
|
},
|
|
21
|
+
variableDeclarations: new Map(),
|
|
21
22
|
};
|
|
22
23
|
const requireFunctionName = 'require';
|
|
23
24
|
try {
|
|
@@ -17,23 +17,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
17
17
|
}) : function(o, v) {
|
|
18
18
|
o["default"] = v;
|
|
19
19
|
});
|
|
20
|
-
var __importStar = (this && this.__importStar) ||
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return ownKeys(o);
|
|
28
|
-
};
|
|
29
|
-
return function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
37
27
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
38
28
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
29
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -78,7 +68,7 @@ const devBuildPlugin = (options) => {
|
|
|
78
68
|
} }));
|
|
79
69
|
}
|
|
80
70
|
};
|
|
81
|
-
const devBuild = (
|
|
71
|
+
const devBuild = (server, extensionMetadata, emptyOutDir = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
72
|
try {
|
|
83
73
|
const { config: extensionConfig } = extensionMetadata;
|
|
84
74
|
const { extensionPath } = extensionConfig;
|
|
@@ -161,7 +151,7 @@ const devBuildPlugin = (options) => {
|
|
|
161
151
|
yield devBuild(localServer, devServerState.extensionsMetadata[i], i === 0);
|
|
162
152
|
}
|
|
163
153
|
}),
|
|
164
|
-
handleHotUpdate: (
|
|
154
|
+
handleHotUpdate: ({ file, server }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
155
|
// If the file is not in the relevantModules list, it's update is inconsequential
|
|
166
156
|
const extensionsToRebuild = devServerState.extensionsMetadata.filter((metadata) => {
|
|
167
157
|
const { config } = metadata;
|
|
@@ -17,7 +17,7 @@ const manifestPlugin = (options) => {
|
|
|
17
17
|
let allDataDependencies;
|
|
18
18
|
return {
|
|
19
19
|
name: 'ui-extensions-manifest-generation-plugin',
|
|
20
|
-
enforce: 'post',
|
|
20
|
+
enforce: 'post',
|
|
21
21
|
buildStart() {
|
|
22
22
|
// Reset the source metadata for the new build
|
|
23
23
|
allDataDependencies = [];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRelevantModules =
|
|
3
|
+
exports.getRelevantModules = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const relevantModules = {};
|
|
6
6
|
function getRelevantModules(output) {
|
|
7
7
|
return relevantModules[output] || [];
|
|
8
8
|
}
|
|
9
|
+
exports.getRelevantModules = getRelevantModules;
|
|
9
10
|
const relevantModulesPlugin = ({ output, logger }) => {
|
|
10
11
|
return {
|
|
11
12
|
name: 'ui-extensions-relevant-modules-plugin',
|
package/dist/lib/server.js
CHANGED
|
@@ -31,9 +31,9 @@ function listen(app, port) {
|
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
function startDevServer(
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
function startDevServer({ devServerState, viteDevServer, }) {
|
|
35
|
+
var _a;
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
const app = (0, express_1.default)();
|
|
38
38
|
// Setup middleware
|
|
39
39
|
app.use((0, cors_1.default)());
|
|
@@ -75,7 +75,7 @@ function startDevServer(_a) {
|
|
|
75
75
|
}
|
|
76
76
|
throw new Error(e);
|
|
77
77
|
}
|
|
78
|
-
(
|
|
78
|
+
(_a = devServerState.extensionsMetadata) === null || _a === void 0 ? void 0 : _a.forEach((metadata) => {
|
|
79
79
|
const { baseMessage } = metadata;
|
|
80
80
|
devServerState.logger.debug(`Listening at ${baseMessage.callback}`);
|
|
81
81
|
});
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PLATFORM_VERSION, PRIVATE_APP, PUBLIC_APP } from './constants';
|
|
2
2
|
import { LocalDevUrlMapping } from '@hubspot/app-functions-dev-server';
|
|
3
|
-
import { PromptModule } from 'inquirer';
|
|
4
3
|
export interface ObjectTypes {
|
|
5
4
|
name: string;
|
|
6
5
|
}
|
|
@@ -208,6 +207,10 @@ export type DataDependency = {
|
|
|
208
207
|
};
|
|
209
208
|
};
|
|
210
209
|
};
|
|
210
|
+
export type NodeValue = string | number | boolean | null | undefined | RegExp | bigint | symbol | NodeValue[] | NodeObject;
|
|
211
|
+
export type NodeObject = {
|
|
212
|
+
[key: string]: NodeValue;
|
|
213
|
+
};
|
|
211
214
|
export interface SourceCodeMetadata {
|
|
212
215
|
functions: {
|
|
213
216
|
[functionName: string]: FunctionMetadata;
|
|
@@ -219,6 +222,7 @@ export interface SourceCodeMetadata {
|
|
|
219
222
|
};
|
|
220
223
|
dependencies: DataDependency[];
|
|
221
224
|
};
|
|
225
|
+
variableDeclarations: Map<string, NodeValue>;
|
|
222
226
|
}
|
|
223
227
|
export interface FunctionInvocationCheck {
|
|
224
228
|
functionName: string;
|
|
@@ -246,7 +250,6 @@ export interface DevModeStartArguments {
|
|
|
246
250
|
}
|
|
247
251
|
export interface DevModeBaseSetupArguments {
|
|
248
252
|
onUploadRequired?: VoidFunction;
|
|
249
|
-
promptUser: PromptModule;
|
|
250
253
|
logger: Logger;
|
|
251
254
|
urls: {
|
|
252
255
|
api: string;
|
package/dist/lib/utils.js
CHANGED
|
@@ -3,17 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UnhandledPlatformVersionError = void 0;
|
|
7
|
-
exports.getUrlSafeFileName = getUrlSafeFileName;
|
|
8
|
-
exports.stripAnsiColorCodes = stripAnsiColorCodes;
|
|
9
|
-
exports.loadManifest = loadManifest;
|
|
10
|
-
exports.buildSourceId = buildSourceId;
|
|
11
|
-
exports.isNodeModule = isNodeModule;
|
|
12
|
-
exports.isExtensionFile = isExtensionFile;
|
|
13
|
-
exports.throwUnhandledPlatformVersionError = throwUnhandledPlatformVersionError;
|
|
14
|
-
exports.extractAllowedUrls = extractAllowedUrls;
|
|
15
|
-
exports.generateHash = generateHash;
|
|
16
|
-
exports.isImage = isImage;
|
|
6
|
+
exports.isImage = exports.generateHash = exports.extractAllowedUrls = exports.throwUnhandledPlatformVersionError = exports.UnhandledPlatformVersionError = exports.isExtensionFile = exports.isNodeModule = exports.buildSourceId = exports.loadManifest = exports.stripAnsiColorCodes = exports.getUrlSafeFileName = void 0;
|
|
17
7
|
const path_1 = __importDefault(require("path"));
|
|
18
8
|
const fs_1 = __importDefault(require("fs"));
|
|
19
9
|
const constants_1 = require("./constants");
|
|
@@ -21,6 +11,7 @@ function getUrlSafeFileName(filePath) {
|
|
|
21
11
|
const { name } = path_1.default.parse(filePath);
|
|
22
12
|
return encodeURIComponent(`${name}.js`);
|
|
23
13
|
}
|
|
14
|
+
exports.getUrlSafeFileName = getUrlSafeFileName;
|
|
24
15
|
// Strips ANSI color codes out of strings because we don't want to pass them to the browser
|
|
25
16
|
function stripAnsiColorCodes(stringWithColorCodes) {
|
|
26
17
|
if (!stringWithColorCodes) {
|
|
@@ -30,6 +21,7 @@ function stripAnsiColorCodes(stringWithColorCodes) {
|
|
|
30
21
|
// eslint-disable-next-line no-control-regex
|
|
31
22
|
/[\u001b][[]*([0-9]{1,4};?)*[m]/g, '');
|
|
32
23
|
}
|
|
24
|
+
exports.stripAnsiColorCodes = stripAnsiColorCodes;
|
|
33
25
|
function loadManifest(outputDir, output) {
|
|
34
26
|
try {
|
|
35
27
|
return JSON.parse(fs_1.default
|
|
@@ -40,12 +32,14 @@ function loadManifest(outputDir, output) {
|
|
|
40
32
|
return {};
|
|
41
33
|
}
|
|
42
34
|
}
|
|
35
|
+
exports.loadManifest = loadManifest;
|
|
43
36
|
function buildSourceId(appConfig, extensionConfig) {
|
|
44
37
|
if (appConfig.uid && extensionConfig.data.uid) {
|
|
45
38
|
return `${appConfig.uid}::${extensionConfig.data.uid}`;
|
|
46
39
|
}
|
|
47
40
|
return null;
|
|
48
41
|
}
|
|
42
|
+
exports.buildSourceId = buildSourceId;
|
|
49
43
|
function isNodeModule(filepath) {
|
|
50
44
|
if (!filepath) {
|
|
51
45
|
return false;
|
|
@@ -53,6 +47,7 @@ function isNodeModule(filepath) {
|
|
|
53
47
|
const directory = path_1.default.parse(filepath).dir;
|
|
54
48
|
return directory.includes('node_modules');
|
|
55
49
|
}
|
|
50
|
+
exports.isNodeModule = isNodeModule;
|
|
56
51
|
/**
|
|
57
52
|
* Check if a given file is within the extension path
|
|
58
53
|
*/
|
|
@@ -72,6 +67,7 @@ function isExtensionFile(filepath, extensionPath) {
|
|
|
72
67
|
return false;
|
|
73
68
|
}
|
|
74
69
|
}
|
|
70
|
+
exports.isExtensionFile = isExtensionFile;
|
|
75
71
|
class UnhandledPlatformVersionError extends Error {
|
|
76
72
|
constructor(platformVersion) {
|
|
77
73
|
super(`Unsupported platform version "${platformVersion}"`);
|
|
@@ -81,12 +77,14 @@ exports.UnhandledPlatformVersionError = UnhandledPlatformVersionError;
|
|
|
81
77
|
function throwUnhandledPlatformVersionError(platformVersion) {
|
|
82
78
|
throw new UnhandledPlatformVersionError(platformVersion);
|
|
83
79
|
}
|
|
80
|
+
exports.throwUnhandledPlatformVersionError = throwUnhandledPlatformVersionError;
|
|
84
81
|
function extractAllowedUrls(appConfig) {
|
|
85
82
|
if (!appConfig || !('allowedUrls' in appConfig) || !appConfig.allowedUrls) {
|
|
86
83
|
return [];
|
|
87
84
|
}
|
|
88
85
|
return appConfig.allowedUrls;
|
|
89
86
|
}
|
|
87
|
+
exports.extractAllowedUrls = extractAllowedUrls;
|
|
90
88
|
function simpleHash(input) {
|
|
91
89
|
let hash = 0;
|
|
92
90
|
for (let i = 0; i < input.length; i++) {
|
|
@@ -122,9 +120,11 @@ function generateHash(...args) {
|
|
|
122
120
|
return '';
|
|
123
121
|
}
|
|
124
122
|
}
|
|
123
|
+
exports.generateHash = generateHash;
|
|
125
124
|
/**
|
|
126
125
|
* Check if a given URL is an image (of a type we support)
|
|
127
126
|
*/
|
|
128
127
|
function isImage(url) {
|
|
129
128
|
return /\.(png|jpg|jpeg|gif|svg|webp|avif|raw|url|inline)$/.test(url);
|
|
130
129
|
}
|
|
130
|
+
exports.isImage = isImage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions-dev-server",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"uie": "./dist/lib/bin/cli.js"
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"optional": true
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "65046f5f3ce4c51652bc454e4425b57bd33aedbf"
|
|
74
74
|
}
|