@embeddable.com/sdk-core 3.14.7-next.0 → 3.14.7-next.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/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
- const include = [];
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.push(...componentLibrary.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 (!((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)) {
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`;
@@ -21997,6 +22000,7 @@ async function archive(args) {
21997
22000
  archive.pipe(output);
21998
22001
  if (!isDev) {
21999
22002
  archive.directory(ctx.client.buildDir, false);
22003
+ // NOTE: for backward compatibility, keep the file name as global.css
22000
22004
  archive.file(ctx.client.customCanvasCss, {
22001
22005
  name: "global.css",
22002
22006
  });
@@ -22062,12 +22066,53 @@ let wss;
22062
22066
  let changedFiles = [];
22063
22067
  let browserWindow = null;
22064
22068
  let previewWorkspace;
22069
+ // Build coordination to prevent duplicate plugin builds
22070
+ let pluginBuildInProgress = false;
22071
+ let pendingPluginBuilds = [];
22065
22072
  const SERVER_PORT = 8926;
22066
22073
  const BUILD_DEV_DIR = ".embeddable-dev-build";
22074
+ // NOTE: for backward compatibility, keep the file name as global.css
22067
22075
  const CUSTOM_CANVAS_CSS = "/global.css";
22068
22076
  const buildWebComponent = async (config) => {
22069
22077
  await generate(config, "sdk-react");
22070
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
+ };
22071
22116
  const addToGitingore = async () => {
22072
22117
  try {
22073
22118
  const gitignorePath = path.resolve(process.cwd(), ".gitignore");
@@ -22182,16 +22227,8 @@ var dev = async () => {
22182
22227
  });
22183
22228
  await sendBuildChanges(config);
22184
22229
  if (config.pushComponents) {
22185
- for (const getPlugin of config.plugins) {
22186
- const plugin = getPlugin();
22187
- breadcrumbs.push("validate plugin");
22188
- await plugin.validate(config);
22189
- breadcrumbs.push("build plugin");
22190
- const watcher = await plugin.build(config);
22191
- breadcrumbs.push("configure watcher");
22192
- await configureWatcher(watcher, config);
22193
- watchers.push(watcher);
22194
- }
22230
+ breadcrumbs.push("build plugins with coordination");
22231
+ await executePluginBuilds(config, watchers);
22195
22232
  const customCanvasCssWatch = globalCustomCanvasWatcher(config);
22196
22233
  watchers.push(customCanvasCssWatch);
22197
22234
  if (themeWatcher) {