@embeddable.com/sdk-core 3.9.0 → 3.9.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.js CHANGED
@@ -51,6 +51,7 @@ var fs__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(fs$1);
51
51
  var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
52
52
  var YAML__namespace = /*#__PURE__*/_interopNamespaceDefault(YAML);
53
53
  var url__namespace = /*#__PURE__*/_interopNamespaceDefault(url);
54
+ var require$$2__namespace = /*#__PURE__*/_interopNamespaceDefault(require$$2$1);
54
55
  var path__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(path$1);
55
56
  var archiver__namespace = /*#__PURE__*/_interopNamespaceDefault(archiver);
56
57
  var http__namespace = /*#__PURE__*/_interopNamespaceDefault(http);
@@ -21382,9 +21383,6 @@ async function selectWorkspace(ora, ctx, token) {
21382
21383
  const oraP$1 = import('ora');
21383
21384
  // grab .cube.yml|js and .sc.yml|js files
21384
21385
  const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
21385
- // grab all files in self-serve-customization folder
21386
- const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
21387
- const customSelfServeFolder = "self-serve-customization/";
21388
21386
  let ora$1;
21389
21387
  var push = async () => {
21390
21388
  var _a, _b;
@@ -21466,24 +21464,20 @@ async function verify(ctx) {
21466
21464
  async function buildArchive(config) {
21467
21465
  const spinnerArchive = ora$1("Building...").start();
21468
21466
  const filesList = await findFiles(config.client.modelsSrc || config.client.srcDir, YAML_OR_JS_FILES);
21469
- let selfServeFiles = [];
21470
- // check existance of self-serve-customization folder
21471
- try {
21472
- await fs__namespace.access(config.client.selfServeCustomizationDir);
21473
- selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
21474
- }
21475
- catch (e) { }
21476
- await archive(config, filesList, selfServeFiles);
21467
+ await archive(config, filesList);
21477
21468
  return spinnerArchive.succeed("Bundling completed");
21478
21469
  }
21479
- async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true) {
21470
+ async function archive(ctx, yamlFiles, isDev = false) {
21480
21471
  const output = fs__namespace$1.createWriteStream(ctx.client.archiveFile);
21481
21472
  const _archiver = archiver__namespace.create("zip", {
21482
21473
  zlib: { level: 9 },
21483
21474
  });
21484
21475
  _archiver.pipe(output);
21485
- if (includeBuild) {
21476
+ if (!isDev) {
21486
21477
  _archiver.directory(ctx.client.buildDir, false);
21478
+ _archiver.file(ctx.client.globalCss, {
21479
+ name: "global.css",
21480
+ });
21487
21481
  }
21488
21482
  for (const fileData of yamlFiles) {
21489
21483
  const fileName = fileData[1].split("/").pop();
@@ -21491,14 +21485,6 @@ async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true)
21491
21485
  name: fileName,
21492
21486
  });
21493
21487
  }
21494
- if (selfServeFiles.length > 0) {
21495
- for (const fileData of selfServeFiles) {
21496
- const fileName = fileData[1].split("/").pop();
21497
- _archiver.file(fileData[1], {
21498
- name: `${customSelfServeFolder}${fileName}`,
21499
- });
21500
- }
21501
- }
21502
21488
  await _archiver.finalize();
21503
21489
  return new Promise((resolve, _reject) => {
21504
21490
  output.on("close", resolve);
@@ -21546,7 +21532,7 @@ let ora;
21546
21532
  let previewWorkspace;
21547
21533
  const SERVER_PORT = 8926;
21548
21534
  const BUILD_DEV_DIR = ".embeddable-dev-build";
21549
- const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
21535
+ const GLOBAL_CSS = "/global.css";
21550
21536
  const buildWebComponent = async (config) => {
21551
21537
  await generate(config, "sdk-react");
21552
21538
  };
@@ -21600,7 +21586,6 @@ var dev = async () => {
21600
21586
  const finalhandler = require("finalhandler");
21601
21587
  const serveStatic = require("serve-static");
21602
21588
  const serve = serveStatic(config.client.buildDir);
21603
- const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
21604
21589
  const workspacePreparation = ora("Preparing workspace...").start();
21605
21590
  try {
21606
21591
  previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
@@ -21611,7 +21596,7 @@ var dev = async () => {
21611
21596
  }
21612
21597
  workspacePreparation.succeed("Workspace is ready");
21613
21598
  const server = http__namespace.createServer((request, res) => {
21614
- var _a, _b;
21599
+ var _a;
21615
21600
  res.setHeader("Access-Control-Allow-Origin", "*");
21616
21601
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
21617
21602
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
@@ -21622,11 +21607,15 @@ var dev = async () => {
21622
21607
  return;
21623
21608
  }
21624
21609
  const done = finalhandler(request, res);
21625
- const selectedServe = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith(SELF_SERVE_CUSTOMIZATION_REQUEST_URL))
21626
- ? serveSelfeServe
21627
- : serve;
21628
- request.url = (_b = request.url) === null || _b === void 0 ? void 0 : _b.replace(SELF_SERVE_CUSTOMIZATION_REQUEST_URL, "");
21629
- selectedServe(request, res, done);
21610
+ try {
21611
+ if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.endsWith(GLOBAL_CSS)) {
21612
+ res.writeHead(200, { "Content-Type": "text/css" });
21613
+ res.end(require$$2__namespace.readFileSync(config.client.globalCss));
21614
+ return;
21615
+ }
21616
+ }
21617
+ catch (_b) { }
21618
+ serve(request, res, done);
21630
21619
  });
21631
21620
  wss = new ws.WebSocketServer({ server });
21632
21621
  server.listen(SERVER_PORT, async () => {
@@ -21656,9 +21645,9 @@ var dev = async () => {
21656
21645
  watchers.push(watcher);
21657
21646
  }
21658
21647
  const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
21659
- const customSelfServeWatch = customSelfServeWatcher(config);
21648
+ const customGlobalCssWatch = globalCssWatcher(config);
21660
21649
  watchers.push(dataModelAndSecurityContextWatch);
21661
- watchers.push(customSelfServeWatch);
21650
+ watchers.push(customGlobalCssWatch);
21662
21651
  });
21663
21652
  };
21664
21653
  const configureWatcher = async (watcher, ctx) => {
@@ -21714,13 +21703,10 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
21714
21703
  });
21715
21704
  return fsWatcher;
21716
21705
  };
21717
- const customSelfServeWatcher = (ctx) => {
21718
- const fsWatcher = chokidar__namespace.watch([
21719
- path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
21720
- path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
21721
- ], chokidarWatchOptions);
21706
+ const globalCssWatcher = (ctx) => {
21707
+ const fsWatcher = chokidar__namespace.watch(ctx.client.globalCss, chokidarWatchOptions);
21722
21708
  fsWatcher.on("all", async () => {
21723
- sendMessage("customSelfServeUpdateSuccess");
21709
+ sendMessage("globalCssUpdateSuccess");
21724
21710
  });
21725
21711
  return fsWatcher;
21726
21712
  };
@@ -21736,7 +21722,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
21736
21722
  "embeddable-manifest",
21737
21723
  path__namespace$1.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
21738
21724
  ]);
