@embeddable.com/sdk-core 3.9.0 → 3.9.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.
@@ -16,7 +16,7 @@ export type EmbeddableConfig = {
16
16
  previewBaseUrl?: string;
17
17
  componentsSrc?: string;
18
18
  modelsSrc?: string;
19
- selfServeCustomizationSrc?: string;
19
+ globalCss?: string;
20
20
  viteConfig?: {
21
21
  resolve?: {
22
22
  alias?: Record<string, string>;
@@ -24,7 +24,7 @@ export type EmbeddableConfig = {
24
24
  };
25
25
  rollupOptions?: RollupOptions;
26
26
  };
27
- declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, selfServeCustomizationSrc, viteConfig, rollupOptions, }: EmbeddableConfig) => {
27
+ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, globalCss, viteConfig, rollupOptions, }: EmbeddableConfig) => {
28
28
  core: {
29
29
  rootDir: string;
30
30
  templatesDir: string;
@@ -36,7 +36,7 @@ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authCl
36
36
  modelsSrc: string | undefined;
37
37
  buildDir: string;
38
38
  tmpDir: string;
39
- selfServeCustomizationDir: string;
39
+ globalCss: string;
40
40
  componentDir: string;
41
41
  stencilBuild: string;
42
42
  archiveFile: string;
package/lib/index.esm.js CHANGED
@@ -17,7 +17,8 @@ import require$$1 from 'os';
17
17
  import require$$3 from 'http';
18
18
  import require$$4 from 'https';
19
19
  import require$$0$1 from 'url';
20
- import require$$2$1, { createReadStream } from 'fs';
20
+ import * as require$$2$1 from 'fs';
21
+ import require$$2__default, { createReadStream } from 'fs';
21
22
  import * as path$1 from 'path';
22
23
  import path__default$1, { basename } from 'path';
23
24
  import axios from 'axios';
@@ -17855,7 +17856,7 @@ function requireStackTrace () {
17855
17856
  hasRequiredStackTrace = 1;
17856
17857
  var SourceMapConsumer = requireSourceMap().SourceMapConsumer;
17857
17858
  var path = path__default$1;
17858
- var fs = require$$2$1;
17859
+ var fs = require$$2__default;
17859
17860
 
17860
17861
  /**
17861
17862
  * Uses Node source-map to map transpiled JS stack locations to original
@@ -18063,7 +18064,7 @@ function requireParser () {
18063
18064
 
18064
18065
  var logger = requireLogger();
18065
18066
  var async = require$$0;
18066
- var fs = require$$2$1;
18067
+ var fs = require$$2__default;
18067
18068
  var lru = requireLruCache();
18068
18069
  var util = require$$4$1;
18069
18070
  var stackTrace = requireStackTrace();
@@ -21354,9 +21355,6 @@ async function selectWorkspace(ora, ctx, token) {
21354
21355
  const oraP$1 = import('ora');
21355
21356
  // grab .cube.yml|js and .sc.yml|js files
21356
21357
  const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
21357
- // grab all files in self-serve-customization folder
21358
- const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
21359
- const customSelfServeFolder = "self-serve-customization/";
21360
21358
  let ora$1;
21361
21359
  var push = async () => {
21362
21360
  var _a, _b;
@@ -21438,24 +21436,20 @@ async function verify(ctx) {
21438
21436
  async function buildArchive(config) {
21439
21437
  const spinnerArchive = ora$1("Building...").start();
21440
21438
  const filesList = await findFiles(config.client.modelsSrc || config.client.srcDir, YAML_OR_JS_FILES);
21441
- let selfServeFiles = [];
21442
- // check existance of self-serve-customization folder
21443
- try {
21444
- await fs.access(config.client.selfServeCustomizationDir);
21445
- selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
21446
- }
21447
- catch (e) { }
21448
- await archive(config, filesList, selfServeFiles);
21439
+ await archive(config, filesList);
21449
21440
  return spinnerArchive.succeed("Bundling completed");
21450
21441
  }
21451
- async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true) {
21442
+ async function archive(ctx, yamlFiles, isDev = false) {
21452
21443
  const output = fs$1.createWriteStream(ctx.client.archiveFile);
21453
21444
  const _archiver = archiver.create("zip", {
21454
21445
  zlib: { level: 9 },
21455
21446
  });
21456
21447
  _archiver.pipe(output);
21457
- if (includeBuild) {
21448
+ if (!isDev) {
21458
21449
  _archiver.directory(ctx.client.buildDir, false);
21450
+ _archiver.file(ctx.client.globalCss, {
21451
+ name: "global.css",
21452
+ });
21459
21453
  }
21460
21454
  for (const fileData of yamlFiles) {
21461
21455
  const fileName = fileData[1].split("/").pop();
@@ -21463,14 +21457,6 @@ async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true)
21463
21457
  name: fileName,
21464
21458
  });
21465
21459
  }
21466
- if (selfServeFiles.length > 0) {
21467
- for (const fileData of selfServeFiles) {
21468
- const fileName = fileData[1].split("/").pop();
21469
- _archiver.file(fileData[1], {
21470
- name: `${customSelfServeFolder}${fileName}`,
21471
- });
21472
- }
21473
- }
21474
21460
  await _archiver.finalize();
21475
21461
  return new Promise((resolve, _reject) => {
21476
21462
  output.on("close", resolve);
@@ -21518,7 +21504,7 @@ let ora;
21518
21504
  let previewWorkspace;
21519
21505
  const SERVER_PORT = 8926;
21520
21506
  const BUILD_DEV_DIR = ".embeddable-dev-build";
21521
- const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
21507
+ const GLOBAL_CSS = "/global.css";
21522
21508
  const buildWebComponent = async (config) => {
21523
21509
  await generate(config, "sdk-react");
21524
21510
  };
@@ -21572,7 +21558,6 @@ var dev = async () => {
21572
21558
  const finalhandler = require("finalhandler");
21573
21559
  const serveStatic = require("serve-static");
21574
21560
  const serve = serveStatic(config.client.buildDir);
21575
- const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
21576
21561
  const workspacePreparation = ora("Preparing workspace...").start();
21577
21562
  try {
21578
21563
  previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
@@ -21583,7 +21568,7 @@ var dev = async () => {
21583
21568
  }
21584
21569
  workspacePreparation.succeed("Workspace is ready");
21585
21570
  const server = http.createServer((request, res) => {
21586
- var _a, _b;
21571
+ var _a;
21587
21572
  res.setHeader("Access-Control-Allow-Origin", "*");
21588
21573
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
21589
21574
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
@@ -21594,11 +21579,12 @@ var dev = async () => {
21594
21579
  return;
21595
21580
  }
21596
21581
  const done = finalhandler(request, res);
21597
- const selectedServe = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith(SELF_SERVE_CUSTOMIZATION_REQUEST_URL))
21598
- ? serveSelfeServe
21599
- : serve;
21600
- request.url = (_b = request.url) === null || _b === void 0 ? void 0 : _b.replace(SELF_SERVE_CUSTOMIZATION_REQUEST_URL, "");
21601
- selectedServe(request, res, done);
21582
+ if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.endsWith(GLOBAL_CSS)) {
21583
+ res.writeHead(200, { "Content-Type": "text/css" });
21584
+ res.end(require$$2$1.readFileSync(config.client.globalCss));
21585
+ return;
21586
+ }
21587
+ serve(request, res, done);
21602
21588
  });
21603
21589
  wss = new WebSocketServer({ server });
21604
21590
  server.listen(SERVER_PORT, async () => {
@@ -21628,9 +21614,9 @@ var dev = async () => {
21628
21614
  watchers.push(watcher);
21629
21615
  }
21630
21616
  const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
21631
- const customSelfServeWatch = customSelfServeWatcher(config);
21617
+ const customGlobalCssWatch = globalCssWatcher(config);
21632
21618
  watchers.push(dataModelAndSecurityContextWatch);
21633
- watchers.push(customSelfServeWatch);
21619
+ watchers.push(customGlobalCssWatch);
21634
21620
  });
21635
21621
  };
21636
21622
  const configureWatcher = async (watcher, ctx) => {
@@ -21686,13 +21672,10 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
21686
21672
  });
21687
21673
  return fsWatcher;
21688
21674
  };
21689
- const customSelfServeWatcher = (ctx) => {
21690
- const fsWatcher = chokidar.watch([
21691
- path$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
21692
- path$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
21693
- ], chokidarWatchOptions);
21675
+ const globalCssWatcher = (ctx) => {
21676
+ const fsWatcher = chokidar.watch(ctx.client.globalCss, chokidarWatchOptions);
21694
21677
  fsWatcher.on("all", async () => {
21695
- sendMessage("customSelfServeUpdateSuccess");
21678
+ sendMessage("globalCssUpdateSuccess");
21696
21679
  });
21697
21680
  return fsWatcher;
21698
21681
  };
@@ -21708,7 +21691,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
21708
21691
  "embeddable-manifest",
21709
21692
  path$1.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
21710
21693
  ]);
21711
- await archive(ctx, filesList, [], false);
21694
+ await archive(ctx, filesList, true);
21712
21695
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
21713
21696
  sending.succeed(`Data models and/or security context synchronized`);
21714
21697
  sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
@@ -21765,7 +21748,7 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
21765
21748
  }
21766
21749
  };
21767
21750
 
21768
- var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", selfServeCustomizationSrc = "src/self-serve-customization", viteConfig = {}, rollupOptions = {}, }) => {
21751
+ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
21769
21752
  const coreRoot = path.resolve(__dirname, "..");
21770
21753
  const clientRoot = process.cwd();
21771
21754
  if (!path.isAbsolute(componentsSrc)) {
@@ -21792,7 +21775,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21792
21775
  modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
21793
21776
  buildDir: path.resolve(clientRoot, ".embeddable-build"),
21794
21777
  tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
21795
- selfServeCustomizationDir: path.resolve(clientRoot, selfServeCustomizationSrc),
21778
+ globalCss: path.resolve(clientRoot, globalCss),
21796
21779
  componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
21797
21780
  stencilBuild: path.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
21798
21781
  archiveFile: path.resolve(clientRoot, "embeddable-build.zip"),
@@ -21818,7 +21801,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21818
21801
  };
21819
21802
 
21820
21803
  var name = "@embeddable.com/sdk-core";
21821
- var version = "3.9.0";
21804
+ var version = "3.9.1";
21822
21805
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21823
21806
  var keywords = [
21824
21807
  "embeddable",