@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/lib/index.esm.js
CHANGED
|
@@ -380,12 +380,12 @@ const loadJson = async (filePath) => {
|
|
|
380
380
|
|
|
381
381
|
const getComponentLibraryConfig = (componentLibrary) => {
|
|
382
382
|
let libraryName = componentLibrary;
|
|
383
|
-
|
|
383
|
+
let include;
|
|
384
384
|
const exclude = [];
|
|
385
385
|
if (typeof componentLibrary === "object" && componentLibrary !== null) {
|
|
386
386
|
libraryName = componentLibrary.name;
|
|
387
387
|
if (componentLibrary.include) {
|
|
388
|
-
include
|
|
388
|
+
include = [...componentLibrary.include];
|
|
389
389
|
}
|
|
390
390
|
if (componentLibrary.exclude) {
|
|
391
391
|
exclude.push(...componentLibrary.exclude);
|
|
@@ -422,12 +422,15 @@ async function generate$1(ctx) {
|
|
|
422
422
|
await fs.writeFile(path$1.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
423
423
|
}
|
|
424
424
|
async function build$1(ctx) {
|
|
425
|
-
var _a;
|
|
425
|
+
var _a, _b, _c, _d;
|
|
426
426
|
const typesFilePath = path$1.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename);
|
|
427
427
|
await vite.build({
|
|
428
428
|
logLevel: "error",
|
|
429
429
|
build: {
|
|
430
430
|
emptyOutDir: false,
|
|
431
|
+
sourcemap: ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch) ? false : true, // No sourcemaps for types in dev
|
|
432
|
+
minify: !((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch), // No minification in dev
|
|
433
|
+
rollupOptions: ((_c = ctx.dev) === null || _c === void 0 ? void 0 : _c.watch) ? { treeshake: false } : undefined,
|
|
431
434
|
lib: {
|
|
432
435
|
entry: typesFilePath,
|
|
433
436
|
formats: ["es"],
|
|
@@ -436,7 +439,7 @@ async function build$1(ctx) {
|
|
|
436
439
|
outDir: ctx.client.buildDir,
|
|
437
440
|
},
|
|
438
441
|
});
|
|
439
|
-
if (!((
|
|
442
|
+
if (!((_d = ctx.dev) === null || _d === void 0 ? void 0 : _d.watch)) {
|
|
440
443
|
const fileContent = await fs.readFile(typesFilePath, "utf8");
|
|
441
444
|
const fileHash = getContentHash(fileContent);
|
|
442
445
|
const fileName = `embeddable-types-${fileHash}.js`;
|
|
@@ -22063,6 +22066,9 @@ let wss;
|
|
|
22063
22066
|
let changedFiles = [];
|
|
22064
22067
|
let browserWindow = null;
|
|
22065
22068
|
let previewWorkspace;
|
|
22069
|
+
// Build coordination to prevent duplicate plugin builds
|
|
22070
|
+
let pluginBuildInProgress = false;
|
|
22071
|
+
let pendingPluginBuilds = [];
|
|
22066
22072
|
const SERVER_PORT = 8926;
|
|
22067
22073
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
22068
22074
|
// NOTE: for backward compatibility, keep the file name as global.css
|
|
@@ -22070,6 +22076,43 @@ const CUSTOM_CANVAS_CSS = "/global.css";
|
|
|
22070
22076
|
const buildWebComponent = async (config) => {
|
|
22071
22077
|
await generate(config, "sdk-react");
|
|
22072
22078
|
};
|
|
22079
|
+
const executePluginBuilds = async (config, watchers) => {
|
|
22080
|
+
if (pluginBuildInProgress) {
|
|
22081
|
+
// If a plugin build is already in progress, queue this one
|
|
22082
|
+
return new Promise((resolve) => {
|
|
22083
|
+
pendingPluginBuilds.push(async () => {
|
|
22084
|
+
await doPluginBuilds(config, watchers);
|
|
22085
|
+
resolve();
|
|
22086
|
+
});
|
|
22087
|
+
});
|
|
22088
|
+
}
|
|
22089
|
+
else {
|
|
22090
|
+
// Start the plugin build immediately
|
|
22091
|
+
await doPluginBuilds(config, watchers);
|
|
22092
|
+
}
|
|
22093
|
+
};
|
|
22094
|
+
const doPluginBuilds = async (config, watchers) => {
|
|
22095
|
+
pluginBuildInProgress = true;
|
|
22096
|
+
try {
|
|
22097
|
+
for (const getPlugin of config.plugins) {
|
|
22098
|
+
const plugin = getPlugin();
|
|
22099
|
+
await plugin.validate(config);
|
|
22100
|
+
const watcher = await plugin.build(config);
|
|
22101
|
+
await configureWatcher(watcher, config);
|
|
22102
|
+
watchers.push(watcher);
|
|
22103
|
+
}
|
|
22104
|
+
}
|
|
22105
|
+
finally {
|
|
22106
|
+
pluginBuildInProgress = false;
|
|
22107
|
+
// Process any pending builds
|
|
22108
|
+
if (pendingPluginBuilds.length > 0) {
|
|
22109
|
+
const nextBuild = pendingPluginBuilds.shift();
|
|
22110
|
+
if (nextBuild) {
|
|
22111
|
+
await nextBuild();
|
|
22112
|
+
}
|
|
22113
|
+
}
|
|
22114
|
+
}
|
|
22115
|
+
};
|
|
22073
22116
|
const addToGitingore = async () => {
|
|
22074
22117
|
try {
|
|
22075
22118
|
const gitignorePath = path.resolve(process.cwd(), ".gitignore");
|
|
@@ -22184,16 +22227,8 @@ var dev = async () => {
|
|
|
22184
22227
|
});
|
|
22185
22228
|
await sendBuildChanges(config);
|
|
22186
22229
|
if (config.pushComponents) {
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
breadcrumbs.push("validate plugin");
|
|
22190
|
-
await plugin.validate(config);
|
|
22191
|
-
breadcrumbs.push("build plugin");
|
|
22192
|
-
const watcher = await plugin.build(config);
|
|
22193
|
-
breadcrumbs.push("configure watcher");
|
|
22194
|
-
await configureWatcher(watcher, config);
|
|
22195
|
-
watchers.push(watcher);
|
|
22196
|
-
}
|
|
22230
|
+
breadcrumbs.push("build plugins with coordination");
|
|
22231
|
+
await executePluginBuilds(config, watchers);
|
|
22197
22232
|
const customCanvasCssWatch = globalCustomCanvasWatcher(config);
|
|
22198
22233
|
watchers.push(customCanvasCssWatch);
|
|
22199
22234
|
if (themeWatcher) {
|
|
@@ -22321,6 +22356,7 @@ const globalCustomCanvasWatcher = (ctx) => {
|
|
|
22321
22356
|
return fsWatcher;
|
|
22322
22357
|
};
|
|
22323
22358
|
const sendBuildChanges = async (ctx) => {
|
|
22359
|
+
var _a, _b, _c, _d;
|
|
22324
22360
|
const isValid = await validate(ctx);
|
|
22325
22361
|
if (!isValid) {
|
|
22326
22362
|
return sendMessage("dataModelsAndOrSecurityContextUpdateError");
|
|
@@ -22351,13 +22387,19 @@ const sendBuildChanges = async (ctx) => {
|
|
|
22351
22387
|
].map((entry) => [path.basename(entry[1]), entry[1]]);
|
|
22352
22388
|
filesList = [...filesList, ...cubeAndSecurityContextFileList];
|
|
22353
22389
|
}
|
|
22354
|
-
|
|
22355
|
-
|
|
22356
|
-
|
|
22357
|
-
|
|
22358
|
-
|
|
22359
|
-
|
|
22360
|
-
|
|
22390
|
+
try {
|
|
22391
|
+
const token = await getToken();
|
|
22392
|
+
await archive({
|
|
22393
|
+
ctx,
|
|
22394
|
+
filesList,
|
|
22395
|
+
isDev: true,
|
|
22396
|
+
});
|
|
22397
|
+
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
22398
|
+
}
|
|
22399
|
+
catch (e) {
|
|
22400
|
+
sending.fail(`Data models and/or security context synchronization failed with error: ${(_d = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errorMessage) !== null && _c !== void 0 ? _c : e.message) !== null && _d !== void 0 ? _d : 'Unknown error'}`);
|
|
22401
|
+
return sendMessage("dataModelsAndOrSecurityContextUpdateError");
|
|
22402
|
+
}
|
|
22361
22403
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
22362
22404
|
sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
|
|
22363
22405
|
};
|