@embeddable.com/sdk-core 3.12.4 → 3.12.5

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
@@ -21497,7 +21497,7 @@ async function resolveFiles() {
21497
21497
  }
21498
21498
 
21499
21499
  async function getWorkspaces(ctx, token, workspaceSpinner) {
21500
- var _a, _b;
21500
+ var _a, _b, _c;
21501
21501
  try {
21502
21502
  const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
21503
21503
  headers: {
@@ -21507,7 +21507,11 @@ async function getWorkspaces(ctx, token, workspaceSpinner) {
21507
21507
  return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
21508
21508
  }
21509
21509
  catch (e) {
21510
- if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
21510
+ if ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch) {
21511
+ workspaceSpinner.stop();
21512
+ throw e;
21513
+ }
21514
+ if (((_c = e.response) === null || _c === void 0 ? void 0 : _c.status) === 401) {
21511
21515
  workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
21512
21516
  }
21513
21517
  else {
@@ -21636,7 +21640,9 @@ async function buildArchive(config) {
21636
21640
  const spinnerArchive = ora$1("Building...").start();
21637
21641
  const cubeFilesList = await findFiles(config.client.modelsSrc || config.client.srcDir, CUBE_FILES);
21638
21642
  const contextFilesList = await findFiles(config.client.presetsSrc || config.client.srcDir, PRESET_FILES);
21639
- await archive(config, [...cubeFilesList, ...contextFilesList]);
21643
+ // Map the files to include their full filenames
21644
+ const filesList = [...cubeFilesList, ...contextFilesList].map((entry) => [path__namespace$1.basename(entry[1]), entry[1]]);
21645
+ await archive(config, filesList);
21640
21646
  return spinnerArchive.succeed("Bundling completed");
21641
21647
  }
21642
21648
  async function archive(ctx, yamlFiles, isDev = false) {
@@ -21652,9 +21658,8 @@ async function archive(ctx, yamlFiles, isDev = false) {
21652
21658
  });
21653
21659
  }
21654
21660
  for (const fileData of yamlFiles) {
21655
- const fileName = fileData[1].split("/").pop();
21656
21661
  _archiver.file(fileData[1], {
21657
- name: fileName,
21662
+ name: fileData[0],
21658
21663
  });
21659
21664
  }
21660
21665
  await _archiver.finalize();
@@ -21731,7 +21736,7 @@ const chokidarWatchOptions = {
21731
21736
  },
21732
21737
  };
21733
21738
  var dev = async () => {
21734
- var _a, _b;
21739
+ var _a, _b, _c;
21735
21740
  await initLogger("dev");
21736
21741
  const breadcrumbs = [];
21737
21742
  try {
@@ -21764,14 +21769,22 @@ var dev = async () => {
21764
21769
  const finalhandler = require("finalhandler");
21765
21770
  const serveStatic = require("serve-static");
21766
21771
  const serve = serveStatic(config.client.buildDir);
21767
- const workspacePreparation = ora("Preparing workspace...").start();
21772
+ let workspacePreparation = ora("Preparing workspace...").start();
21768
21773
  breadcrumbs.push("get preview workspace");
21769
21774
  try {
21770
21775
  previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
21771
21776
  }
21772
21777
  catch (e) {
21773
- workspacePreparation.fail(((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errorMessage) || "Unknown error: " + e.message);
21774
- process.exit(1);
21778
+ if (((_a = e.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
21779
+ // login and retry
21780
+ await login();
21781
+ workspacePreparation = ora("Preparing workspace...").start();
21782
+ previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
21783
+ }
21784
+ else {
21785
+ workspacePreparation.fail(((_c = (_b = e.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.errorMessage) || "Unknown error: " + e.message);
21786
+ process.exit(1);
21787
+ }
21775
21788
  }
21776
21789
  workspacePreparation.succeed("Workspace is ready");
21777
21790
  const server = http__namespace.createServer((request, res) => {
@@ -21780,7 +21793,6 @@ var dev = async () => {
21780
21793
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
21781
21794
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
21782
21795
  if (request.method === "OPTIONS") {
21783
- // Respond to OPTIONS requests with just the CORS headers and a 200 status code
21784
21796
  res.writeHead(200);
21785
21797
  res.end();
21786
21798
  return;
@@ -21797,7 +21809,21 @@ var dev = async () => {
21797
21809
  serve(request, res, done);
21798
21810
  });
21799
21811
  wss = new ws.WebSocketServer({ server });
21812
+ wss.on("connection", (ws) => {
21813
+ console.log("🔌 New WebSocket connection established");
21814
+ ws.on("error", (error) => {
21815
+ console.error("WebSocket error:", error);
21816
+ });
21817
+ ws.on("close", () => {
21818
+ console.log("WebSocket connection closed");
21819
+ });
21820
+ });
21821
+ wss.on("error", (error) => {
21822
+ console.error("WebSocket server error:", error);
21823
+ });
21800
21824
  server.listen(SERVER_PORT, async () => {
21825
+ console.log(`\n�� Dev server running and ready to connect`);
21826
+ console.log("ℹ️ Your app will automatically connect to the dev server when you open the workspace");
21801
21827
  const watchers = [];
21802
21828
  if (sys === null || sys === void 0 ? void 0 : sys.onProcessInterrupt) {
21803
21829
  sys.onProcessInterrupt(async () => await onClose(server, sys, watchers, config));
@@ -21915,10 +21941,11 @@ const sendDataModelsAndContextsChanges = async (ctx) => {
21915
21941
  const sending = ora("Synchronising data models and/or security contexts...").start();
21916
21942
  const cubeFilesList = await findFiles(ctx.client.modelsSrc, CUBE_FILES);
21917
21943
  const contextFilesList = await findFiles(ctx.client.presetsSrc, PRESET_FILES);
21918
- const filesList = [...cubeFilesList, ...contextFilesList];
21944
+ // Map the files to include their full filenames
21945
+ const filesList = [...cubeFilesList, ...contextFilesList].map((entry) => [path__namespace$1.basename(entry[1]), entry[1]]);
21919
21946
  // add manifest to the archive
21920
21947
  filesList.push([
21921
- "embeddable-manifest",
21948
+ "embeddable-manifest.json",
21922
21949
  path__namespace$1.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
21923
21950
  ]);
21924
21951
  await archive(ctx, filesList, true);
@@ -22069,7 +22096,7 @@ var defineConfig = ({ plugins, region = "legacy-US", pushBaseUrl, audienceUrl, a
22069
22096
  };
22070
22097
 
22071
22098
  var name = "@embeddable.com/sdk-core";
22072
- var version = "3.12.3";
22099
+ var version = "3.12.4";
22073
22100
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
22074
22101
  var keywords = [
22075
22102
  "embeddable",
@@ -22097,7 +22124,8 @@ var files = [
22097
22124
  "lib/",
22098
22125
  "loader/",
22099
22126
  "templates/",
22100
- "configs/"
22127
+ "configs/",
22128
+ "certs"
22101
22129
  ];
22102
22130
  var bin = {
22103
22131
  embeddable: "bin/embeddable"
@@ -22107,7 +22135,7 @@ var engines = {
22107
22135
  };
22108
22136
  var license = "MIT";
22109
22137
  var dependencies = {
22110
- "@embeddable.com/sdk-utils": "0.6.1",
22138
+ "@embeddable.com/sdk-utils": "0.6.2",
22111
22139
  "@inquirer/prompts": "^7.2.1",
22112
22140
  "@stencil/core": "^4.23.0",
22113
22141
  "@swc-node/register": "^1.10.9",