@embeddable.com/sdk-core 3.9.0 → 3.9.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/defineConfig.d.ts +3 -3
- package/lib/index.esm.js +30 -44
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +27 -41
- package/lib/index.js.map +1 -1
- package/lib/push.d.ts +1 -2
- package/package.json +1 -1
- package/src/defineConfig.test.ts +1 -1
- package/src/defineConfig.ts +3 -6
- package/src/dev.test.ts +1 -1
- package/src/dev.ts +17 -25
- package/src/push.ts +6 -30
package/lib/defineConfig.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type EmbeddableConfig = {
|
|
|
16
16
|
previewBaseUrl?: string;
|
|
17
17
|
componentsSrc?: string;
|
|
18
18
|
modelsSrc?: string;
|
|
19
|
-
|
|
19
|
+
globalCss?: string;
|
|
20
20
|
viteConfig?: {
|
|
21
21
|
resolve?: {
|
|
22
22
|
alias?: Record<string, string>;
|
|
@@ -24,7 +24,7 @@ export type EmbeddableConfig = {
|
|
|
24
24
|
};
|
|
25
25
|
rollupOptions?: RollupOptions;
|
|
26
26
|
};
|
|
27
|
-
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc,
|
|
27
|
+
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc, globalCss, viteConfig, rollupOptions, }: EmbeddableConfig) => {
|
|
28
28
|
core: {
|
|
29
29
|
rootDir: string;
|
|
30
30
|
templatesDir: string;
|
|
@@ -36,7 +36,7 @@ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authCl
|
|
|
36
36
|
modelsSrc: string | undefined;
|
|
37
37
|
buildDir: string;
|
|
38
38
|
tmpDir: string;
|
|
39
|
-
|
|
39
|
+
globalCss: string;
|
|
40
40
|
componentDir: string;
|
|
41
41
|
stencilBuild: string;
|
|
42
42
|
archiveFile: string;
|
package/lib/index.esm.js
CHANGED
|
@@ -17,7 +17,8 @@ import require$$1 from 'os';
|
|
|
17
17
|
import require$$3 from 'http';
|
|
18
18
|
import require$$4 from 'https';
|
|
19
19
|
import require$$0$1 from 'url';
|
|
20
|
-
import require$$2$1
|
|
20
|
+
import * as require$$2$1 from 'fs';
|
|
21
|
+
import require$$2__default, { createReadStream } from 'fs';
|
|
21
22
|
import * as path$1 from 'path';
|
|
22
23
|
import path__default$1, { basename } from 'path';
|
|
23
24
|
import axios from 'axios';
|
|
@@ -17855,7 +17856,7 @@ function requireStackTrace () {
|
|
|
17855
17856
|
hasRequiredStackTrace = 1;
|
|
17856
17857
|
var SourceMapConsumer = requireSourceMap().SourceMapConsumer;
|
|
17857
17858
|
var path = path__default$1;
|
|
17858
|
-
var fs = require$$
|
|
17859
|
+
var fs = require$$2__default;
|
|
17859
17860
|
|
|
17860
17861
|
/**
|
|
17861
17862
|
* Uses Node source-map to map transpiled JS stack locations to original
|
|
@@ -18063,7 +18064,7 @@ function requireParser () {
|
|
|
18063
18064
|
|
|
18064
18065
|
var logger = requireLogger();
|
|
18065
18066
|
var async = require$$0;
|
|
18066
|
-
var fs = require$$
|
|
18067
|
+
var fs = require$$2__default;
|
|
18067
18068
|
var lru = requireLruCache();
|
|
18068
18069
|
var util = require$$4$1;
|
|
18069
18070
|
var stackTrace = requireStackTrace();
|
|
@@ -21354,9 +21355,6 @@ async function selectWorkspace(ora, ctx, token) {
|
|
|
21354
21355
|
const oraP$1 = import('ora');
|
|
21355
21356
|
// grab .cube.yml|js and .sc.yml|js files
|
|
21356
21357
|
const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
21357
|
-
// grab all files in self-serve-customization folder
|
|
21358
|
-
const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
|
|
21359
|
-
const customSelfServeFolder = "self-serve-customization/";
|
|
21360
21358
|
let ora$1;
|
|
21361
21359
|
var push = async () => {
|
|
21362
21360
|
var _a, _b;
|
|
@@ -21438,24 +21436,20 @@ async function verify(ctx) {
|
|
|
21438
21436
|
async function buildArchive(config) {
|
|
21439
21437
|
const spinnerArchive = ora$1("Building...").start();
|
|
21440
21438
|
const filesList = await findFiles(config.client.modelsSrc || config.client.srcDir, YAML_OR_JS_FILES);
|
|
21441
|
-
|
|
21442
|
-
// check existance of self-serve-customization folder
|
|
21443
|
-
try {
|
|
21444
|
-
await fs.access(config.client.selfServeCustomizationDir);
|
|
21445
|
-
selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
|
|
21446
|
-
}
|
|
21447
|
-
catch (e) { }
|
|
21448
|
-
await archive(config, filesList, selfServeFiles);
|
|
21439
|
+
await archive(config, filesList);
|
|
21449
21440
|
return spinnerArchive.succeed("Bundling completed");
|
|
21450
21441
|
}
|
|
21451
|
-
async function archive(ctx, yamlFiles,
|
|
21442
|
+
async function archive(ctx, yamlFiles, isDev = false) {
|
|
21452
21443
|
const output = fs$1.createWriteStream(ctx.client.archiveFile);
|
|
21453
21444
|
const _archiver = archiver.create("zip", {
|
|
21454
21445
|
zlib: { level: 9 },
|
|
21455
21446
|
});
|
|
21456
21447
|
_archiver.pipe(output);
|
|
21457
|
-
if (
|
|
21448
|
+
if (!isDev) {
|
|
21458
21449
|
_archiver.directory(ctx.client.buildDir, false);
|
|
21450
|
+
_archiver.file(ctx.client.globalCss, {
|
|
21451
|
+
name: "global.css",
|
|
21452
|
+
});
|
|
21459
21453
|
}
|
|
21460
21454
|
for (const fileData of yamlFiles) {
|
|
21461
21455
|
const fileName = fileData[1].split("/").pop();
|
|
@@ -21463,14 +21457,6 @@ async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true)
|
|
|
21463
21457
|
name: fileName,
|
|
21464
21458
|
});
|
|
21465
21459
|
}
|
|
21466
|
-
if (selfServeFiles.length > 0) {
|
|
21467
|
-
for (const fileData of selfServeFiles) {
|
|
21468
|
-
const fileName = fileData[1].split("/").pop();
|
|
21469
|
-
_archiver.file(fileData[1], {
|
|
21470
|
-
name: `${customSelfServeFolder}${fileName}`,
|
|
21471
|
-
});
|
|
21472
|
-
}
|
|
21473
|
-
}
|
|
21474
21460
|
await _archiver.finalize();
|
|
21475
21461
|
return new Promise((resolve, _reject) => {
|
|
21476
21462
|
output.on("close", resolve);
|
|
@@ -21518,7 +21504,7 @@ let ora;
|
|
|
21518
21504
|
let previewWorkspace;
|
|
21519
21505
|
const SERVER_PORT = 8926;
|
|
21520
21506
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
21521
|
-
const
|
|
21507
|
+
const GLOBAL_CSS = "/global.css";
|
|
21522
21508
|
const buildWebComponent = async (config) => {
|
|
21523
21509
|
await generate(config, "sdk-react");
|
|
21524
21510
|
};
|
|
@@ -21572,7 +21558,6 @@ var dev = async () => {
|
|
|
21572
21558
|
const finalhandler = require("finalhandler");
|
|
21573
21559
|
const serveStatic = require("serve-static");
|
|
21574
21560
|
const serve = serveStatic(config.client.buildDir);
|
|
21575
|
-
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
21576
21561
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
21577
21562
|
try {
|
|
21578
21563
|
previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
|
|
@@ -21583,7 +21568,7 @@ var dev = async () => {
|
|
|
21583
21568
|
}
|
|
21584
21569
|
workspacePreparation.succeed("Workspace is ready");
|
|
21585
21570
|
const server = http.createServer((request, res) => {
|
|
21586
|
-
var _a
|
|
21571
|
+
var _a;
|
|
21587
21572
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
21588
21573
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
21589
21574
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
|
@@ -21594,11 +21579,15 @@ var dev = async () => {
|
|
|
21594
21579
|
return;
|
|
21595
21580
|
}
|
|
21596
21581
|
const done = finalhandler(request, res);
|
|
21597
|
-
|
|
21598
|
-
?
|
|
21599
|
-
|
|
21600
|
-
|
|
21601
|
-
|
|
21582
|
+
try {
|
|
21583
|
+
if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.endsWith(GLOBAL_CSS)) {
|
|
21584
|
+
res.writeHead(200, { "Content-Type": "text/css" });
|
|
21585
|
+
res.end(require$$2$1.readFileSync(config.client.globalCss));
|
|
21586
|
+
return;
|
|
21587
|
+
}
|
|
21588
|
+
}
|
|
21589
|
+
catch (_b) { }
|
|
21590
|
+
serve(request, res, done);
|
|
21602
21591
|
});
|
|
21603
21592
|
wss = new WebSocketServer({ server });
|
|
21604
21593
|
server.listen(SERVER_PORT, async () => {
|
|
@@ -21628,9 +21617,9 @@ var dev = async () => {
|
|
|
21628
21617
|
watchers.push(watcher);
|
|
21629
21618
|
}
|
|
21630
21619
|
const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
|
|
21631
|
-
const
|
|
21620
|
+
const customGlobalCssWatch = globalCssWatcher(config);
|
|
21632
21621
|
watchers.push(dataModelAndSecurityContextWatch);
|
|
21633
|
-
watchers.push(
|
|
21622
|
+
watchers.push(customGlobalCssWatch);
|
|
21634
21623
|
});
|
|
21635
21624
|
};
|
|
21636
21625
|
const configureWatcher = async (watcher, ctx) => {
|
|
@@ -21686,13 +21675,10 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
|
21686
21675
|
});
|
|
21687
21676
|
return fsWatcher;
|
|
21688
21677
|
};
|
|
21689
|
-
const
|
|
21690
|
-
const fsWatcher = chokidar.watch(
|
|
21691
|
-
path$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
|
|
21692
|
-
path$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
|
|
21693
|
-
], chokidarWatchOptions);
|
|
21678
|
+
const globalCssWatcher = (ctx) => {
|
|
21679
|
+
const fsWatcher = chokidar.watch(ctx.client.globalCss, chokidarWatchOptions);
|
|
21694
21680
|
fsWatcher.on("all", async () => {
|
|
21695
|
-
sendMessage("
|
|
21681
|
+
sendMessage("globalCssUpdateSuccess");
|
|
21696
21682
|
});
|
|
21697
21683
|
return fsWatcher;
|
|
21698
21684
|
};
|
|
@@ -21708,7 +21694,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
|
|
|
21708
21694
|
"embeddable-manifest",
|
|
21709
21695
|
path$1.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
|
|
21710
21696
|
]);
|
|
21711
|
-
await archive(ctx, filesList,
|
|
21697
|
+
await archive(ctx, filesList, true);
|
|
21712
21698
|
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
21713
21699
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
21714
21700
|
sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
|
|
@@ -21765,7 +21751,7 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
|
21765
21751
|
}
|
|
21766
21752
|
};
|
|
21767
21753
|
|
|
21768
|
-
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src",
|
|
21754
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, }) => {
|
|
21769
21755
|
const coreRoot = path.resolve(__dirname, "..");
|
|
21770
21756
|
const clientRoot = process.cwd();
|
|
21771
21757
|
if (!path.isAbsolute(componentsSrc)) {
|
|
@@ -21792,7 +21778,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21792
21778
|
modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
|
|
21793
21779
|
buildDir: path.resolve(clientRoot, ".embeddable-build"),
|
|
21794
21780
|
tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
|
|
21795
|
-
|
|
21781
|
+
globalCss: path.resolve(clientRoot, globalCss),
|
|
21796
21782
|
componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
|
|
21797
21783
|
stencilBuild: path.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
|
|
21798
21784
|
archiveFile: path.resolve(clientRoot, "embeddable-build.zip"),
|
|
@@ -21818,7 +21804,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21818
21804
|
};
|
|
21819
21805
|
|
|
21820
21806
|
var name = "@embeddable.com/sdk-core";
|
|
21821
|
-
var version = "3.9.
|
|
21807
|
+
var version = "3.9.2";
|
|
21822
21808
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21823
21809
|
var keywords = [
|
|
21824
21810
|
"embeddable",
|