@embeddable.com/sdk-core 3.6.0 → 3.7.0-next.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.
- package/lib/defineConfig.d.ts +4 -1
- package/lib/index.esm.js +2 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/src/build.d.ts +2 -0
- package/lib/src/build.test.d.ts +1 -0
- package/lib/src/buildTypes.d.ts +4 -0
- package/lib/src/buildTypes.test.d.ts +1 -0
- package/lib/src/cleanup.d.ts +10 -0
- package/lib/src/cleanup.test.d.ts +1 -0
- package/lib/src/createContext.d.ts +20 -0
- package/lib/src/credentials.d.ts +2 -0
- package/lib/src/defineConfig.d.ts +53 -0
- package/lib/src/dev.d.ts +2 -0
- package/lib/src/generate.d.ts +2 -0
- package/lib/src/globalCleanup.d.ts +2 -0
- package/lib/src/index.d.ts +5 -0
- package/lib/src/login.d.ts +4 -0
- package/lib/src/prepare.d.ts +3 -0
- package/lib/src/provideConfig.d.ts +2 -0
- package/lib/src/provideConfig.test.d.ts +1 -0
- package/lib/src/push.d.ts +13 -0
- package/lib/src/utils.d.ts +23 -0
- package/lib/src/utils.test.d.ts +1 -0
- package/lib/src/validate.d.ts +4 -0
- package/lib/src/validate.test.d.ts +1 -0
- package/loader/custom-esm-loader.mjs +47 -25
- package/package.json +1 -1
- package/src/defineConfig.test.ts +1 -0
- package/src/defineConfig.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: (ctx: any) => Promise<void>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type ManifestArgs = {
|
|
4
|
+
ctx: any;
|
|
5
|
+
typesFileName: string;
|
|
6
|
+
metaFileName: string;
|
|
7
|
+
editorsMetaFileName: string;
|
|
8
|
+
stencilWrapperFileName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function createManifest({ ctx, typesFileName, metaFileName, editorsMetaFileName, stencilWrapperFileName, }: ManifestArgs): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: (coreRoot: string, clientRoot: string) => {
|
|
2
|
+
core: {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
templatesDir: string;
|
|
5
|
+
configsDir: string;
|
|
6
|
+
};
|
|
7
|
+
client: {
|
|
8
|
+
rootDir: string;
|
|
9
|
+
buildDir: string;
|
|
10
|
+
srcDir: string;
|
|
11
|
+
tmpDir: string;
|
|
12
|
+
componentDir: string;
|
|
13
|
+
stencilBuild: string;
|
|
14
|
+
archiveFile: string;
|
|
15
|
+
};
|
|
16
|
+
outputOptions: {
|
|
17
|
+
typesEntryPointFilename: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type EmbeddableConfig = {
|
|
2
|
+
plugins: (() => {
|
|
3
|
+
pluginName: string;
|
|
4
|
+
build: (config: EmbeddableConfig) => Promise<unknown>;
|
|
5
|
+
cleanup: (config: EmbeddableConfig) => Promise<unknown>;
|
|
6
|
+
validate: (config: EmbeddableConfig) => Promise<unknown>;
|
|
7
|
+
})[];
|
|
8
|
+
pushBaseUrl?: string;
|
|
9
|
+
audienceUrl?: string;
|
|
10
|
+
authDomain?: string;
|
|
11
|
+
authClientId?: string;
|
|
12
|
+
errorFallbackComponent?: string;
|
|
13
|
+
applicationEnvironment?: string;
|
|
14
|
+
rollbarAccessToken?: string;
|
|
15
|
+
previewBaseUrl?: string;
|
|
16
|
+
componentsSrc?: string;
|
|
17
|
+
modelsSrc?: string;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, }: EmbeddableConfig) => {
|
|
20
|
+
core: {
|
|
21
|
+
rootDir: string;
|
|
22
|
+
templatesDir: string;
|
|
23
|
+
configsDir: string;
|
|
24
|
+
};
|
|
25
|
+
client: {
|
|
26
|
+
rootDir: string;
|
|
27
|
+
srcDir: string;
|
|
28
|
+
modelsSrc: string | undefined;
|
|
29
|
+
buildDir: string;
|
|
30
|
+
tmpDir: string;
|
|
31
|
+
componentDir: string;
|
|
32
|
+
stencilBuild: string;
|
|
33
|
+
archiveFile: string;
|
|
34
|
+
errorFallbackComponent: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
outputOptions: {
|
|
37
|
+
typesEntryPointFilename: string;
|
|
38
|
+
};
|
|
39
|
+
pushBaseUrl: string;
|
|
40
|
+
audienceUrl: string;
|
|
41
|
+
previewBaseUrl: string;
|
|
42
|
+
authDomain: string;
|
|
43
|
+
authClientId: string;
|
|
44
|
+
applicationEnvironment: string;
|
|
45
|
+
rollbarAccessToken: string;
|
|
46
|
+
plugins: (() => {
|
|
47
|
+
pluginName: string;
|
|
48
|
+
build: (config: EmbeddableConfig) => Promise<unknown>;
|
|
49
|
+
cleanup: (config: EmbeddableConfig) => Promise<unknown>;
|
|
50
|
+
validate: (config: EmbeddableConfig) => Promise<unknown>;
|
|
51
|
+
})[];
|
|
52
|
+
};
|
|
53
|
+
export default _default;
|
package/lib/src/dev.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const YAML_OR_JS_FILES: RegExp;
|
|
2
|
+
declare const _default: () => Promise<void>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare function archive(ctx: any, yamlFiles: [string, string][], includeBuild?: boolean): Promise<unknown>;
|
|
5
|
+
export declare function sendBuildByApiKey(ctx: any, { apiKey, email, message }: any): Promise<{
|
|
6
|
+
bundleId: any;
|
|
7
|
+
email: any;
|
|
8
|
+
message: any;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function sendBuild(ctx: any, { workspaceId, token }: {
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
token: string;
|
|
13
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const checkNodeVersion: () => Promise<boolean>;
|
|
2
|
+
/**
|
|
3
|
+
* Get the value of a process argument by key
|
|
4
|
+
* Example: getArgumentByKey("--email") or getArgumentByKey(["--email", "-e"])
|
|
5
|
+
* @param key The key to search for in the process arguments
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const getArgumentByKey: (key: string | string[]) => string | undefined;
|
|
9
|
+
export declare const SUCCESS_FLAG_FILE: string;
|
|
10
|
+
/**
|
|
11
|
+
* Store a flag in the credentials directory to indicate a successful build
|
|
12
|
+
* This is used to determine if the build was successful or not
|
|
13
|
+
*/
|
|
14
|
+
export declare const storeBuildSuccessFlag: () => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Remove the success flag from the credentials directory
|
|
17
|
+
*/
|
|
18
|
+
export declare const removeBuildSuccessFlag: () => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the build was successful
|
|
21
|
+
*/
|
|
22
|
+
export declare const checkBuildSuccess: () => Promise<boolean>;
|
|
23
|
+
export declare const getPackageVersion: (packageName: string) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const _default: (ctx: any, exitIfInvalid?: boolean) => Promise<boolean>;
|
|
2
|
+
export default _default;
|
|
3
|
+
export declare function dataModelsValidation(filesList: [string, string][]): Promise<string[]>;
|
|
4
|
+
export declare function securityContextValidation(filesList: [string, string][]): Promise<string[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,12 +9,34 @@
|
|
|
9
9
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
10
10
|
import { dirname, join } from "path";
|
|
11
11
|
import ts from "typescript";
|
|
12
|
-
// @ts-expect-error
|
|
13
12
|
import { readDefaultTsConfig } from "@swc-node/register/read-default-tsconfig";
|
|
14
13
|
import { compile } from "./custom-esm-register.cjs";
|
|
14
|
+
import fs from "fs";
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
const
|
|
16
|
+
// Find the tsconfig.json in the customer's project directory
|
|
17
|
+
const tsconfigPath = ts.findConfigFile(
|
|
18
|
+
process.cwd(),
|
|
19
|
+
fs.existsSync,
|
|
20
|
+
"tsconfig.json",
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
let tsconfig;
|
|
24
|
+
if (tsconfigPath) {
|
|
25
|
+
// Read and parse the tsconfig.json
|
|
26
|
+
const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
27
|
+
|
|
28
|
+
const parsedConfig = ts.parseJsonConfigFileContent(
|
|
29
|
+
configFile.config,
|
|
30
|
+
ts.sys,
|
|
31
|
+
dirname(tsconfigPath),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
tsconfig = parsedConfig.options;
|
|
35
|
+
} else {
|
|
36
|
+
tsconfig = await readDefaultTsConfig();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Set necessary compiler options
|
|
18
40
|
tsconfig.module = ts.ModuleKind.ESNext;
|
|
19
41
|
tsconfig.moduleResolution = ts.ModuleResolutionKind.Node16;
|
|
20
42
|
|
|
@@ -23,10 +45,12 @@ const moduleResolutionCache = ts.createModuleResolutionCache(
|
|
|
23
45
|
(x) => x,
|
|
24
46
|
tsconfig,
|
|
25
47
|
);
|
|
48
|
+
|
|
26
49
|
const host = {
|
|
27
50
|
fileExists: ts.sys.fileExists,
|
|
28
51
|
readFile: ts.sys.readFile,
|
|
29
52
|
};
|
|
53
|
+
|
|
30
54
|
const EXTENSIONS = [ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Mts];
|
|
31
55
|
const NON_JS_TS_EXTENSIONS =
|
|
32
56
|
/\.(css|scss|less|sass|styl|json|svg|woff|woff2|png|jpg|jpeg|gif|webp|md|yml|yaml)$/;
|
|
@@ -50,7 +74,7 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
50
74
|
|
|
51
75
|
const isTS = EXTENSIONS.some((ext) => specifier.endsWith(ext));
|
|
52
76
|
|
|
53
|
-
//
|
|
77
|
+
// Entry point
|
|
54
78
|
if (!context.parentURL) {
|
|
55
79
|
const processCwd = pathToFileURL(process.cwd()).href;
|
|
56
80
|
|
|
@@ -65,12 +89,13 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
65
89
|
};
|
|
66
90
|
}
|
|
67
91
|
|
|
68
|
-
//
|
|
92
|
+
// Determine if this is a package import
|
|
69
93
|
const isPackageImport =
|
|
70
94
|
!specifier.startsWith(".") &&
|
|
71
95
|
!specifier.startsWith("/") &&
|
|
72
|
-
!/^[A-Z]:/.test(specifier); //
|
|
73
|
-
|
|
96
|
+
!/^[A-Z]:/.test(specifier); // Windows path
|
|
97
|
+
|
|
98
|
+
// External library import
|
|
74
99
|
if (
|
|
75
100
|
(context.parentURL.includes("/node_modules/") || isPackageImport) &&
|
|
76
101
|
!isTS
|
|
@@ -80,6 +105,8 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
80
105
|
|
|
81
106
|
const isFileUrl = specifier.startsWith("file://");
|
|
82
107
|
const isParentFileUrl = context.parentURL.startsWith("file://");
|
|
108
|
+
|
|
109
|
+
// Resolve the module using TypeScript's module resolution
|
|
83
110
|
const { resolvedModule } = ts.resolveModuleName(
|
|
84
111
|
isFileUrl ? fileURLToPath(specifier) : specifier,
|
|
85
112
|
isParentFileUrl ? fileURLToPath(context.parentURL) : context.parentURL,
|
|
@@ -87,7 +114,8 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
87
114
|
host,
|
|
88
115
|
moduleResolutionCache,
|
|
89
116
|
);
|
|
90
|
-
|
|
117
|
+
|
|
118
|
+
// Local project TS file
|
|
91
119
|
if (
|
|
92
120
|
resolvedModule &&
|
|
93
121
|
!resolvedModule.resolvedFileName.includes("/node_modules/") &&
|
|
@@ -101,10 +129,8 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
101
129
|
shortCircuit: true,
|
|
102
130
|
};
|
|
103
131
|
}
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
// - external library
|
|
107
|
-
// - local project non-TS file
|
|
132
|
+
|
|
133
|
+
// Fallback for non-TS files or unresolved modules
|
|
108
134
|
const specifierPathOrUrl =
|
|
109
135
|
!resolvedModule?.resolvedFileName?.includes("/node_modules/") && isWindows
|
|
110
136
|
? pathToFileURL(specifier).href
|
|
@@ -112,32 +138,28 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
112
138
|
|
|
113
139
|
return nextResolve(specifierPathOrUrl);
|
|
114
140
|
};
|
|
115
|
-
const tsconfigForSWCNode = {
|
|
116
|
-
...tsconfig,
|
|
117
|
-
paths: undefined,
|
|
118
|
-
baseUrl: undefined,
|
|
119
|
-
};
|
|
120
141
|
|
|
121
142
|
export const load = async (url, context, nextLoad) => {
|
|
122
143
|
if (context.format === "ts") {
|
|
123
144
|
const { source } = await nextLoad(url, context);
|
|
124
145
|
const code =
|
|
125
146
|
typeof source === "string" ? source : Buffer.from(source).toString();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
tsconfigForSWCNode,
|
|
130
|
-
true,
|
|
131
|
-
);
|
|
147
|
+
|
|
148
|
+
// Compile the code using @swc-node with the customer's tsconfig
|
|
149
|
+
const compiled = await compile(code, fileURLToPath(url), tsconfig, true);
|
|
132
150
|
return {
|
|
133
151
|
format: "module",
|
|
134
152
|
source: compiled,
|
|
135
153
|
shortCircuit: true,
|
|
136
154
|
};
|
|
137
155
|
} else {
|
|
138
|
-
if (
|
|
156
|
+
if (
|
|
157
|
+
isWindows &&
|
|
158
|
+
!url.startsWith("file://") &&
|
|
159
|
+
url.includes("node_modules")
|
|
160
|
+
) {
|
|
139
161
|
return nextLoad(pathToFileURL(url).href, context);
|
|
140
|
-
|
|
162
|
+
}
|
|
141
163
|
return nextLoad(url, context);
|
|
142
164
|
}
|
|
143
165
|
};
|
package/package.json
CHANGED
package/src/defineConfig.test.ts
CHANGED
|
@@ -54,6 +54,7 @@ describe("defineConfig", () => {
|
|
|
54
54
|
"componentDir": "/embeddable-sdk/packages/core-sdk",
|
|
55
55
|
"errorFallbackComponent": "/embeddable-sdk/packages/core-sdk",
|
|
56
56
|
"modelsSrc": "/embeddable-sdk/packages/core-sdk",
|
|
57
|
+
"rollupOptions": {},
|
|
57
58
|
"rootDir": "/embeddable-sdk/packages/core-sdk",
|
|
58
59
|
"srcDir": "/embeddable-sdk/packages/core-sdk",
|
|
59
60
|
"stencilBuild": "/embeddable-sdk/packages/core-sdk",
|
package/src/defineConfig.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
+
import { RollupOptions } from "rollup";
|
|
3
4
|
|
|
4
5
|
export type EmbeddableConfig = {
|
|
5
6
|
plugins: (() => {
|
|
@@ -23,6 +24,7 @@ export type EmbeddableConfig = {
|
|
|
23
24
|
alias?: Record<string, string>;
|
|
24
25
|
};
|
|
25
26
|
};
|
|
27
|
+
rollupOptions?: RollupOptions;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export default ({
|
|
@@ -38,6 +40,7 @@ export default ({
|
|
|
38
40
|
modelsSrc = "src",
|
|
39
41
|
componentsSrc = "src",
|
|
40
42
|
viteConfig = {},
|
|
43
|
+
rollupOptions = {},
|
|
41
44
|
}: EmbeddableConfig) => {
|
|
42
45
|
const coreRoot = path.resolve(__dirname, "..");
|
|
43
46
|
const clientRoot = process.cwd();
|
|
@@ -85,6 +88,7 @@ export default ({
|
|
|
85
88
|
: undefined,
|
|
86
89
|
bundleHash: undefined, // This will be set by the build process
|
|
87
90
|
viteConfig,
|
|
91
|
+
rollupOptions,
|
|
88
92
|
},
|
|
89
93
|
outputOptions: {
|
|
90
94
|
typesEntryPointFilename: "embeddable-types-entry-point.js",
|