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