@embeddable.com/sdk-core 3.13.1 → 3.13.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
@@ -8,9 +8,7 @@ var crypto = require('node:crypto');
8
8
  var fs$1 = require('node:fs');
9
9
  var node = require('@stencil/core/sys/node');
10
10
  var compiler = require('@stencil/core/compiler');
11
- var sorcery = require('sorcery');
12
11
  var os = require('node:os');
13
- var ora = require('ora');
14
12
  var YAML = require('yaml');
15
13
  var url = require('node:url');
16
14
  var require$$4$1 = require('util');
@@ -26,7 +24,6 @@ var prompts = require('@inquirer/prompts');
26
24
  var http = require('node:http');
27
25
  var ws = require('ws');
28
26
  var chokidar = require('chokidar');
29
- var minimist = require('minimist');
30
27
  var fg = require('fast-glob');
31
28
  var dotenv = require('dotenv');
32
29
  var promises = require('fs/promises');
@@ -53,7 +50,6 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
53
50
  var vite__namespace = /*#__PURE__*/_interopNamespaceDefault(vite);
54
51
  var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
55
52
  var fs__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(fs$1);
56
- var sorcery__namespace = /*#__PURE__*/_interopNamespaceDefault(sorcery);
57
53
  var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
58
54
  var YAML__namespace = /*#__PURE__*/_interopNamespaceDefault(YAML);
59
55
  var url__namespace = /*#__PURE__*/_interopNamespaceDefault(url);
@@ -400,11 +396,11 @@ const getContentHash = (contentString) => {
400
396
  .substring(0, 5);
401
397
  };
402
398
 
403
- const oraP$1 = import('ora');
399
+ const oraP$4 = import('ora');
404
400
  const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
405
401
  const EMB_OPTIONS_FILE_REGEX = /^(.*)\.options\.emb\.[jt]s$/;
