@embeddable.com/sdk-core 3.7.0-next.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.
@@ -16,6 +16,7 @@ export type EmbeddableConfig = {
16
16
  previewBaseUrl?: string;
17
17
  componentsSrc?: string;
18
18
  modelsSrc?: string;
19
+ selfServeCustomizationSrc?: string;
19
20
  viteConfig?: {
20
21
  resolve?: {
21
22
  alias?: Record<string, string>;
@@ -23,7 +24,7 @@ export type EmbeddableConfig = {
23
24
  };
24
25
  rollupOptions?: RollupOptions;
25
26
  };
26
- declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, viteConfig, rollupOptions, }: EmbeddableConfig) => {
27
+ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, selfServeCustomizationSrc, viteConfig, rollupOptions, }: EmbeddableConfig) => {
27
28
  core: {
28
29
  rootDir: string;
29
30
  templatesDir: string;
@@ -35,6 +36,7 @@ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authCl
35
36
  modelsSrc: string | undefined;
36
37
  buildDir: string;
37
38
  tmpDir: string;
39
+ selfServeCustomizationDir: string;
38
40
  componentDir: string;
39
41
  stencilBuild: string;
40
42
  archiveFile: string;
package/lib/index.esm.js CHANGED
@@ -20541,6 +20541,9 @@ const oraP$1 = import('ora');
20541
20541
  const inquirerSelect = import('@inquirer/select');
20542
20542
  // grab .cube.yml|js and .sc.yml|js files
20543
20543
  const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
20544
+ // grab all files in self-serve-customization folder
20545
+ const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
20546
+ const customSelfServeFolder = "self-serve-customization/";
20544
20547
  let ora$1;
20545
20548
  var push = async () => {
20546
20549
  var _a, _b;
@@ -20651,10 +20654,11 @@ async function verify(ctx) {
20651
20654
  async function buildArchive(config) {
20652
20655
  const spinnerArchive = ora$1("Building...").start();
20653
20656
  const filesList = await findFiles(config.client.modelsSrc || config.client.srcDir, YAML_OR_JS_FILES);
20654
- await archive(config, filesList);
20657
+ const selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
20658
+ await archive(config, filesList, selfServeFiles);
20655
20659
  return spinnerArchive.succeed("Bundling completed");
20656
20660
  }
20657
- async function archive(ctx, yamlFiles, includeBuild = true) {
20661
+ async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true) {
20658
20662
  const output = fs$2.createWriteStream(ctx.client.archiveFile);
20659
20663
  const _archiver = archiver.create("zip", {
20660
20664
  zlib: { level: 9 },
@@ -20669,6 +20673,14 @@ async function archive(ctx, yamlFiles, includeBuild = true) {
20669
20673
  name: fileName,
20670
20674
  });
20671
20675
  }
20676
+ if (selfServeFiles.length > 0) {
20677
+ for (const fileData of selfServeFiles) {
20678
+ const fileName = fileData[1].split("/").pop();
20679
+ _archiver.file(fileData[1], {
20680
+ name: `${customSelfServeFolder}${fileName}`,
20681
+ });
20682
+ }
20683
+ }
20672
20684
  await _archiver.finalize();
20673
20685
  return new Promise((resolve, _reject) => {
20674
20686
  output.on("close", resolve);
@@ -20736,6 +20748,7 @@ let ora;
20736
20748
  let previewWorkspace;
20737
20749
  const SERVER_PORT = 8926;
20738
20750
  const BUILD_DEV_DIR = ".embeddable-dev-build";
20751
+ const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
20739
20752
  const buildWebComponent = async (config) => {
20740
20753
  await generate(config, "sdk-react");
20741
20754
  };
@@ -20782,6 +20795,7 @@ var dev = async () => {
20782
20795
  const finalhandler = require("finalhandler");
20783
20796
  const serveStatic = require("serve-static");
20784
20797
  const serve = serveStatic(config.client.buildDir);
20798
+ const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
20785
20799
  const workspacePreparation = ora("Preparing workspace...").start();
20786
20800
  try {
20787
20801
  previewWorkspace = await getPreviewWorkspace(config);
@@ -20792,6 +20806,7 @@ var dev = async () => {
20792
20806
  }
20793
20807
  workspacePreparation.succeed("Workspace is ready");
20794
20808
  const server = http.createServer((request, res) => {
20809
+ var _a, _b;
20795
20810
  res.setHeader("Access-Control-Allow-Origin", "*");
20796
20811
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
20797
20812
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
@@ -20802,7 +20817,11 @@ var dev = async () => {
20802
20817
  return;
20803
20818
  }
20804
20819
  const done = finalhandler(request, res);
20805
- serve(request, res, done);
20820
+ const selectedServe = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith(SELF_SERVE_CUSTOMIZATION_REQUEST_URL))
20821
+ ? serveSelfeServe
20822
+ : serve;
20823
+ request.url = (_b = request.url) === null || _b === void 0 ? void 0 : _b.replace(SELF_SERVE_CUSTOMIZATION_REQUEST_URL, "");
20824
+ selectedServe(request, res, done);
20806
20825
  });
20807
20826
  wss = new WebSocketServer({ server });
20808
20827
  server.listen(SERVER_PORT, async () => {
@@ -20832,7 +20851,9 @@ var dev = async () => {
20832
20851
  watchers.push(watcher);
20833
20852
  }
20834
20853
  const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
20854
+ const customSelfServeWatch = customSelfServeWatcher(config);
20835
20855
  watchers.push(dataModelAndSecurityContextWatch);
20856
+ watchers.push(customSelfServeWatch);
20836
20857
  });
20837
20858
  };
20838
20859
  const configureWatcher = async (watcher, ctx) => {
@@ -20890,6 +20911,18 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
20890
20911
  });
20891
20912
  return fsWatcher;
20892
20913
  };
20914
+ const customSelfServeWatcher = (ctx) => {
20915
+ const fsWatcher = chokidar.watch([
20916
+ path$2.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
20917
+ path$2.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
20918
+ ], {
20919
+ ignoreInitial: true,
20920
+ });
20921
+ fsWatcher.on("all", async () => {
20922
+ sendMessage("customSelfServeUpdateSuccess");
20923
+ });
20924
+ return fsWatcher;
20925
+ };
20893
20926
  const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
20894
20927
  sendMessage("dataModelsAndOrSecurityContextUpdateStart");
20895
20928
  const isValid = await validate(ctx, false);
@@ -20902,7 +20935,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
20902
20935
  "embeddable-manifest",
20903
20936
  path$2.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
20904
20937
  ]);
20905
- await archive(ctx, filesList, false);
20938
+ await archive(ctx, filesList, [], false);
20906
20939
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
20907
20940
  sending.succeed(`Data models and/or security context synchronized`);
20908
20941
  sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
@@ -20953,7 +20986,7 @@ const getPreviewWorkspace = async (ctx) => {
20953
20986
  }
20954
20987
  };
20955
20988
 
20956
- var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", viteConfig = {}, rollupOptions = {}, }) => {
20989
+ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", selfServeCustomizationSrc = "src/self-serve-customization", viteConfig = {}, rollupOptions = {}, }) => {
20957
20990
  const coreRoot = path$1.resolve(__dirname, "..");
20958
20991
  const clientRoot = process.cwd();
20959
20992
  if (!path$1.isAbsolute(componentsSrc)) {
@@ -20980,6 +21013,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
20980
21013
  modelsSrc: modelsSrc ? path$1.resolve(clientRoot, modelsSrc) : undefined,
20981
21014
  buildDir: path$1.resolve(clientRoot, ".embeddable-build"),
20982
21015
  tmpDir: path$1.resolve(clientRoot, ".embeddable-tmp"),
21016
+ selfServeCustomizationDir: path$1.resolve(clientRoot, selfServeCustomizationSrc),
20983
21017
  componentDir: path$1.resolve(clientRoot, ".embeddable-build", "component"),
20984
21018
  stencilBuild: path$1.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
20985
21019
  archiveFile: path$1.resolve(clientRoot, "embeddable-build.zip"),
@@ -21005,7 +21039,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21005
21039
  };
21006
21040
 
21007
21041
  var name = "@embeddable.com/sdk-core";
21008
- var version = "3.6.0";
21042
+ var version = "3.7.1";
21009
21043
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21010
21044
  var keywords = [
21011
21045
  "embeddable",
@@ -21023,7 +21057,8 @@ var repository = {
21023
21057
  var scripts = {
21024
21058
  build: "rollup -c",
21025
21059
  test: "vitest run",
21026
- "test:watch": "vitest"
21060
+ "test:watch": "vitest",
21061
+ "license-report": "license-report --output=csv --csvHeaders --fields name --fields link --fields licenseType --fields installedVersion --fields author > license-report-sdk-core-sdk.csv"
21027
21062
  };
21028
21063
  var author = "Embeddable.com <engineering@embeddable.com>";
21029
21064
  var files = [