21739
- await archive(ctx, filesList, [], false);
21725
+ await archive(ctx, filesList, true);
21740
21726
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
21741
21727
  sending.succeed(`Data models and/or security context synchronized`);
21742
21728
  sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
@@ -21793,7 +21779,7 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
21793
21779
  }
21794
21780
  };
21795
21781
 
21796
- var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", selfServeCustomizationSrc = "src/self-serve-customization", viteConfig = {}, rollupOptions = {}, }) => {
21782
+ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
21797
21783
  const coreRoot = path__namespace.resolve(__dirname, "..");
21798
21784
  const clientRoot = process.cwd();
21799
21785
  if (!path__namespace.isAbsolute(componentsSrc)) {
@@ -21820,7 +21806,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21820
21806
  modelsSrc: modelsSrc ? path__namespace.resolve(clientRoot, modelsSrc) : undefined,
21821
21807
  buildDir: path__namespace.resolve(clientRoot, ".embeddable-build"),
21822
21808
  tmpDir: path__namespace.resolve(clientRoot, ".embeddable-tmp"),
21823
- selfServeCustomizationDir: path__namespace.resolve(clientRoot, selfServeCustomizationSrc),
21809
+ globalCss: path__namespace.resolve(clientRoot, globalCss),
21824
21810
  componentDir: path__namespace.resolve(clientRoot, ".embeddable-build", "component"),
21825
21811
  stencilBuild: path__namespace.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
21826
21812
  archiveFile: path__namespace.resolve(clientRoot, "embeddable-build.zip"),
@@ -21846,7 +21832,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21846
21832
  };
21847
21833
 
21848
21834
  var name = "@embeddable.com/sdk-core";
21849
- var version = "3.9.0";
21835
+ var version = "3.9.2";
21850
21836
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21851
21837
  var keywords = [
21852
21838
  "embeddable",