@embeddable.com/sdk-core 3.7.0 → 3.7.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.
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,11 @@ 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
+ const selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
20685
+ await archive(config, filesList, selfServeFiles);
20682
20686
  return spinnerArchive.succeed("Bundling completed");
20683
20687
  }
20684
- async function archive(ctx, yamlFiles, includeBuild = true) {
20688
+ async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true) {
20685
20689
  const output = fs__namespace$1.createWriteStream(ctx.client.archiveFile);
20686
20690
  const _archiver = archiver__namespace.create("zip", {
20687
20691
  zlib: { level: 9 },
@@ -20696,6 +20700,14 @@ async function archive(ctx, yamlFiles, includeBuild = true) {
20696
20700
  name: fileName,
20697
20701
  });
20698
20702
  }
20703
+ if (selfServeFiles.length > 0) {
20704
+ for (const fileData of selfServeFiles) {
20705
+ const fileName = fileData[1].split("/").pop();
20706
+ _archiver.file(fileData[1], {
20707
+ name: `${customSelfServeFolder}${fileName}`,
20708
+ });
20709
+ }
20710
+ }
20699
20711
  await _archiver.finalize();
20700
20712
  return new Promise((resolve, _reject) => {
20701
20713
  output.on("close", resolve);
@@ -20763,6 +20775,7 @@ let ora;
20763
20775
  let previewWorkspace;
20764
20776
  const SERVER_PORT = 8926;
20765
20777
  const BUILD_DEV_DIR = ".embeddable-dev-build";
20778
+ const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
20766
20779
  const buildWebComponent = async (config) => {
20767
20780
  await generate(config, "sdk-react");
20768
20781
  };
@@ -20809,6 +20822,7 @@ var dev = async () => {
20809
20822
  const finalhandler = require("finalhandler");
20810
20823
  const serveStatic = require("serve-static");
20811
20824
  const serve = serveStatic(config.client.buildDir);
20825
+ const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
20812
20826
  const workspacePreparation = ora("Preparing workspace...").start();
20813
20827
  try {
20814
20828
  previewWorkspace = await getPreviewWorkspace(config);
@@ -20819,6 +20833,7 @@ var dev = async () => {
20819
20833
  }
20820
20834
  workspacePreparation.succeed("Workspace is ready");
20821
20835
  const server = http.createServer((request, res) => {
20836
+ var _a, _b;
20822
20837
  res.setHeader("Access-Control-Allow-Origin", "*");
20823
20838
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
20824
20839
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
@@ -20829,7 +20844,11 @@ var dev = async () => {
20829
20844
  return;
20830
20845
  }
20831
20846
  const done = finalhandler(request, res);
20832
- serve(request, res, done);
20847
+ const selectedServe = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith(SELF_SERVE_CUSTOMIZATION_REQUEST_URL))
20848
+ ? serveSelfeServe
20849
+ : serve;
20850
+ request.url = (_b = request.url) === null || _b === void 0 ? void 0 : _b.replace(SELF_SERVE_CUSTOMIZATION_REQUEST_URL, "");
20851
+ selectedServe(request, res, done);
20833
20852
  });
20834
20853
  wss = new ws.WebSocketServer({ server });
20835
20854
  server.listen(SERVER_PORT, async () => {
@@ -20859,7 +20878,9 @@ var dev = async () => {
20859
20878
  watchers.push(watcher);
20860
20879
  }
20861
20880
  const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
20881
+ const customSelfServeWatch = customSelfServeWatcher(config);
20862
20882
  watchers.push(dataModelAndSecurityContextWatch);
20883
+ watchers.push(customSelfServeWatch);
20863
20884
  });
20864
20885
  };
20865
20886
  const configureWatcher = async (watcher, ctx) => {
@@ -20917,6 +20938,18 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
20917
20938
  });
20918
20939
  return fsWatcher;
20919
20940
  };
20941
+ const customSelfServeWatcher = (ctx) => {
20942
+ const fsWatcher = chokidar__namespace.watch([
20943
+ path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
20944
+ path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
20945
+ ], {
20946
+ ignoreInitial: true,
20947
+ });
20948
+ fsWatcher.on("all", async () => {
20949
+ sendMessage("customSelfServeUpdateSuccess");
20950
+ });
20951
+ return fsWatcher;
20952
+ };
20920
20953
  const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
20921
20954
  sendMessage("dataModelsAndOrSecurityContextUpdateStart");
20922
20955
  const isValid = await validate(ctx, false);
@@ -20929,7 +20962,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
20929
20962
  "embeddable-manifest",
20930
20963
  path__namespace$1.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
20931
20964
  ]);
20932
- await archive(ctx, filesList, false);
20965
+ await archive(ctx, filesList, [], false);
20933
20966
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
20934
20967
  sending.succeed(`Data models and/or security context synchronized`);
20935
20968
  sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
@@ -20980,7 +21013,7 @@ const getPreviewWorkspace = async (ctx) => {
20980
21013
  }
20981
21014
  };
20982
21015
 
20983
- var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", viteConfig = {}, rollupOptions = {}, }) => {
21016
+ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", selfServeCustomizationSrc = "src/self-serve-customization", viteConfig = {}, rollupOptions = {}, }) => {
20984
21017
  const coreRoot = path__namespace.resolve(__dirname, "..");
20985
21018
  const clientRoot = process.cwd();
20986
21019
  if (!path__namespace.isAbsolute(componentsSrc)) {
@@ -21007,6 +21040,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21007
21040
  modelsSrc: modelsSrc ? path__namespace.resolve(clientRoot, modelsSrc) : undefined,
21008
21041
  buildDir: path__namespace.resolve(clientRoot, ".embeddable-build"),
21009
21042
  tmpDir: path__namespace.resolve(clientRoot, ".embeddable-tmp"),
21043
+ selfServeCustomizationDir: path__namespace.resolve(clientRoot, selfServeCustomizationSrc),
21010
21044
  componentDir: path__namespace.resolve(clientRoot, ".embeddable-build", "component"),
21011
21045
  stencilBuild: path__namespace.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
21012
21046
  archiveFile: path__namespace.resolve(clientRoot, "embeddable-build.zip"),
@@ -21032,7 +21066,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21032
21066
  };
21033
21067
 
21034
21068
  var name = "@embeddable.com/sdk-core";
21035
- var version = "3.7.0";
21069
+ var version = "3.7.1";
21036
21070
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21037
21071
  var keywords = [
21038
21072
  "embeddable",