@embeddable.com/sdk-core 3.7.0 → 3.7.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 -1
- package/lib/index.esm.js +46 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +46 -6
- package/lib/index.js.map +1 -1
- package/lib/push.d.ts +2 -1
- package/package.json +1 -1
- package/src/defineConfig.test.ts +1 -0
- package/src/defineConfig.ts +6 -0
- package/src/dev.ts +37 -2
- package/src/push.ts +28 -1
package/lib/defineConfig.d.ts
CHANGED
|
@@ -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,17 @@ 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
|
-
|
|
20657
|
+
let selfServeFiles = [];
|
|
20658
|
+
// check existance of self-serve-customization folder
|
|
20659
|
+
try {
|
|
20660
|
+
await fs$1.access(config.client.selfServeCustomizationDir);
|
|
20661
|
+
selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
|
|
20662
|
+
}
|
|
20663
|
+
catch (e) { }
|
|
20664
|
+
await archive(config, filesList, selfServeFiles);
|
|
20655
20665
|
return spinnerArchive.succeed("Bundling completed");
|
|
20656
20666
|
}
|
|
20657
|
-
async function archive(ctx, yamlFiles, includeBuild = true) {
|
|
20667
|
+
async function archive(ctx, yamlFiles, selfServeFiles = [], includeBuild = true) {
|
|
20658
20668
|
const output = fs$2.createWriteStream(ctx.client.archiveFile);
|
|
20659
20669
|
const _archiver = archiver.create("zip", {
|
|
20660
20670
|
zlib: { level: 9 },
|
|
@@ -20669,6 +20679,14 @@ async function archive(ctx, yamlFiles, includeBuild = true) {
|
|
|
20669
20679
|
name: fileName,
|
|
20670
20680
|
});
|
|
20671
20681
|
}
|
|
20682
|
+
if (selfServeFiles.length > 0) {
|
|
20683
|
+
for (const fileData of selfServeFiles) {
|
|
20684
|
+
const fileName = fileData[1].split("/").pop();
|
|
20685
|
+
_archiver.file(fileData[1], {
|
|
20686
|
+
name: `${customSelfServeFolder}${fileName}`,
|
|
20687
|
+
});
|
|
20688
|
+
}
|
|
20689
|
+
}
|
|
20672
20690
|
await _archiver.finalize();
|
|
20673
20691
|
return new Promise((resolve, _reject) => {
|
|
20674
20692
|
output.on("close", resolve);
|
|
@@ -20736,6 +20754,7 @@ let ora;
|
|
|
20736
20754
|
let previewWorkspace;
|
|
20737
20755
|
const SERVER_PORT = 8926;
|
|
20738
20756
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
20757
|
+
const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
|
|
20739
20758
|
const buildWebComponent = async (config) => {
|
|
20740
20759
|
await generate(config, "sdk-react");
|
|
20741
20760
|
};
|
|
@@ -20782,6 +20801,7 @@ var dev = async () => {
|
|
|
20782
20801
|
const finalhandler = require("finalhandler");
|
|
20783
20802
|
const serveStatic = require("serve-static");
|
|
20784
20803
|
const serve = serveStatic(config.client.buildDir);
|
|
20804
|
+
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
20785
20805
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
20786
20806
|
try {
|
|
20787
20807
|
previewWorkspace = await getPreviewWorkspace(config);
|
|
@@ -20792,6 +20812,7 @@ var dev = async () => {
|
|
|
20792
20812
|
}
|
|
20793
20813
|
workspacePreparation.succeed("Workspace is ready");
|
|
20794
20814
|
const server = http.createServer((request, res) => {
|
|
20815
|
+
var _a, _b;
|
|
20795
20816
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
20796
20817
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
20797
20818
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
|
@@ -20802,7 +20823,11 @@ var dev = async () => {
|
|
|
20802
20823
|
return;
|
|
20803
20824
|
}
|
|
20804
20825
|
const done = finalhandler(request, res);
|
|
20805
|
-
|
|
20826
|
+
const selectedServe = ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith(SELF_SERVE_CUSTOMIZATION_REQUEST_URL))
|
|
20827
|
+
? serveSelfeServe
|
|
20828
|
+
: serve;
|
|
20829
|
+
request.url = (_b = request.url) === null || _b === void 0 ? void 0 : _b.replace(SELF_SERVE_CUSTOMIZATION_REQUEST_URL, "");
|
|
20830
|
+
selectedServe(request, res, done);
|
|
20806
20831
|
});
|
|
20807
20832
|
wss = new WebSocketServer({ server });
|
|
20808
20833
|
server.listen(SERVER_PORT, async () => {
|
|
@@ -20832,7 +20857,9 @@ var dev = async () => {
|
|
|
20832
20857
|
watchers.push(watcher);
|
|
20833
20858
|
}
|
|
20834
20859
|
const dataModelAndSecurityContextWatch = dataModelAndSecurityContextWatcher(config);
|
|
20860
|
+
const customSelfServeWatch = customSelfServeWatcher(config);
|
|
20835
20861
|
watchers.push(dataModelAndSecurityContextWatch);
|
|
20862
|
+
watchers.push(customSelfServeWatch);
|
|
20836
20863
|
});
|
|
20837
20864
|
};
|
|
20838
20865
|
const configureWatcher = async (watcher, ctx) => {
|
|
@@ -20890,6 +20917,18 @@ const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
|
20890
20917
|
});
|
|
20891
20918
|
return fsWatcher;
|
|
20892
20919
|
};
|
|
20920
|
+
const customSelfServeWatcher = (ctx) => {
|
|
20921
|
+
const fsWatcher = chokidar.watch([
|
|
20922
|
+
path$2.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
|
|
20923
|
+
path$2.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
|
|
20924
|
+
], {
|
|
20925
|
+
ignoreInitial: true,
|
|
20926
|
+
});
|
|
20927
|
+
fsWatcher.on("all", async () => {
|
|
20928
|
+
sendMessage("customSelfServeUpdateSuccess");
|
|
20929
|
+
});
|
|
20930
|
+
return fsWatcher;
|
|
20931
|
+
};
|
|
20893
20932
|
const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
|
|
20894
20933
|
sendMessage("dataModelsAndOrSecurityContextUpdateStart");
|
|
20895
20934
|
const isValid = await validate(ctx, false);
|
|
@@ -20902,7 +20941,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
|
|
|
20902
20941
|
"embeddable-manifest",
|
|
20903
20942
|
path$2.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
|
|
20904
20943
|
]);
|
|
20905
|
-
await archive(ctx, filesList, false);
|
|
20944
|
+
await archive(ctx, filesList, [], false);
|
|
20906
20945
|
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
20907
20946
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
20908
20947
|
sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
|
|
@@ -20953,7 +20992,7 @@ const getPreviewWorkspace = async (ctx) => {
|
|
|
20953
20992
|
}
|
|
20954
20993
|
};
|
|
20955
20994
|
|
|
20956
|
-
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", viteConfig = {}, rollupOptions = {}, }) => {
|
|
20995
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", selfServeCustomizationSrc = "src/self-serve-customization", viteConfig = {}, rollupOptions = {}, }) => {
|
|
20957
20996
|
const coreRoot = path$1.resolve(__dirname, "..");
|
|
20958
20997
|
const clientRoot = process.cwd();
|
|
20959
20998
|
if (!path$1.isAbsolute(componentsSrc)) {
|
|
@@ -20980,6 +21019,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
20980
21019
|
modelsSrc: modelsSrc ? path$1.resolve(clientRoot, modelsSrc) : undefined,
|
|
20981
21020
|
buildDir: path$1.resolve(clientRoot, ".embeddable-build"),
|
|
20982
21021
|
tmpDir: path$1.resolve(clientRoot, ".embeddable-tmp"),
|
|
21022
|
+
selfServeCustomizationDir: path$1.resolve(clientRoot, selfServeCustomizationSrc),
|
|
20983
21023
|
componentDir: path$1.resolve(clientRoot, ".embeddable-build", "component"),
|
|
20984
21024
|
stencilBuild: path$1.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
|
|
20985
21025
|
archiveFile: path$1.resolve(clientRoot, "embeddable-build.zip"),
|
|
@@ -21005,7 +21045,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21005
21045
|
};
|
|
21006
21046
|
|
|
21007
21047
|
var name = "@embeddable.com/sdk-core";
|
|
21008
|
-
var version = "3.7.
|
|
21048
|
+
var version = "3.7.2";
|
|
21009
21049
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21010
21050
|
var keywords = [
|
|
21011
21051
|
"embeddable",
|