406
402
  var buildTypes = async (ctx) => {
407
- const ora = (await oraP$1).default;
403
+ const ora = (await oraP$4).default;
408
404
  const progress = ora("Building types...").start();
409
405
  await generate$1(ctx);
410
406
  await build$1(ctx);
@@ -466,6 +462,7 @@ async function createComponentDir(dir) {
466
462
  await fs__namespace.mkdir(dir);
467
463
  }
468
464
 
465
+ const sorcery = require("sorcery");
469
466
  const STYLE_IMPORTS_TOKEN = "{{STYLES_IMPORT}}";
470
467
  const RENDER_IMPORT_TOKEN = "{{RENDER_IMPORT}}";
471
468
  // stencil doesn't support dynamic component tag name, so we need to replace it manually
@@ -579,7 +576,7 @@ async function generateSourceMap(ctx, pluginName) {
579
576
  const jsFiles = stencilFiles.filter((file) => file.toLowerCase().endsWith(".js"));
580
577
  await Promise.all(jsFiles.map(async (jsFile) => {
581
578
  try {
582
- const chain = await sorcery__namespace.load(path__namespace.resolve(stencilBuild, jsFile));
579
+ const chain = await sorcery.load(path__namespace.resolve(stencilBuild, jsFile));
583
580
  // overwrite the existing file
584
581
  await chain.write();
585
582
  }
@@ -593,16 +590,12 @@ async function generateSourceMap(ctx, pluginName) {
593
590
  const CREDENTIALS_DIR = path__namespace.resolve(os__namespace.homedir(), ".embeddable");
594
591
  const CREDENTIALS_FILE = path__namespace.resolve(CREDENTIALS_DIR, "credentials");
595
592
 
593
+ const oraP$3 = import('ora');
596
594
  const checkNodeVersion = async () => {
595
+ const ora = (await oraP$3).default;
597
596
  const spinner = ora("Checking node version...").start();
598
597
  const [major, minor] = process.versions.node.split(".").map(Number);
599
- let packageJson;
600
- try {
601
- packageJson = JSON.parse(fs$1.readFileSync(path.join(undefined, "../package.json"), "utf-8"));
602
- }
603
- catch (e) {
604
- throw new Error("Failed to read package.json of core-sdk");
605
- }
598
+ const packageJson = await Promise.resolve().then(function () { return _package$1; });
606
599
  const { engines: { node }, } = packageJson;
607
600
  const [minMajor, minMinor] = node
608
601
  .split(".")
@@ -5213,7 +5206,6 @@ var provideConfig = async () => {
5213
5206
  ? tsConfigFilePath
5214
5207
  : configFilePath;
5215
5208
  const pathOrUrl = isWindows ? url__namespace.pathToFileURL(configPath).href : configPath;
5216
- console.log(pathOrUrl);
5217
5209
  return (await import(pathOrUrl)).default;
5218
5210
  };
5219
5211
 
@@ -5246,25 +5238,25 @@ function getAugmentedNamespace(n) {
5246
5238
  return a;
5247
5239
  }
5248
5240
 
5249
- var name = "rollbar";
5250
- var version = "2.26.4";
5251
- var repository = {
5241
+ var name$1 = "rollbar";
5242
+ var version$1 = "2.26.4";
5243
+ var repository$1 = {
5252
5244
  type: "git",
5253
5245
  url: "http://github.com/rollbar/rollbar.js"
5254
5246
  };
5255
- var description = "Effortlessly track and debug errors in your JavaScript applications with Rollbar. This package includes advanced error tracking features and an intuitive interface to help you identify and fix issues more quickly.";
5256
- var keywords = [
5247
+ var description$1 = "Effortlessly track and debug errors in your JavaScript applications with Rollbar. This package includes advanced error tracking features and an intuitive interface to help you identify and fix issues more quickly.";
5248
+ var keywords$1 = [
5257
5249
  "error",
5258
5250
  "tracking",
5259
5251
  "logging",
5260
5252
  "debugging",
5261
5253
  "javascript"
5262
5254
  ];
5263
- var license = "MIT";
5264
- var main = "src/server/rollbar.js";
5255
+ var license$1 = "MIT";
5256
+ var main$1 = "src/server/rollbar.js";
5265
5257
  var browser = "dist/rollbar.umd.min.js";
5266
- var types = "./index.d.ts";
5267
- var dependencies = {
5258
+ var types$1 = "./index.d.ts";
5259
+ var dependencies$1 = {
5268
5260
  async: "~3.2.3",
5269
5261
  "console-polyfill": "0.3.0",
5270
5262
  "error-stack-parser": "^2.0.4",
@@ -5273,7 +5265,7 @@ var dependencies = {
5273
5265
  "request-ip": "~3.3.0",
5274
5266
  "source-map": "^0.5.7"
5275
5267
  };
5276
- var devDependencies = {
5268
+ var devDependencies$1 = {
5277
5269
  "@babel/core": "^7.22.11",
5278
5270
  "babel-eslint": "^10.0.3",
5279
5271
  "babel-loader": "^8.0.4",
@@ -5333,7 +5325,7 @@ var devDependencies = {
5333
5325
  var optionalDependencies = {
5334
5326
  decache: "^3.0.5"
5335
5327
  };
5336
- var scripts = {
5328
+ var scripts$1 = {
5337
5329
  build: "./node_modules/.bin/grunt",
5338
5330
  test: "./node_modules/.bin/grunt test",
5339
5331
  "test-browser": "./node_modules/.bin/grunt test-browser",
@@ -5407,19 +5399,19 @@ var plugins = {
5407
5399
  }
5408
5400
  };
5409
5401
  var require$$2 = {
5410
- name: name,
5411
- version: version,
5412
- repository: repository,
5413
- description: description,
5414
- keywords: keywords,
5415
- license: license,
5416
- main: main,
5402
+ name: name$1,
5403
+ version: version$1,
5404
+ repository: repository$1,
5405
+ description: description$1,
5406
+ keywords: keywords$1,
5407
+ license: license$1,
5408
+ main: main$1,
5417
5409
  browser: browser,
5418
- types: types,
5419
- dependencies: dependencies,
5420
- devDependencies: devDependencies,
5410
+ types: types$1,
5411
+ dependencies: dependencies$1,
5412
+ devDependencies: devDependencies$1,
5421
5413
  optionalDependencies: optionalDependencies,
5422
- scripts: scripts,
5414
+ scripts: scripts$1,
5423
5415
  cdn: cdn,
5424
5416
  defaults: defaults,
5425
5417
  plugins: plugins
@@ -21409,13 +21401,13 @@ var build = async () => {
21409
21401
  }
21410
21402
  };
21411
21403
 
21412
- const oraP = import('ora');
21404
+ const oraP$2 = import('ora');
21413
21405
  const openP = import('open');
21414
21406
  var login = async () => {
21415
21407
  var _a;
21416
21408
  await initLogger("login");
21417
21409
  const breadcrumbs = [];
21418
- const ora = (await oraP).default;
21410
+ const ora = (await oraP$2).default;
21419
21411
  const authenticationSpinner = ora("Waiting for code verification...").start();
21420
21412
  try {
21421
21413
  const open = (await openP).default;
@@ -21505,7 +21497,7 @@ async function resolveFiles() {
21505
21497
  }
21506
21498
 
21507
21499
  async function getWorkspaces(ctx, token, workspaceSpinner) {
21508
- var _a, _b, _c;
21500
+ var _a, _b;
21509
21501
  try {
21510
21502
  const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
21511
21503
  headers: {
@@ -21515,11 +21507,7 @@ async function getWorkspaces(ctx, token, workspaceSpinner) {
21515
21507
  return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
21516
21508
  }
21517
21509
  catch (e) {
21518
- if ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch) {
21519
- workspaceSpinner.stop();
21520
- throw e;
21521
- }
21522
- if (((_c = e.response) === null || _c === void 0 ? void 0 : _c.status) === 401) {
21510
+ if (((_b = e.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
21523
21511
  workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
21524
21512
  }
21525
21513
  else {
@@ -21557,10 +21545,12 @@ async function selectWorkspace(ora, ctx, token) {
21557
21545
  return selectedWorkspace;
21558
21546
  }
21559
21547
 
21548
+ const oraP$1 = import('ora');
21560
21549
  // grab cube files
21561
21550
  const CUBE_FILES = /^(.*)\.cube\.(ya?ml|js)$/;
21562
21551
  // grab security context and client context files
21563
21552
  const PRESET_FILES = /^(.*)\.(sc|cc)\.ya?ml$/;
21553
+ let ora$1;
21564
21554
  var push = async () => {
21565
21555
  var _a;
21566
21556
  await initLogger("push");
@@ -21574,9 +21564,10 @@ var push = async () => {
21574
21564
  console.error("Build failed or not completed. Please run `embeddable:build` first.");
21575
21565
  process.exit(1);
21576
21566
  }
21567
+ ora$1 = (await oraP$1).default;
21577
21568
  const config = await provideConfig();
21578
21569
  if (process.argv.includes("--api-key") || process.argv.includes("-k")) {
21579
- spinnerPushing = ora("Using API key...").start();
21570
+ spinnerPushing = ora$1("Using API key...").start();
21580
21571
  breadcrumbs.push("push by api key");
21581
21572
  await pushByApiKey(config, spinnerPushing);
21582
21573
  spinnerPushing.succeed("Published using API key");
@@ -21584,11 +21575,11 @@ var push = async () => {
21584
21575
  }
21585
21576
  breadcrumbs.push("push by standard login");
21586
21577
  const token = await verify(config);
21587
- spinnerPushing = ora()
21578
+ spinnerPushing = ora$1()
21588
21579
  .start()
21589
21580
  .info("No API Key provided. Standard login will be used.");
21590
21581
  breadcrumbs.push("select workspace");
21591
- const { workspaceId, name: workspaceName } = await selectWorkspace(ora, config, token);
21582
+ const { workspaceId, name: workspaceName } = await selectWorkspace(ora$1, config, token);
21592
21583
  const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
21593
21584
  breadcrumbs.push("build archive");
21594
21585
  await buildArchive(config);
@@ -21642,7 +21633,7 @@ async function verify(ctx) {
21642
21633
  return token;
21643
21634
  }
21644
21635
  async function buildArchive(config) {
21645
- const spinnerArchive = ora("Building...").start();
21636
+ const spinnerArchive = ora$1("Building...").start();
21646
21637
  const cubeFilesList = await findFiles(config.client.modelsSrc || config.client.srcDir, CUBE_FILES);
21647
21638
  const contextFilesList = await findFiles(config.client.presetsSrc || config.client.srcDir, PRESET_FILES);
21648
21639
  // Map the files to include their full filenames
@@ -21705,10 +21696,13 @@ async function uploadFile(formData, url, token) {
21705
21696
  });
21706
21697
  }
21707
21698
 
21699
+ const minimist = require("minimist");
21708
21700
  dotenv__namespace.config();
21701
+ const oraP = import('ora');
21709
21702
  let wss;
21710
21703
  let changedFiles = [];
21711
21704
  let browserWindow = null;
21705
+ let ora;
21712
21706
  let previewWorkspace;
21713
21707
  const SERVER_PORT = 8926;
21714
21708
  const BUILD_DEV_DIR = ".embeddable-dev-build";
@@ -21738,13 +21732,14 @@ const chokidarWatchOptions = {
21738
21732
  },
21739
21733
  };
21740
21734
  var dev = async () => {
21741
- var _a, _b, _c;
21735
+ var _a, _b;
21742
21736
  await initLogger("dev");
21743
21737
  const breadcrumbs = [];
21744
21738
  try {
21745
21739
  breadcrumbs.push("run dev");
21746
21740
  checkNodeVersion();
21747
21741
  addToGitingore();
21742
+ ora = (await oraP).default;
21748
21743
  process.on("warning", (e) => console.warn(e.stack));
21749
21744
  const logger = node.createNodeLogger();
21750
21745
  const sys = node.createNodeSys({ process });
@@ -21770,22 +21765,14 @@ var dev = async () => {
21770
21765
  const finalhandler = require("finalhandler");
21771
21766
  const serveStatic = require("serve-static");
21772
21767
  const serve = serveStatic(config.client.buildDir);
21773
- let workspacePreparation = ora("Preparing workspace...").start();
21768
+ const workspacePreparation = ora("Preparing workspace...").start();
21774
21769
  breadcrumbs.push("get preview workspace");
21775
21770
  try {
21776
21771
  previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
21777
21772
  }
21778
21773
  catch (e) {
21779
- if (((_a = e.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
21780
- // login and retry
21781
- await login();
21782
- workspacePreparation = ora("Preparing workspace...").start();
21783
- previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
21784
- }
21785
- else {
21786
- 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);
21787
- process.exit(1);
21788
- }
21774
+ 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);
21775
+ process.exit(1);
21789
21776
  }
21790
21777
  workspacePreparation.succeed("Workspace is ready");
21791
21778
  const server = http__namespace.createServer((request, res) => {
@@ -22020,12 +22007,52 @@ const REGION_CONFIGS = {
22020
22007
  authClientId: "dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V",
22021
22008
  },
22022
22009
  };
22023
- var defineConfig = ({ plugins, region = "legacy-US", pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
22010
+ const embeddableConfigSchema = z
22011
+ .object({
22012
+ plugins: z.array(z.function()),
22013
+ region: z
22014
+ .union([z.literal("EU"), z.literal("US"), z.literal("legacy-US")])
22015
+ .optional(),
22016
+ pushBaseUrl: z.string().optional(),
22017
+ audienceUrl: z.string().optional(),
22018
+ authDomain: z.string().optional(),
22019
+ authClientId: z.string().optional(),
22020
+ errorFallbackComponent: z.string().optional(),
22021
+ applicationEnvironment: z.string().optional(),
22022
+ rollbarAccessToken: z.string().optional(),
22023
+ previewBaseUrl: z.string().optional(),
22024
+ modelsSrc: z.string().optional(),
22025
+ presetsSrc: z.string().optional(),
22026
+ componentsSrc: z.string().optional(),
22027
+ globalCss: z.string().optional(),
22028
+ viteConfig: z
22029
+ .object({
22030
+ resolve: z
22031
+ .object({
22032
+ alias: z.record(z.string()),
22033
+ })
22034
+ .optional(),
22035
+ })
22036
+ .optional(),
22037
+ rollupOptions: z.object({}).optional(),
22038
+ })
22039
+ .strict();
22040
+ var defineConfig = (config) => {
22041
+ const safeParse = embeddableConfigSchema.safeParse(config);
22042
+ const errors = [];
22043
+ if (!safeParse.success) {
22044
+ errorFormatter(safeParse.error.issues).forEach((error) => {
22045
+ errors.push(`${error}`);
22046
+ });
22047
+ }
22048
+ if (errors.length > 0) {
22049
+ throw new Error(`Invalid Embeddable Configuration: ${errors.join("\n")}}`);
22050
+ }
22051
+ let { plugins, region = "legacy-US", pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, } = config;
22024
22052
  if (region && !REGION_CONFIGS[region]) {
22025
22053
  throw new Error(`Unsupported region: ${region}. Supported regions are: ${Object.keys(REGION_CONFIGS).join(", ")}`);
22026
22054
  }
22027
22055
  const regionConfig = REGION_CONFIGS[region];
22028
- const __dirname = undefined;
22029
22056
  const coreRoot = path__namespace.resolve(__dirname, "..");
22030
22057
  const clientRoot = process.cwd();
22031
22058
  if (!path__namespace.isAbsolute(componentsSrc)) {
@@ -22084,6 +22111,114 @@ var defineConfig = ({ plugins, region = "legacy-US", pushBaseUrl, audienceUrl, a
22084
22111
  };
22085
22112
  };
22086
22113
 
22114
+ var name = "@embeddable.com/sdk-core";
22115
+ var version = "3.12.4-next.1";
22116
+ var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
22117
+ var keywords = [
22118
+ "embeddable",
22119
+ "sdk",
22120
+ "web-components"
22121
+ ];
22122
+ var main = "lib/index.js";
22123
+ var module$1 = "lib/index.esm.js";
22124
+ var types = "lib/index.d.ts";
22125
+ var repository = {
22126
+ type: "git",
22127
+ url: "git+https://github.com/embeddable-hq/embeddable-sdk.git",
22128
+ directory: "packages/core-sdk"
22129
+ };
22130
+ var scripts = {
22131
+ build: "rollup -c",
22132
+ test: "vitest run",
22133
+ "test:watch": "vitest",
22134
+ "license-report": "license-report --output=csv --csvHeaders --fields name --fields link --fields licenseType --fields installedVersion --fields author > license-report-sdk-core-sdk.csv"
22135
+ };
22136
+ var author = "Embeddable.com <engineering@embeddable.com>";
22137
+ var files = [
22138
+ "bin/",
22139
+ "src/",
22140
+ "lib/",
22141
+ "loader/",
22142
+ "templates/",
22143
+ "configs/"
22144
+ ];
22145
+ var bin = {
22146
+ embeddable: "bin/embeddable"
22147
+ };
22148
+ var engines = {
22149
+ node: ">=20.0.0"
22150
+ };
22151
+ var license = "MIT";
22152
+ var dependencies = {
22153
+ "@embeddable.com/sdk-utils": "0.6.2-next.0",
22154
+ "@inquirer/prompts": "^7.2.1",
22155
+ "@stencil/core": "^4.23.0",
22156
+ "@swc-node/register": "^1.10.9",
22157
+ archiver: "^5.3.2",
22158
+ axios: "^1.7.9",
22159
+ chokidar: "^4.0.3",
22160
+ dotenv: "^16.4.7",
22161
+ "fast-glob": "^3.3.2",
22162
+ finalhandler: "^1.3.1",
22163
+ "formdata-node": "^6.0.3",
22164
+ minimist: "^1.2.8",
22165
+ open: "^9.1.0",
22166
+ ora: "^8.1.1",
22167
+ "serve-static": "^1.16.2",
22168
+ sorcery: "^0.11.1",
22169
+ vite: "^5.4.11",
22170
+ ws: "^8.18.0",
22171
+ yaml: "^2.6.1"
22172
+ };
22173
+ var devDependencies = {
22174
+ "@types/archiver": "^5.3.4",
22175
+ "@types/ws": "^8.5.13"
22176
+ };
22177
+ var _package = {
22178
+ name: name,
22179
+ version: version,
22180
+ description: description,
22181
+ keywords: keywords,
22182
+ main: main,
22183
+ module: module$1,
22184
+ types: types,
22185
+ repository: repository,
22186
+ scripts: scripts,
22187
+ author: author,
22188
+ files: files,
22189
+ bin: bin,
22190
+ engines: engines,
22191
+ license: license,
22192
+ dependencies: dependencies,
22193
+ "lint-staged": {
22194
+ "*.{js,ts,json}": [
22195
+ "prettier --write"
22196
+ ]
22197
+ },
22198
+ devDependencies: devDependencies
22199
+ };
22200
+
22201
+ var _package$1 = /*#__PURE__*/Object.freeze({
22202
+ __proto__: null,
22203
+ author: author,
22204
+ bin: bin,
22205
+ default: _package,
22206
+ dependencies: dependencies,
22207
+ description: description,
22208
+ devDependencies: devDependencies,
22209
+ engines: engines,
22210
+ files: files,
22211
+ keywords: keywords,
22212
+ license: license,
22213
+ main: main,
22214
+ module: module$1,
22215
+ name: name,
22216
+ repository: repository,
22217
+ scripts: scripts,
22218
+ types: types,
22219
+ version: version
22220
+ });
22221
+
22087
22222
  var __accessCheck = (obj, member, msg) => {
22088
22223
  if (!member.has(obj))
22089
22224
  throw TypeError("Cannot " + msg);