@embeddable.com/sdk-core 4.0.0-next.1 → 4.0.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/index.esm.js +63 -21
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +22492 -0
- package/lib/index.js.map +1 -0
- package/package.json +3 -3
- package/src/buildTypes.test.ts +46 -0
- package/src/buildTypes.ts +3 -0
- package/src/defineConfig.test.ts +7 -7
- package/src/dev.test.ts +1554 -41
- package/src/dev.ts +67 -18
package/src/dev.ts
CHANGED
|
@@ -53,6 +53,10 @@ let browserWindow: ChildProcess | null = null;
|
|
|
53
53
|
|
|
54
54
|
let previewWorkspace: string;
|
|
55
55
|
|
|
56
|
+
// Build coordination to prevent duplicate plugin builds
|
|
57
|
+
let pluginBuildInProgress = false;
|
|
58
|
+
let pendingPluginBuilds: (() => Promise<void>)[] = [];
|
|
59
|
+
|
|
56
60
|
const SERVER_PORT = 8926;
|
|
57
61
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
58
62
|
// NOTE: for backward compatibility, keep the file name as global.css
|
|
@@ -62,6 +66,52 @@ export const buildWebComponent = async (config: any) => {
|
|
|
62
66
|
await generate(config, "sdk-react");
|
|
63
67
|
};
|
|
64
68
|
|
|
69
|
+
const executePluginBuilds = async (
|
|
70
|
+
config: ResolvedEmbeddableConfig,
|
|
71
|
+
watchers: Array<RollupWatcher | FSWatcher>,
|
|
72
|
+
) => {
|
|
73
|
+
if (pluginBuildInProgress) {
|
|
74
|
+
// If a plugin build is already in progress, queue this one
|
|
75
|
+
return new Promise<void>((resolve) => {
|
|
76
|
+
pendingPluginBuilds.push(async () => {
|
|
77
|
+
await doPluginBuilds(config, watchers);
|
|
78
|
+
resolve();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
// Start the plugin build immediately
|
|
83
|
+
await doPluginBuilds(config, watchers);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const doPluginBuilds = async (
|
|
88
|
+
config: ResolvedEmbeddableConfig,
|
|
89
|
+
watchers: Array<RollupWatcher | FSWatcher>,
|
|
90
|
+
) => {
|
|
91
|
+
pluginBuildInProgress = true;
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
for (const getPlugin of config.plugins) {
|
|
95
|
+
const plugin = getPlugin();
|
|
96
|
+
|
|
97
|
+
await plugin.validate(config);
|
|
98
|
+
const watcher = await plugin.build(config);
|
|
99
|
+
await configureWatcher(watcher as RollupWatcher, config);
|
|
100
|
+
watchers.push(watcher as RollupWatcher);
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
pluginBuildInProgress = false;
|
|
104
|
+
|
|
105
|
+
// Process any pending builds
|
|
106
|
+
if (pendingPluginBuilds.length > 0) {
|
|
107
|
+
const nextBuild = pendingPluginBuilds.shift();
|
|
108
|
+
if (nextBuild) {
|
|
109
|
+
await nextBuild();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
65
115
|
const addToGitingore = async () => {
|
|
66
116
|
try {
|
|
67
117
|
const gitignorePath = path.resolve(process.cwd(), ".gitignore");
|
|
@@ -215,17 +265,8 @@ export default async () => {
|
|
|
215
265
|
await sendBuildChanges(config);
|
|
216
266
|
|
|
217
267
|
if (config.pushComponents) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
breadcrumbs.push("validate plugin");
|
|
222
|
-
await plugin.validate(config);
|
|
223
|
-
breadcrumbs.push("build plugin");
|
|
224
|
-
const watcher = await plugin.build(config);
|
|
225
|
-
breadcrumbs.push("configure watcher");
|
|
226
|
-
await configureWatcher(watcher as RollupWatcher, config);
|
|
227
|
-
watchers.push(watcher as RollupWatcher);
|
|
228
|
-
}
|
|
268
|
+
breadcrumbs.push("build plugins with coordination");
|
|
269
|
+
await executePluginBuilds(config, watchers);
|
|
229
270
|
|
|
230
271
|
const customCanvasCssWatch = globalCustomCanvasWatcher(config);
|
|
231
272
|
watchers.push(customCanvasCssWatch);
|
|
@@ -440,13 +481,21 @@ export const sendBuildChanges = async (ctx: ResolvedEmbeddableConfig) => {
|
|
|
440
481
|
filesList = [...filesList, ...cubeAndSecurityContextFileList];
|
|
441
482
|
}
|
|
442
483
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
484
|
+
try {
|
|
485
|
+
const token = await getToken();
|
|
486
|
+
await archive({
|
|
487
|
+
ctx,
|
|
488
|
+
filesList,
|
|
489
|
+
isDev: true,
|
|
490
|
+
});
|
|
491
|
+
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
492
|
+
} catch (e: any) {
|
|
493
|
+
sending.fail(
|
|
494
|
+
`Data models and/or security context synchronization failed with error: ${e.response?.data?.errorMessage ?? e.message ?? 'Unknown error'}`
|
|
495
|
+
);
|
|
496
|
+
return sendMessage("dataModelsAndOrSecurityContextUpdateError");
|
|
497
|
+
}
|
|
498
|
+
|
|
450
499
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
451
500
|
sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
|
|
452
501
|
};
|