@embeddable.com/sdk-core 3.7.0 → 3.7.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
@@ -20568,6 +20568,9 @@ const oraP$1 = import('ora');
20568
20568
  const inquirerSelect = import('@inquirer/select');
20569
20569
  // grab .cube.yml|js and .sc.yml|js files
20570
20570
  const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
20571
+ // grab all files in self-serve-customization folder
20572
+ const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
20573
+ const customSelfServeFolder = "self-serve-customization/";
20571
20574
  let ora$1;
20572
20575
  var push = async () => {
20573
20576
  var _a, _b;
@@ -20678,10 +20681,17 @@ async function verify(ctx) {
20678
20681
  async function buildArchive(config) {
20679
20682
  const spinnerArchive = ora$1("Building...").start();
20680
20683
  const filesList = await findFiles(config.client.modelsSrc || config.client.srcDir, YAML_OR_JS_FILES);
20681
- await archive(config, filesList);
20684
+ let selfServeFiles = [];
20685
+ // check existance of self-serve-customization folder
20686
+ try {
20687
+ await fs__namespace.access(config.client.selfServeCustomizationDir);
20688
+ selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
20689
+ }
20690
+ catch (e) { }
20691
+ await archive(config, filesList, selfServeFiles);
20682
20692
  return spinnerArchive.succeed("Bundling completed");
20683
20693
  }
20684
- async function archive(ctx, yamlFiles, includeBuild = true) {
20694
+ async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true) {
20685
20695
  const output = fs__namespace$1.createWriteStream(ctx.client.archiveFile);
20686
20696
  const _archiver = archiver__namespace.create("zip", {
20687
20697
  zlib: { level: 9 },
@@ -20696,6 +20706,14 @@ async function archive(ctx, yamlFiles, includeBuild = true) {
20696
20706
  name: fileName,
20697
20707
  });
20698
20708
  }
20709
+ if (selfServeFiles.length > 0) {
20710
+ for (const fileData of selfServeFiles) {
20711
+ const fileName = fileData[1].split("/").pop();
20712
+ _archiver.file(fileData[1], {
20713
+ name: `${customSelfServeFolder}${fileName}`,
20714
+ });
20715
+ }
20716
+ }
20699
20717
  await _archiver.finalize();
20700
20718
  return new Promise((resolve, _reject) => {
20701
20719
  output.on("close", resolve);
@@ -20763,6 +20781,7 @@ let ora;
20763
20781
  let previewWorkspace;
20764
20782
  const SERVER_PORT = 8926;
20765
20783
  const BUILD_DEV_DIR = ".embeddable-dev-build";
20784
+ const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
20766
20785
  const buildWebComponent = async (config) => {
20767
20786
  await generate(config, "sdk-react");
20768
20787
  };
@@ -20809,6 +20828,7 @@ var dev = async () => {
20809
20828
  const finalhandler = require("finalhandler");
20810
20829
  const serveStatic = require("serve-static");
20811
20830
  const serve = serveStatic(config.client.buildDir);
20831
+ const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
20812
20832
  const workspacePreparation = ora("Preparing workspace...").start();
20813
20833
  try {
20814
20834
  previewWorkspace = await getPreviewWorkspace(config);
@@ -20819,6 +20839,7 @@ var dev = async () => {
20819
20839
  }
20820
20840
  workspacePreparation.succeed("Workspace is ready");
20821
20841
  const server = http.createServer((request, res) => {
20842
+ var _a, _b;
20822
20843
  res.setHeader("Access-Control-Allow-Origin", "*");
20823
20844
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
20824
20845
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
@@ -20829,7 +20850,11 @@ var dev = async () => {
20829
20850
  return;
20830
20851
  }
20831
20852
  const done = finalhandler(request, res);
20832
- serve(request, res, done);
20853
+ const selectedServe = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith(SELF_SERVE_CUSTOMIZATION_REQUEST_URL))
20854
+ ? serveSelfeServe
20855
+ : serve;
20856
+ request.url = (_b = request.url) === null || _b === void 0 ? void 0 : _b.replace(SELF_SERVE_CUSTOMIZATION_REQUEST_URL, "");
20857
+ selectedServe(request, res, done);
20833
20858
  });
20834
20859
  wss = new ws.WebSocketServer({ server });
20835
20860
  server.listen(SERVER_PORT, async () => {
@@ -20859,7 +20884,9 @@ var dev = async () => {
20859
20884
  watchers.push(watcher);
20860
20885
  }
20861
20886
  const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
20887
+ const customSelfServeWatch = customSelfServeWatcher(config);
20862
20888
  watchers.push(dataModelAndSecurityContextWatch);
20889
+ watchers.push(customSelfServeWatch);
20863
20890
  });
20864
20891
  };
20865
20892
  const configureWatcher = async (watcher, ctx) => {
@@ -20917,6 +20944,18 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
20917
20944
  });
20918
20945
  return fsWatcher;
20919
20946
  };
20947
+ const customSelfServeWatcher = (ctx) => {
20948
+ const fsWatcher = chokidar__namespace.watch([
20949
+ path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
20950
+ path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
20951
+ ], {
20952
+ ignoreInitial: true,
20953
+ });
20954
+ fsWatcher.on("all", async () => {
20955
+ sendMessage("customSelfServeUpdateSuccess");
20956
+ });
20957
+ return fsWatcher;
20958
+ };
20920
20959
  const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
20921
20960
  sendMessage("dataModelsAndOrSecurityContextUpdateStart");
20922
20961
  const isValid = await validate(ctx, false);
@@ -20929,7 +20968,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
20929
20968
  "embeddable-manifest",
20930
20969
  path__namespace$1.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
20931
20970
  ]);
20932
- await archive(ctx, filesList, false);
20971
+ await archive(ctx, filesList, [], false);
20933
20972
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
20934
20973
  sending.succeed(`Data models and/or security context synchronized`);
20935
20974
  sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
@@ -20980,7 +21019,7 @@ const getPreviewWorkspace = async (ctx) => {
20980
21019
  }
20981
21020
  };
20982
21021
 
20983
- var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", viteConfig = {}, rollupOptions = {}, }) => {
21022
+ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", selfServeCustomizationSrc = "src/self-serve-customization", viteConfig = {}, rollupOptions = {}, }) => {
20984
21023
  const coreRoot = path__namespace.resolve(__dirname, "..");
20985
21024
  const clientRoot = process.cwd();
20986
21025
  if (!path__namespace.isAbsolute(componentsSrc)) {
@@ -21007,6 +21046,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21007
21046
  modelsSrc: modelsSrc ? path__namespace.resolve(clientRoot, modelsSrc) : undefined,
21008
21047
  buildDir: path__namespace.resolve(clientRoot, ".embeddable-build"),
21009
21048
  tmpDir: path__namespace.resolve(clientRoot, ".embeddable-tmp"),
21049
+ selfServeCustomizationDir: path__namespace.resolve(clientRoot, selfServeCustomizationSrc),
21010
21050
  componentDir: path__namespace.resolve(clientRoot, ".embeddable-build", "component"),
21011
21051
  stencilBuild: path__namespace.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
21012
21052
  archiveFile: path__namespace.resolve(clientRoot, "embeddable-build.zip"),
@@ -21032,7 +21072,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21032
21072
  };
21033
21073
 
21034
21074
  var name = "@embeddable.com/sdk-core";
21035
- var version = "3.7.0";
21075
+ var version = "3.7.2";
21036
21076
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21037
21077
  var keywords = [
21038
21078
  "embeddable",