@embeddable.com/sdk-core 3.14.6 → 3.14.7-next.1

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.
@@ -23,7 +23,7 @@ export type EmbeddableConfig = {
23
23
  componentsSrc?: string;
24
24
  modelsSrc?: string;
25
25
  presetsSrc?: string;
26
- globalCss?: string;
26
+ customCanvasCss?: string;
27
27
  viteConfig?: {
28
28
  resolve?: {
29
29
  alias?: Record<string, string>;
@@ -50,7 +50,7 @@ export type ResolvedEmbeddableConfig = {
50
50
  presetsSrc: string;
51
51
  buildDir: string;
52
52
  tmpDir: string;
53
- globalCss: string;
53
+ customCanvasCss: string;
54
54
  componentDir: string;
55
55
  stencilBuild: string;
56
56
  archiveFile: string;
@@ -112,7 +112,7 @@ export declare const embeddableConfigSchema: z.ZodObject<{
112
112
  modelsSrc: z.ZodOptional<z.ZodString>;
113
113
  presetsSrc: z.ZodOptional<z.ZodString>;
114
114
  componentsSrc: z.ZodOptional<z.ZodString>;
115
- globalCss: z.ZodOptional<z.ZodString>;
115
+ customCanvasCss: z.ZodOptional<z.ZodString>;
116
116
  customizationFile: z.ZodOptional<z.ZodString>;
117
117
  lifecycleHooksFile: z.ZodOptional<z.ZodString>;
118
118
  componentLibraries: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodArray<z.ZodObject<{
@@ -162,7 +162,7 @@ export declare const embeddableConfigSchema: z.ZodObject<{
162
162
  modelsSrc?: string | undefined;
163
163
  presetsSrc?: string | undefined;
164
164
  componentsSrc?: string | undefined;
165
- globalCss?: string | undefined;
165
+ customCanvasCss?: string | undefined;
166
166
  customizationFile?: string | undefined;
167
167
  lifecycleHooksFile?: string | undefined;
168
168
  componentLibraries?: string[] | {
@@ -192,7 +192,7 @@ export declare const embeddableConfigSchema: z.ZodObject<{
192
192
  modelsSrc?: string | undefined;
193
193
  presetsSrc?: string | undefined;
194
194
  componentsSrc?: string | undefined;
195
- globalCss?: string | undefined;
195
+ customCanvasCss?: string | undefined;
196
196
  customizationFile?: string | undefined;
197
197
  lifecycleHooksFile?: string | undefined;
198
198
  componentLibraries?: string[] | {
@@ -220,7 +220,7 @@ declare const _default: (config: EmbeddableConfig) => {
220
220
  presetsSrc: string | undefined;
221
221
  buildDir: string;
222
222
  tmpDir: string;
223
- globalCss: string;
223
+ customCanvasCss: string;
224
224
  componentDir: string;
225
225
  stencilBuild: string;
226
226
  archiveFile: string;
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,7 +22000,8 @@ async function archive(args) {
21997
22000
  archive.pipe(output);
21998
22001
  if (!isDev) {
21999
22002
  archive.directory(ctx.client.buildDir, false);
22000
- archive.file(ctx.client.globalCss, {
22003
+ // NOTE: for backward compatibility, keep the file name as global.css
22004
+ archive.file(ctx.client.customCanvasCss, {
22001
22005
  name: "global.css",
22002
22006
  });
22003
22007
  }
@@ -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";
22067
- const GLOBAL_CSS = "/global.css";
22074
+ // NOTE: for backward compatibility, keep the file name as global.css
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");
@@ -22150,9 +22195,9 @@ var dev = async () => {
22150
22195
  }
22151
22196
  const done = finalhandler(request, res);
22152
22197
  try {
22153
- if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.endsWith(GLOBAL_CSS)) {
22198
+ if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.endsWith(CUSTOM_CANVAS_CSS)) {
22154
22199
  res.writeHead(200, { "Content-Type": "text/css" });
22155
- res.end(await fs.readFile(config.client.globalCss));
22200
+ res.end(await fs.readFile(config.client.customCanvasCss));
22156
22201
  return;
22157
22202
  }
22158
22203
  }
@@ -22182,18 +22227,10 @@ 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
- }
22195
- const customGlobalCssWatch = globalCssWatcher(config);
22196
- watchers.push(customGlobalCssWatch);
22230
+ breadcrumbs.push("build plugins with coordination");
22231
+ await executePluginBuilds(config, watchers);
22232
+ const customCanvasCssWatch = globalCustomCanvasWatcher(config);
22233
+ watchers.push(customCanvasCssWatch);
22197
22234
  if (themeWatcher) {
22198
22235
  await globalHookWatcher(themeWatcher);
22199
22236
  watchers.push(themeWatcher);
@@ -22311,8 +22348,8 @@ const cubeSecurityContextAndClientContextWatcher = async (ctx) => {
22311
22348
  fsWatcher.on("all", () => sendBuildChanges(ctx));
22312
22349
  return fsWatcher;
22313
22350
  };
22314
- const globalCssWatcher = (ctx) => {
22315
- const fsWatcher = chokidar.watch(ctx.client.globalCss, chokidarWatchOptions);
22351
+ const globalCustomCanvasWatcher = (ctx) => {
22352
+ const fsWatcher = chokidar.watch(ctx.client.customCanvasCss, chokidarWatchOptions);
22316
22353
  fsWatcher.on("all", async () => {
22317
22354
  sendMessage("globalCssUpdateSuccess");
22318
22355
  });
@@ -22459,7 +22496,7 @@ const embeddableConfigSchema = z
22459
22496
  modelsSrc: z.string().optional(),
22460
22497
  presetsSrc: z.string().optional(),
22461
22498
  componentsSrc: z.string().optional(),
22462
- globalCss: z.string().optional(),
22499
+ customCanvasCss: z.string().optional(),
22463
22500
  customizationFile: z.string().optional(),
22464
22501
  lifecycleHooksFile: z.string().optional(),
22465
22502
  componentLibraries: z
@@ -22488,7 +22525,7 @@ var defineConfig = (config) => {
22488
22525
  if (errors.length > 0) {
22489
22526
  throw new Error(`Invalid Embeddable Configuration: ${errors.join("\n")}}`);
22490
22527
  }
22491
- let { plugins, region = "legacy-US", pushModels = true, pushComponents = true, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, componentLibraries = [], customizationFile = "embeddable.theme.ts", lifecycleHooksFile = "lifecycle.config.ts", } = config;
22528
+ let { plugins, region = "legacy-US", pushModels = true, pushComponents = true, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", customCanvasCss = "src/custom-canvas.css", viteConfig = {}, rollupOptions = {}, componentLibraries = [], customizationFile = "embeddable.theme.ts", lifecycleHooksFile = "lifecycle.config.ts", } = config;
22492
22529
  const regionConfig = REGION_CONFIGS[region];
22493
22530
  const __dirname = import.meta.dirname;
22494
22531
  const coreRoot = path$1.resolve(__dirname, "..");
@@ -22524,7 +22561,7 @@ var defineConfig = (config) => {
22524
22561
  presetsSrc: presetsSrc ? path$1.resolve(clientRoot, presetsSrc) : undefined,
22525
22562
  buildDir: path$1.resolve(clientRoot, ".embeddable-build"),
22526
22563
  tmpDir: path$1.resolve(clientRoot, ".embeddable-tmp"),
22527
- globalCss: path$1.resolve(clientRoot, globalCss),
22564
+ customCanvasCss: path$1.resolve(clientRoot, customCanvasCss),
22528
22565
  componentDir: path$1.resolve(clientRoot, ".embeddable-build", "component"),
22529
22566
  stencilBuild: path$1.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
22530
22567
  archiveFile: path$1.resolve(clientRoot, "embeddable-build.zip"),