@embeddables/cli 0.8.0 → 0.8.2
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/auth/index.d.ts +43 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +102 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +210 -0
- package/dist/commands/branch.d.ts +4 -0
- package/dist/commands/branch.d.ts.map +1 -0
- package/dist/commands/branch.js +67 -0
- package/dist/commands/build-workbench.d.ts +5 -0
- package/dist/commands/build-workbench.d.ts.map +1 -0
- package/dist/commands/build-workbench.js +116 -0
- package/dist/commands/build.d.ts +8 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +60 -0
- package/dist/commands/builder-open.d.ts +4 -0
- package/dist/commands/builder-open.d.ts.map +1 -0
- package/dist/commands/builder-open.js +74 -0
- package/dist/commands/dev.d.ts +12 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +226 -0
- package/dist/commands/experiments-connect.d.ts +6 -0
- package/dist/commands/experiments-connect.d.ts.map +1 -0
- package/dist/commands/experiments-connect.js +140 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +384 -0
- package/dist/commands/inspect.d.ts +9 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +293 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +117 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +19 -0
- package/dist/commands/pull.d.ts +16 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +395 -0
- package/dist/commands/save.d.ts +30 -0
- package/dist/commands/save.d.ts.map +1 -0
- package/dist/commands/save.js +597 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +50 -0
- package/dist/compiler/errors.d.ts +20 -0
- package/dist/compiler/errors.d.ts.map +1 -0
- package/dist/compiler/errors.js +35 -0
- package/dist/compiler/evalStatic.d.ts +3 -0
- package/dist/compiler/evalStatic.d.ts.map +1 -0
- package/dist/compiler/evalStatic.js +57 -0
- package/dist/compiler/helpers/duplicateIds.d.ts +9 -0
- package/dist/compiler/helpers/duplicateIds.d.ts.map +1 -0
- package/dist/compiler/helpers/duplicateIds.js +71 -0
- package/dist/compiler/helpers/numericLeadingKeys.d.ts +8 -0
- package/dist/compiler/helpers/numericLeadingKeys.d.ts.map +1 -0
- package/dist/compiler/helpers/numericLeadingKeys.js +17 -0
- package/dist/compiler/index.d.ts +18 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +1272 -0
- package/dist/compiler/parsePage.d.ts +15 -0
- package/dist/compiler/parsePage.d.ts.map +1 -0
- package/dist/compiler/parsePage.js +654 -0
- package/dist/compiler/registry.d.ts +4 -0
- package/dist/compiler/registry.d.ts.map +1 -0
- package/dist/compiler/registry.js +44 -0
- package/dist/compiler/reverse.d.ts +23 -0
- package/dist/compiler/reverse.d.ts.map +1 -0
- package/dist/compiler/reverse.js +1938 -0
- package/dist/compiler/types.d.ts +21 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/compiler/types.js +1 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +21 -0
- package/dist/components/primitives/BaseComponent.d.ts +33 -0
- package/dist/components/primitives/BaseComponent.d.ts.map +1 -0
- package/dist/components/primitives/BaseComponent.js +26 -0
- package/dist/components/primitives/BookMeeting.d.ts +18 -0
- package/dist/components/primitives/BookMeeting.d.ts.map +1 -0
- package/dist/components/primitives/BookMeeting.js +5 -0
- package/dist/components/primitives/Chart.d.ts +41 -0
- package/dist/components/primitives/Chart.d.ts.map +1 -0
- package/dist/components/primitives/Chart.js +5 -0
- package/dist/components/primitives/Container.d.ts +8 -0
- package/dist/components/primitives/Container.d.ts.map +1 -0
- package/dist/components/primitives/Container.js +5 -0
- package/dist/components/primitives/CustomButton.d.ts +37 -0
- package/dist/components/primitives/CustomButton.d.ts.map +1 -0
- package/dist/components/primitives/CustomButton.js +10 -0
- package/dist/components/primitives/CustomHTML.d.ts +8 -0
- package/dist/components/primitives/CustomHTML.d.ts.map +1 -0
- package/dist/components/primitives/CustomHTML.js +5 -0
- package/dist/components/primitives/FileUpload.d.ts +18 -0
- package/dist/components/primitives/FileUpload.d.ts.map +1 -0
- package/dist/components/primitives/FileUpload.js +16 -0
- package/dist/components/primitives/InputBox.d.ts +34 -0
- package/dist/components/primitives/InputBox.d.ts.map +1 -0
- package/dist/components/primitives/InputBox.js +25 -0
- package/dist/components/primitives/Lottie.d.ts +11 -0
- package/dist/components/primitives/Lottie.d.ts.map +1 -0
- package/dist/components/primitives/Lottie.js +5 -0
- package/dist/components/primitives/MediaEmbed.d.ts +13 -0
- package/dist/components/primitives/MediaEmbed.d.ts.map +1 -0
- package/dist/components/primitives/MediaEmbed.js +6 -0
- package/dist/components/primitives/MediaImage.d.ts +8 -0
- package/dist/components/primitives/MediaImage.d.ts.map +1 -0
- package/dist/components/primitives/MediaImage.js +5 -0
- package/dist/components/primitives/OptionSelector.d.ts +38 -0
- package/dist/components/primitives/OptionSelector.d.ts.map +1 -0
- package/dist/components/primitives/OptionSelector.js +8 -0
- package/dist/components/primitives/PaypalCheckout.d.ts +25 -0
- package/dist/components/primitives/PaypalCheckout.d.ts.map +1 -0
- package/dist/components/primitives/PaypalCheckout.js +5 -0
- package/dist/components/primitives/PlainText.d.ts +6 -0
- package/dist/components/primitives/PlainText.d.ts.map +1 -0
- package/dist/components/primitives/PlainText.js +5 -0
- package/dist/components/primitives/ProgressBar.d.ts +15 -0
- package/dist/components/primitives/ProgressBar.d.ts.map +1 -0
- package/dist/components/primitives/ProgressBar.js +5 -0
- package/dist/components/primitives/RichText.d.ts +6 -0
- package/dist/components/primitives/RichText.d.ts.map +1 -0
- package/dist/components/primitives/RichText.js +5 -0
- package/dist/components/primitives/RichTextMarkdown.d.ts +6 -0
- package/dist/components/primitives/RichTextMarkdown.d.ts.map +1 -0
- package/dist/components/primitives/RichTextMarkdown.js +5 -0
- package/dist/components/primitives/Rive.d.ts +16 -0
- package/dist/components/primitives/Rive.d.ts.map +1 -0
- package/dist/components/primitives/Rive.js +8 -0
- package/dist/components/primitives/StripeCheckout.d.ts +52 -0
- package/dist/components/primitives/StripeCheckout.d.ts.map +1 -0
- package/dist/components/primitives/StripeCheckout.js +5 -0
- package/dist/components/primitives/StripeCheckout2.d.ts +30 -0
- package/dist/components/primitives/StripeCheckout2.d.ts.map +1 -0
- package/dist/components/primitives/StripeCheckout2.js +7 -0
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +42 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +9 -0
- package/dist/helpers/dates.d.ts +5 -0
- package/dist/helpers/dates.d.ts.map +1 -0
- package/dist/helpers/dates.js +7 -0
- package/dist/helpers/json.d.ts +47 -0
- package/dist/helpers/json.d.ts.map +1 -0
- package/dist/helpers/json.js +622 -0
- package/dist/helpers/prompt.d.ts +15 -0
- package/dist/helpers/prompt.d.ts.map +1 -0
- package/dist/helpers/prompt.js +35 -0
- package/dist/helpers/utils.d.ts +13 -0
- package/dist/helpers/utils.d.ts.map +1 -0
- package/dist/helpers/utils.js +28 -0
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +21 -0
- package/dist/patches/prompts-escape.d.ts +14 -0
- package/dist/patches/prompts-escape.d.ts.map +1 -0
- package/dist/patches/prompts-escape.js +23 -0
- package/dist/prompts/branches.d.ts +20 -0
- package/dist/prompts/branches.d.ts.map +1 -0
- package/dist/prompts/branches.js +86 -0
- package/dist/prompts/embeddables.d.ts +43 -0
- package/dist/prompts/embeddables.d.ts.map +1 -0
- package/dist/prompts/embeddables.js +200 -0
- package/dist/prompts/experiments.d.ts +28 -0
- package/dist/prompts/experiments.d.ts.map +1 -0
- package/dist/prompts/experiments.js +89 -0
- package/dist/prompts/index.d.ts +11 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +6 -0
- package/dist/prompts/projects.d.ts +22 -0
- package/dist/prompts/projects.d.ts.map +1 -0
- package/dist/prompts/projects.js +92 -0
- package/dist/prompts/versions.d.ts +18 -0
- package/dist/prompts/versions.d.ts.map +1 -0
- package/dist/prompts/versions.js +95 -0
- package/dist/proxy/injectApiInterceptor.d.ts +6 -0
- package/dist/proxy/injectApiInterceptor.d.ts.map +1 -0
- package/dist/proxy/injectApiInterceptor.js +66 -0
- package/dist/proxy/injectReload.d.ts +2 -0
- package/dist/proxy/injectReload.d.ts.map +1 -0
- package/dist/proxy/injectReload.js +14 -0
- package/dist/proxy/injectWorkbench.d.ts +5 -0
- package/dist/proxy/injectWorkbench.d.ts.map +1 -0
- package/dist/proxy/injectWorkbench.js +22 -0
- package/dist/proxy/server.d.ts +11 -0
- package/dist/proxy/server.d.ts.map +1 -0
- package/dist/proxy/server.js +304 -0
- package/dist/proxy/sse.d.ts +5 -0
- package/dist/proxy/sse.d.ts.map +1 -0
- package/dist/proxy/sse.js +17 -0
- package/dist/sentry-context.d.ts +48 -0
- package/dist/sentry-context.d.ts.map +1 -0
- package/dist/sentry-context.js +156 -0
- package/dist/stdout.d.ts +61 -0
- package/dist/stdout.d.ts.map +1 -0
- package/dist/stdout.js +163 -0
- package/dist/types-builder.d.ts +800 -0
- package/dist/types-builder.d.ts.map +1 -0
- package/dist/types-builder.js +20 -0
- package/dist/workbench/ActionsPanel.d.ts +6 -0
- package/dist/workbench/ActionsPanel.d.ts.map +1 -0
- package/dist/workbench/ActionsPanel.js +47 -0
- package/dist/workbench/AutofillPanel.d.ts +6 -0
- package/dist/workbench/AutofillPanel.d.ts.map +1 -0
- package/dist/workbench/AutofillPanel.js +543 -0
- package/dist/workbench/ComputedFieldsPanel.d.ts +6 -0
- package/dist/workbench/ComputedFieldsPanel.d.ts.map +1 -0
- package/dist/workbench/ComputedFieldsPanel.js +31 -0
- package/dist/workbench/ExperimentsPanel.d.ts +6 -0
- package/dist/workbench/ExperimentsPanel.d.ts.map +1 -0
- package/dist/workbench/ExperimentsPanel.js +182 -0
- package/dist/workbench/FieldEditorPanel.d.ts +9 -0
- package/dist/workbench/FieldEditorPanel.d.ts.map +1 -0
- package/dist/workbench/FieldEditorPanel.js +650 -0
- package/dist/workbench/InspectorPanel.d.ts +6 -0
- package/dist/workbench/InspectorPanel.d.ts.map +1 -0
- package/dist/workbench/InspectorPanel.js +341 -0
- package/dist/workbench/PageNavigator.d.ts +6 -0
- package/dist/workbench/PageNavigator.d.ts.map +1 -0
- package/dist/workbench/PageNavigator.js +123 -0
- package/dist/workbench/SchemaPanel.d.ts +6 -0
- package/dist/workbench/SchemaPanel.d.ts.map +1 -0
- package/dist/workbench/SchemaPanel.js +222 -0
- package/dist/workbench/UserDataPanel.d.ts +6 -0
- package/dist/workbench/UserDataPanel.d.ts.map +1 -0
- package/dist/workbench/UserDataPanel.js +350 -0
- package/dist/workbench/WorkbenchApp.d.ts +7 -0
- package/dist/workbench/WorkbenchApp.d.ts.map +1 -0
- package/dist/workbench/WorkbenchApp.js +193 -0
- package/dist/workbench/index.d.ts +10 -0
- package/dist/workbench/index.d.ts.map +1 -0
- package/dist/workbench/index.js +44 -0
- package/package.json +2 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
export class CompileError extends Error {
|
|
3
|
+
info;
|
|
4
|
+
constructor(message, info) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.info = info;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function formatError(e) {
|
|
10
|
+
if (e instanceof CompileError) {
|
|
11
|
+
const parts = [];
|
|
12
|
+
// File location
|
|
13
|
+
if (e.info?.file && e.info?.line != null) {
|
|
14
|
+
parts.push(`${pc.cyan(e.info.file)}:${pc.yellow(String(e.info.line))}:${pc.yellow(String(e.info.column ?? 0))}`);
|
|
15
|
+
}
|
|
16
|
+
// Page context
|
|
17
|
+
if (e.info?.pageKey) {
|
|
18
|
+
parts.push(`page: ${pc.magenta(e.info.pageKey)}`);
|
|
19
|
+
}
|
|
20
|
+
// Component context
|
|
21
|
+
if (e.info?.componentId || e.info?.componentKey) {
|
|
22
|
+
const componentParts = [];
|
|
23
|
+
if (e.info.componentId) {
|
|
24
|
+
componentParts.push(`id=${pc.cyan(e.info.componentId)}`);
|
|
25
|
+
}
|
|
26
|
+
if (e.info.componentKey) {
|
|
27
|
+
componentParts.push(`key=${pc.cyan(e.info.componentKey)}`);
|
|
28
|
+
}
|
|
29
|
+
parts.push(`component (${componentParts.join(', ')})`);
|
|
30
|
+
}
|
|
31
|
+
const where = parts.length > 0 ? parts.join(' | ') : '';
|
|
32
|
+
return `${pc.red('Error')} ${where}\n${e.message}`;
|
|
33
|
+
}
|
|
34
|
+
return String(e);
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evalStatic.d.ts","sourceRoot":"","sources":["../../src/compiler/evalStatic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAA;AAEtC,wBAAgB,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CA+DtF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CompileError } from './errors.js';
|
|
2
|
+
export function evalStatic(node, constEnv, file) {
|
|
3
|
+
switch (node.type) {
|
|
4
|
+
case 'StringLiteral':
|
|
5
|
+
return node.value;
|
|
6
|
+
case 'TemplateLiteral': {
|
|
7
|
+
// Support template literals with {{variable}} syntax (templating system)
|
|
8
|
+
// These are written as {`{{variable}}`} in JSX and should be converted to plain strings
|
|
9
|
+
// Note: {{variable}} is just a string pattern, not a JavaScript expression
|
|
10
|
+
// Template literals with actual expressions (${...}) are not supported
|
|
11
|
+
if (node.expressions.length > 0) {
|
|
12
|
+
throw new CompileError('Template literals with expressions are not supported. Use plain strings only.', loc(file, node));
|
|
13
|
+
}
|
|
14
|
+
// For simple template literals (no expressions), concatenate all quasis
|
|
15
|
+
// Use cooked value if available, otherwise fall back to raw
|
|
16
|
+
// This handles {`{{first_name}}'s plan`} → "{{first_name}}'s plan"
|
|
17
|
+
return node.quasis.map((q) => q.value.cooked ?? q.value.raw).join('');
|
|
18
|
+
}
|
|
19
|
+
case 'NumericLiteral':
|
|
20
|
+
return node.value;
|
|
21
|
+
case 'BooleanLiteral':
|
|
22
|
+
return node.value;
|
|
23
|
+
case 'NullLiteral':
|
|
24
|
+
return null;
|
|
25
|
+
case 'ArrayExpression':
|
|
26
|
+
return node.elements.map((el) => {
|
|
27
|
+
if (!el)
|
|
28
|
+
return null;
|
|
29
|
+
return evalStatic(el, constEnv, file);
|
|
30
|
+
});
|
|
31
|
+
case 'ObjectExpression': {
|
|
32
|
+
const out = {};
|
|
33
|
+
for (const prop of node.properties) {
|
|
34
|
+
if (prop.type !== 'ObjectProperty') {
|
|
35
|
+
throw new CompileError('Only plain object literals are supported.', loc(file, node));
|
|
36
|
+
}
|
|
37
|
+
if (prop.key.type !== 'Identifier' && prop.key.type !== 'StringLiteral') {
|
|
38
|
+
throw new CompileError('Only identifier/string keys supported in objects.', loc(file, node));
|
|
39
|
+
}
|
|
40
|
+
const k = prop.key.type === 'Identifier' ? prop.key.name : prop.key.value;
|
|
41
|
+
out[k] = evalStatic(prop.value, constEnv, file);
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
case 'Identifier': {
|
|
46
|
+
if (!constEnv.has(node.name)) {
|
|
47
|
+
throw new CompileError(`Unknown identifier "${node.name}" (must be a static const).`, loc(file, node));
|
|
48
|
+
}
|
|
49
|
+
return constEnv.get(node.name);
|
|
50
|
+
}
|
|
51
|
+
default:
|
|
52
|
+
throw new CompileError(`Unsupported expression "${node.type}". Use literals/arrays/objects/static const identifiers only.`, loc(file, node));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function loc(file, node) {
|
|
56
|
+
return { file, line: node.loc?.start?.line, column: node.loc?.start?.column };
|
|
57
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for deduplicating component/button IDs in forward and reverse compilers.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generates a new unique ID based on component/button type, e.g. plaintext_abcdefghij,
|
|
6
|
+
* button_abcdef, option_abcde. Used when deduplicating IDs in forward and reverse compilers.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateRandomIdByType(componentType: string, isOptionButton: boolean, existingIds: Set<string>, alsoExclude: Iterable<string>): string;
|
|
9
|
+
//# sourceMappingURL=duplicateIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicateIds.d.ts","sourceRoot":"","sources":["../../../src/compiler/helpers/duplicateIds.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwDH;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,OAAO,EACvB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC5B,MAAM,CAaR"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for deduplicating component/button IDs in forward and reverse compilers.
|
|
3
|
+
*/
|
|
4
|
+
const ID_RANDOM_CHARS = 'abcdefghijklmnopqrstuvwxyz';
|
|
5
|
+
/**
|
|
6
|
+
* Returns { prefix, suffixLen } for type-based ID generation.
|
|
7
|
+
* OptionSelector buttons use prefix "option" and length 5; components use a switch over type.
|
|
8
|
+
*/
|
|
9
|
+
function getIdPrefixAndLength(componentType, isOptionButton) {
|
|
10
|
+
if (isOptionButton) {
|
|
11
|
+
return { prefix: 'option', suffixLen: 12 };
|
|
12
|
+
}
|
|
13
|
+
switch (componentType) {
|
|
14
|
+
case 'PlainText':
|
|
15
|
+
return { prefix: 'text', suffixLen: 12 };
|
|
16
|
+
case 'CustomButton':
|
|
17
|
+
return { prefix: 'button', suffixLen: 12 };
|
|
18
|
+
case 'Container':
|
|
19
|
+
return { prefix: 'container', suffixLen: 12 };
|
|
20
|
+
case 'RichTextMarkdown':
|
|
21
|
+
return { prefix: 'richtext', suffixLen: 12 };
|
|
22
|
+
case 'CustomHTML':
|
|
23
|
+
return { prefix: 'html', suffixLen: 12 };
|
|
24
|
+
case 'InputBox':
|
|
25
|
+
return { prefix: 'input', suffixLen: 12 };
|
|
26
|
+
case 'OptionSelector':
|
|
27
|
+
return { prefix: 'optionselector', suffixLen: 12 };
|
|
28
|
+
case 'StripeCheckout2':
|
|
29
|
+
return { prefix: 'stripe', suffixLen: 12 };
|
|
30
|
+
case 'PaypalCheckout':
|
|
31
|
+
return { prefix: 'paypal', suffixLen: 12 };
|
|
32
|
+
case 'MediaImage':
|
|
33
|
+
return { prefix: 'image', suffixLen: 12 };
|
|
34
|
+
case 'MediaEmbed':
|
|
35
|
+
return { prefix: 'embed', suffixLen: 12 };
|
|
36
|
+
case 'Lottie':
|
|
37
|
+
return { prefix: 'lottie', suffixLen: 12 };
|
|
38
|
+
case 'Rive':
|
|
39
|
+
return { prefix: 'rive', suffixLen: 12 };
|
|
40
|
+
case 'ProgressBar':
|
|
41
|
+
return { prefix: 'progressbar', suffixLen: 12 };
|
|
42
|
+
case 'FileUpload':
|
|
43
|
+
return { prefix: 'fileupload', suffixLen: 12 };
|
|
44
|
+
case 'BookMeeting':
|
|
45
|
+
return { prefix: 'bookmeeting', suffixLen: 12 };
|
|
46
|
+
case 'Chart':
|
|
47
|
+
return { prefix: 'chart', suffixLen: 12 };
|
|
48
|
+
default:
|
|
49
|
+
return { prefix: componentType.toLowerCase(), suffixLen: 12 };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generates a new unique ID based on component/button type, e.g. plaintext_abcdefghij,
|
|
54
|
+
* button_abcdef, option_abcde. Used when deduplicating IDs in forward and reverse compilers.
|
|
55
|
+
*/
|
|
56
|
+
export function generateRandomIdByType(componentType, isOptionButton, existingIds, alsoExclude) {
|
|
57
|
+
const { prefix, suffixLen } = getIdPrefixAndLength(componentType, isOptionButton);
|
|
58
|
+
const excluded = new Set(existingIds);
|
|
59
|
+
for (const id of alsoExclude)
|
|
60
|
+
excluded.add(id);
|
|
61
|
+
for (;;) {
|
|
62
|
+
let suffix = '';
|
|
63
|
+
for (let i = 0; i < suffixLen; i++) {
|
|
64
|
+
suffix += ID_RANDOM_CHARS[Math.floor(Math.random() * ID_RANDOM_CHARS.length)];
|
|
65
|
+
}
|
|
66
|
+
const candidate = `${prefix}_${suffix}`;
|
|
67
|
+
if (!excluded.has(candidate))
|
|
68
|
+
return candidate;
|
|
69
|
+
excluded.add(candidate); // avoid retrying same value
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys and IDs must not start with a digit (invalid in JS/JSON).
|
|
3
|
+
* This helper produces a safe key by prefixing when needed.
|
|
4
|
+
*/
|
|
5
|
+
/** Returns a key safe for use (prefix applied if key starts with a digit). */
|
|
6
|
+
export declare function normalizeKeyIfStartsWithDigit(key: string | null, prefix: string): string | null;
|
|
7
|
+
export declare function keyOrIdStartsWithDigit(value: string | null | undefined): boolean;
|
|
8
|
+
//# sourceMappingURL=numericLeadingKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numericLeadingKeys.d.ts","sourceRoot":"","sources":["../../../src/compiler/helpers/numericLeadingKeys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI/F;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAIhF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys and IDs must not start with a digit (invalid in JS/JSON).
|
|
3
|
+
* This helper produces a safe key by prefixing when needed.
|
|
4
|
+
*/
|
|
5
|
+
/** Returns a key safe for use (prefix applied if key starts with a digit). */
|
|
6
|
+
export function normalizeKeyIfStartsWithDigit(key, prefix) {
|
|
7
|
+
if (key === null || typeof key !== 'string' || key === '')
|
|
8
|
+
return key;
|
|
9
|
+
if (!/^\d/.test(key))
|
|
10
|
+
return key;
|
|
11
|
+
return `${prefix}_${key}`;
|
|
12
|
+
}
|
|
13
|
+
export function keyOrIdStartsWithDigit(value) {
|
|
14
|
+
if (value === null || value === undefined || typeof value !== 'string' || value === '')
|
|
15
|
+
return false;
|
|
16
|
+
return /^\d/.test(value);
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a copy of newVal with object key order (recursively) matching oldVal
|
|
3
|
+
* where possible. Keeps existing keys in old order; appends new keys at the end.
|
|
4
|
+
* Arrays are not reordered; we recurse into elements by index for nested objects.
|
|
5
|
+
* Used so embeddable.json diffs show only actual changes, not reordering noise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function reorderObjectKeysToMatch(oldVal: unknown, newVal: unknown): unknown;
|
|
8
|
+
export declare function compileAllPages(opts: {
|
|
9
|
+
pagesGlob: string;
|
|
10
|
+
outPath: string;
|
|
11
|
+
pageKeyFrom: 'filename' | 'export';
|
|
12
|
+
stylesDir?: string;
|
|
13
|
+
embeddableId?: string;
|
|
14
|
+
configPath?: string;
|
|
15
|
+
/** When true, apply lint fixes (duplicate IDs, keys/IDs starting with a digit). When 'prompt', ask user to fix. */
|
|
16
|
+
fixLint?: true | 'prompt';
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compiler/index.ts"],"names":[],"mappings":"AAkDA;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CA2DlF;AA6BD,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,UAAU,GAAG,QAAQ,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mHAAmH;IACnH,OAAO,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAA;CAC1B,iBAseA"}
|