@embeddable.com/sdk-core 2.4.14 → 2.4.16
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/configs/package.json +13 -0
- package/lib/buildTypes.d.ts +2 -0
- package/lib/defineConfig.d.ts +3 -1
- package/lib/dev.d.ts +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +218 -38
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +220 -38
- package/lib/index.js.map +1 -1
- package/lib/prepare.d.ts +1 -0
- package/lib/push.d.ts +6 -0
- package/lib/validate.d.ts +2 -1
- package/package.json +7 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "embeddable-wrapper",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"es2015": "dist/esm/index.mjs",
|
|
7
|
+
"es2017": "dist/esm/index.mjs",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"collection": "dist/collection/collection-manifest.json",
|
|
10
|
+
"collection:main": "dist/collection/index.js",
|
|
11
|
+
"unpkg": "dist/embeddable/embeddable.esm.js",
|
|
12
|
+
"license": "MIT"
|
|
13
|
+
}
|
package/lib/buildTypes.d.ts
CHANGED
package/lib/defineConfig.d.ts
CHANGED
|
@@ -12,8 +12,9 @@ export type EmbeddableConfig = {
|
|
|
12
12
|
errorFallbackComponent?: string;
|
|
13
13
|
applicationEnvironment?: string;
|
|
14
14
|
rollbarAccessToken?: string;
|
|
15
|
+
previewBaseUrl?: string;
|
|
15
16
|
};
|
|
16
|
-
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, }: EmbeddableConfig) => {
|
|
17
|
+
declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, }: EmbeddableConfig) => {
|
|
17
18
|
core: {
|
|
18
19
|
rootDir: string;
|
|
19
20
|
templatesDir: string;
|
|
@@ -34,6 +35,7 @@ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authCl
|
|
|
34
35
|
};
|
|
35
36
|
pushBaseUrl: string;
|
|
36
37
|
audienceUrl: string;
|
|
38
|
+
previewBaseUrl: string;
|
|
37
39
|
authDomain: string;
|
|
38
40
|
authClientId: string;
|
|
39
41
|
applicationEnvironment: string;
|
package/lib/dev.d.ts
ADDED
package/lib/index.d.ts
CHANGED
package/lib/index.esm.js
CHANGED
|
@@ -8,10 +8,10 @@ import * as fsSync from 'node:fs';
|
|
|
8
8
|
import { createNodeLogger, createNodeSys } from '@stencil/core/sys/node';
|
|
9
9
|
import { loadConfig, createCompiler } from '@stencil/core/compiler';
|
|
10
10
|
import * as YAML from 'yaml';
|
|
11
|
-
import * as
|
|
12
|
-
import
|
|
11
|
+
import * as path$2 from 'path';
|
|
12
|
+
import path__default, { basename } from 'path';
|
|
13
13
|
import require$$4$1 from 'util';
|
|
14
|
-
import require$$1
|
|
14
|
+
import require$$1 from 'os';
|
|
15
15
|
import require$$3 from 'http';
|
|
16
16
|
import require$$4 from 'https';
|
|
17
17
|
import require$$0$1 from 'url';
|
|
@@ -19,6 +19,8 @@ import require$$2$1, { createReadStream } from 'fs';
|
|
|
19
19
|
import * as os$1 from 'node:os';
|
|
20
20
|
import axios from 'axios';
|
|
21
21
|
import * as archiver from 'archiver';
|
|
22
|
+
import { WebSocketServer } from 'ws';
|
|
23
|
+
import * as chokidar from 'chokidar';
|
|
22
24
|
import { stat } from 'fs/promises';
|
|
23
25
|
|
|
24
26
|
var findFiles = async (initialSrcDir, regex) => {
|
|
@@ -333,11 +335,11 @@ const formatErrorPath = (path) => {
|
|
|
333
335
|
return formatted;
|
|
334
336
|
};
|
|
335
337
|
|
|
336
|
-
const oraP$
|
|
338
|
+
const oraP$4 = import('ora');
|
|
337
339
|
const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
|
|
338
340
|
const EMB_OPTIONS_FILE_REGEX = /^(.*)\.options\.emb\.[jt]s$/;
|
|
339
341
|
var buildTypes = async (ctx) => {
|
|
340
|
-
const ora = (await oraP$
|
|
342
|
+
const ora = (await oraP$4).default;
|
|
341
343
|
const progress = ora("building types...").start();
|
|
342
344
|
await generate$1(ctx);
|
|
343
345
|
await build$1(ctx);
|
|
@@ -354,17 +356,16 @@ async function generate$1(ctx) {
|
|
|
354
356
|
await fs$1.writeFile(path$1.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
355
357
|
}
|
|
356
358
|
async function build$1(ctx) {
|
|
357
|
-
process.chdir(ctx.client.rootDir);
|
|
358
359
|
await vite.build({
|
|
359
360
|
logLevel: "error",
|
|
360
361
|
build: {
|
|
361
362
|
emptyOutDir: false,
|
|
362
363
|
lib: {
|
|
363
|
-
entry:
|
|
364
|
+
entry: path$1.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename),
|
|
364
365
|
formats: ["es"],
|
|
365
366
|
fileName: "embeddable-types",
|
|
366
367
|
},
|
|
367
|
-
outDir:
|
|
368
|
+
outDir: ctx.client.buildDir,
|
|
368
369
|
},
|
|
369
370
|
});
|
|
370
371
|
}
|
|
@@ -413,15 +414,21 @@ async function injectBundleRender(ctx, pluginName) {
|
|
|
413
414
|
await fs$1.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
414
415
|
}
|
|
415
416
|
async function runStencil(ctx) {
|
|
416
|
-
|
|
417
|
-
const logger = createNodeLogger({ process });
|
|
418
|
-
const sys = createNodeSys({ process });
|
|
417
|
+
var _a, _b;
|
|
418
|
+
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || createNodeLogger({ process });
|
|
419
|
+
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || createNodeSys({ process });
|
|
420
|
+
const devMode = !!ctx.dev;
|
|
419
421
|
const validated = await loadConfig({
|
|
422
|
+
initTsConfig: true,
|
|
420
423
|
logger,
|
|
421
424
|
sys,
|
|
422
425
|
config: {
|
|
426
|
+
devMode,
|
|
427
|
+
rootDir: ctx.client.buildDir,
|
|
428
|
+
configPath: path$1.resolve(ctx.client.buildDir, "stencil.config.ts"),
|
|
429
|
+
tsconfig: path$1.resolve(ctx.client.buildDir, "tsconfig.json"),
|
|
423
430
|
namespace: "embeddable-wrapper",
|
|
424
|
-
srcDir: "component",
|
|
431
|
+
srcDir: path$1.resolve(ctx.client.buildDir, "component"),
|
|
425
432
|
outputTargets: [
|
|
426
433
|
{
|
|
427
434
|
type: "dist",
|
|
@@ -432,6 +439,7 @@ async function runStencil(ctx) {
|
|
|
432
439
|
const compiler = await createCompiler(validated.config);
|
|
433
440
|
await compiler.build();
|
|
434
441
|
await compiler.destroy();
|
|
442
|
+
process.chdir(ctx.client.rootDir);
|
|
435
443
|
}
|
|
436
444
|
async function generateSourceMap(ctx, pluginName) {
|
|
437
445
|
const componentBuildDir = path$1.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
@@ -4496,7 +4504,7 @@ const checkNodeVersion$1 = () => {
|
|
|
4496
4504
|
throw new Error(`Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`);
|
|
4497
4505
|
}
|
|
4498
4506
|
};
|
|
4499
|
-
var validate = async (ctx) => {
|
|
4507
|
+
var validate = async (ctx, exitIfInvalid = true) => {
|
|
4500
4508
|
checkNodeVersion$1();
|
|
4501
4509
|
const ora = (await import('ora')).default;
|
|
4502
4510
|
const spinnerValidate = ora("data model validation...").start();
|
|
@@ -4505,9 +4513,12 @@ var validate = async (ctx) => {
|
|
|
4505
4513
|
if (dataModelErrors.length) {
|
|
4506
4514
|
spinnerValidate.fail("One or more cube.yaml files are invalid:");
|
|
4507
4515
|
dataModelErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
4508
|
-
|
|
4516
|
+
if (exitIfInvalid) {
|
|
4517
|
+
process.exit(1);
|
|
4518
|
+
}
|
|
4509
4519
|
}
|
|
4510
4520
|
spinnerValidate.succeed("data model validation completed");
|
|
4521
|
+
return dataModelErrors.length === 0;
|
|
4511
4522
|
};
|
|
4512
4523
|
async function dataModelsValidation(filesList) {
|
|
4513
4524
|
const errors = [];
|
|
@@ -16790,7 +16801,7 @@ sourceMap.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
|
|
|
16790
16801
|
sourceMap.SourceNode = sourceNode.SourceNode;
|
|
16791
16802
|
|
|
16792
16803
|
var SourceMapConsumer = sourceMap.SourceMapConsumer;
|
|
16793
|
-
var path =
|
|
16804
|
+
var path = path__default;
|
|
16794
16805
|
var fs = require$$2$1;
|
|
16795
16806
|
|
|
16796
16807
|
/**
|
|
@@ -19057,7 +19068,7 @@ var setupCustomJSON = function(JSON) {
|
|
|
19057
19068
|
var json3 = setupCustomJSON;
|
|
19058
19069
|
|
|
19059
19070
|
var util = require$$4$1;
|
|
19060
|
-
var os = require$$1
|
|
19071
|
+
var os = require$$1;
|
|
19061
19072
|
|
|
19062
19073
|
var packageJson = require$$2;
|
|
19063
19074
|
var Client = rollbar$1;
|
|
@@ -19833,7 +19844,7 @@ const reportErrorToRollbar = async (error) => {
|
|
|
19833
19844
|
|
|
19834
19845
|
const getSdkPackageVersionInfo = (config) => {
|
|
19835
19846
|
try {
|
|
19836
|
-
const packageJsonFilePath =
|
|
19847
|
+
const packageJsonFilePath = path$2.resolve(
|
|
19837
19848
|
config.client.rootDir,
|
|
19838
19849
|
"package.json",
|
|
19839
19850
|
);
|
|
@@ -19877,11 +19888,11 @@ async function getUserData() {
|
|
|
19877
19888
|
}
|
|
19878
19889
|
}
|
|
19879
19890
|
|
|
19880
|
-
const oraP$
|
|
19881
|
-
let ora$
|
|
19891
|
+
const oraP$3 = import('ora');
|
|
19892
|
+
let ora$2;
|
|
19882
19893
|
const checkNodeVersion = async () => {
|
|
19883
|
-
ora$
|
|
19884
|
-
ora$
|
|
19894
|
+
ora$2 = (await oraP$3).default;
|
|
19895
|
+
ora$2("checking node version...");
|
|
19885
19896
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
19886
19897
|
const engines = require("../package.json").engines.node;
|
|
19887
19898
|
const [minMajor, minMinor] = engines
|
|
@@ -19889,7 +19900,7 @@ const checkNodeVersion = async () => {
|
|
|
19889
19900
|
.map((v) => v.replace(/[^\d]/g, ""))
|
|
19890
19901
|
.map(Number);
|
|
19891
19902
|
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
19892
|
-
ora$
|
|
19903
|
+
ora$2({
|
|
19893
19904
|
text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
|
|
19894
19905
|
color: "red",
|
|
19895
19906
|
}).fail();
|
|
@@ -19917,16 +19928,17 @@ var build = async () => {
|
|
|
19917
19928
|
catch (error) {
|
|
19918
19929
|
await reportErrorToRollbar(error);
|
|
19919
19930
|
console.log(error);
|
|
19920
|
-
|
|
19931
|
+
process.exit(1);
|
|
19921
19932
|
}
|
|
19922
19933
|
};
|
|
19923
19934
|
|
|
19924
|
-
const oraP$
|
|
19935
|
+
const oraP$2 = import('ora');
|
|
19925
19936
|
const openP = import('open');
|
|
19926
19937
|
var login = async () => {
|
|
19927
19938
|
var _a;
|
|
19939
|
+
const ora = (await oraP$2).default;
|
|
19940
|
+
const authenticationSpinner = ora("waiting for code verification...").start();
|
|
19928
19941
|
try {
|
|
19929
|
-
const ora = (await oraP$1).default;
|
|
19930
19942
|
const open = (await openP).default;
|
|
19931
19943
|
const config = await provideConfig();
|
|
19932
19944
|
await resolveFiles();
|
|
@@ -19940,7 +19952,6 @@ var login = async () => {
|
|
|
19940
19952
|
device_code: deviceCodeResponse.data["device_code"],
|
|
19941
19953
|
client_id: config.authClientId,
|
|
19942
19954
|
};
|
|
19943
|
-
const authenticationSpinner = ora("waiting for code verification...").start();
|
|
19944
19955
|
await open(deviceCodeResponse.data["verification_uri_complete"]);
|
|
19945
19956
|
/**
|
|
19946
19957
|
* This is a recommended way to poll, since it take some time for a user to enter a `user_code` in a browser.
|
|
@@ -19963,9 +19974,10 @@ var login = async () => {
|
|
|
19963
19974
|
}
|
|
19964
19975
|
}
|
|
19965
19976
|
catch (error) {
|
|
19977
|
+
authenticationSpinner.fail("authentication failed. please try again.");
|
|
19966
19978
|
await reportErrorToRollbar(error);
|
|
19967
19979
|
console.log(error);
|
|
19968
|
-
|
|
19980
|
+
process.exit(1);
|
|
19969
19981
|
}
|
|
19970
19982
|
};
|
|
19971
19983
|
async function getToken() {
|
|
@@ -19997,22 +20009,22 @@ async function resolveFiles() {
|
|
|
19997
20009
|
}
|
|
19998
20010
|
}
|
|
19999
20011
|
|
|
20000
|
-
const oraP = import('ora');
|
|
20012
|
+
const oraP$1 = import('ora');
|
|
20001
20013
|
const inquirerSelect = import('@inquirer/select');
|
|
20002
20014
|
const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
20003
|
-
let ora;
|
|
20015
|
+
let ora$1;
|
|
20004
20016
|
var push = async () => {
|
|
20005
20017
|
try {
|
|
20006
20018
|
checkNodeVersion();
|
|
20007
|
-
ora = (await oraP).default;
|
|
20019
|
+
ora$1 = (await oraP$1).default;
|
|
20008
20020
|
const config = await provideConfig();
|
|
20009
20021
|
const token = await verify(config);
|
|
20010
20022
|
const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
|
|
20011
|
-
const spinnerArchive = ora("archivation...").start();
|
|
20023
|
+
const spinnerArchive = ora$1("archivation...").start();
|
|
20012
20024
|
const filesList = await findFiles(config.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
20013
20025
|
await archive(config, filesList);
|
|
20014
20026
|
spinnerArchive.succeed("archivation competed");
|
|
20015
|
-
const spinnerPushing = ora(`publishing to ${workspaceName} using ${config.pushBaseUrl}...`).start();
|
|
20027
|
+
const spinnerPushing = ora$1(`publishing to ${workspaceName} using ${config.pushBaseUrl}...`).start();
|
|
20016
20028
|
await sendBuild(config, { workspaceId, token });
|
|
20017
20029
|
spinnerPushing.succeed(`published to ${workspaceName} using ${config.pushBaseUrl}`);
|
|
20018
20030
|
}
|
|
@@ -20023,7 +20035,7 @@ var push = async () => {
|
|
|
20023
20035
|
}
|
|
20024
20036
|
};
|
|
20025
20037
|
async function selectWorkspace(ctx, token) {
|
|
20026
|
-
const workspaceSpinner = ora({
|
|
20038
|
+
const workspaceSpinner = ora$1({
|
|
20027
20039
|
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20028
20040
|
color: "green",
|
|
20029
20041
|
discardStdin: false,
|
|
@@ -20067,13 +20079,15 @@ async function verify(ctx) {
|
|
|
20067
20079
|
}
|
|
20068
20080
|
return token;
|
|
20069
20081
|
}
|
|
20070
|
-
async function archive(ctx, yamlFiles) {
|
|
20082
|
+
async function archive(ctx, yamlFiles, includeBuild = true) {
|
|
20071
20083
|
const output = fsSync.createWriteStream(ctx.client.archiveFile);
|
|
20072
20084
|
const _archiver = archiver.create("zip", {
|
|
20073
20085
|
zlib: { level: 9 },
|
|
20074
20086
|
});
|
|
20075
20087
|
_archiver.pipe(output);
|
|
20076
|
-
|
|
20088
|
+
if (includeBuild) {
|
|
20089
|
+
_archiver.directory(ctx.client.buildDir, false);
|
|
20090
|
+
}
|
|
20077
20091
|
for (const fileData of yamlFiles) {
|
|
20078
20092
|
_archiver.file(fileData[1], { name: `${fileData[0]}.cube.yaml` });
|
|
20079
20093
|
}
|
|
@@ -20099,13 +20113,14 @@ async function sendBuild(ctx, { workspaceId, token }) {
|
|
|
20099
20113
|
await fs$1.rm(ctx.client.archiveFile);
|
|
20100
20114
|
}
|
|
20101
20115
|
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20116
|
+
var _a;
|
|
20102
20117
|
try {
|
|
20103
20118
|
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20104
20119
|
headers: {
|
|
20105
20120
|
Authorization: `Bearer ${token}`,
|
|
20106
20121
|
},
|
|
20107
20122
|
});
|
|
20108
|
-
return response.data;
|
|
20123
|
+
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20109
20124
|
}
|
|
20110
20125
|
catch (e) {
|
|
20111
20126
|
if (e.response.status === 401) {
|
|
@@ -20118,7 +20133,171 @@ async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
|
20118
20133
|
}
|
|
20119
20134
|
}
|
|
20120
20135
|
|
|
20121
|
-
|
|
20136
|
+
const oraP = import('ora');
|
|
20137
|
+
let wss;
|
|
20138
|
+
let changedFiles = [];
|
|
20139
|
+
let browserWindow = null;
|
|
20140
|
+
let ora;
|
|
20141
|
+
let previewWorkspace;
|
|
20142
|
+
const SERVER_PORT = 8926;
|
|
20143
|
+
const buildWebComponent = async (config) => {
|
|
20144
|
+
await generate(config, "sdk-react");
|
|
20145
|
+
};
|
|
20146
|
+
var dev = async () => {
|
|
20147
|
+
const http = require("http");
|
|
20148
|
+
ora = (await oraP).default;
|
|
20149
|
+
process.on("warning", (e) => console.warn(e.stack));
|
|
20150
|
+
const logger = createNodeLogger({ process });
|
|
20151
|
+
const sys = createNodeSys({ process });
|
|
20152
|
+
const config = {
|
|
20153
|
+
dev: {
|
|
20154
|
+
watch: true,
|
|
20155
|
+
logger,
|
|
20156
|
+
sys,
|
|
20157
|
+
},
|
|
20158
|
+
...(await provideConfig()),
|
|
20159
|
+
};
|
|
20160
|
+
await prepare(config);
|
|
20161
|
+
const finalhandler = require("finalhandler");
|
|
20162
|
+
const serveStatic = require("serve-static");
|
|
20163
|
+
const serve = serveStatic(config.client.buildDir);
|
|
20164
|
+
const workspacePreparation = ora("Preparing workspace...").start();
|
|
20165
|
+
previewWorkspace = await getPreviewWorkspace(config);
|
|
20166
|
+
workspacePreparation.succeed("Workspace is ready");
|
|
20167
|
+
const server = http.createServer((request, res) => {
|
|
20168
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
20169
|
+
const done = finalhandler(request, res);
|
|
20170
|
+
serve(request, res, done);
|
|
20171
|
+
});
|
|
20172
|
+
wss = new WebSocketServer({ server });
|
|
20173
|
+
server.listen(SERVER_PORT, async () => {
|
|
20174
|
+
const watchers = [];
|
|
20175
|
+
if (sys === null || sys === void 0 ? void 0 : sys.onProcessInterrupt) {
|
|
20176
|
+
sys.onProcessInterrupt(async () => await onClose(server, sys, watchers, config));
|
|
20177
|
+
}
|
|
20178
|
+
await sendDataModels(config);
|
|
20179
|
+
for (const getPlugin of config.plugins) {
|
|
20180
|
+
const plugin = getPlugin();
|
|
20181
|
+
await plugin.validate(config);
|
|
20182
|
+
const watcher = await plugin.build(config);
|
|
20183
|
+
await configureWatcher(watcher, config);
|
|
20184
|
+
watchers.push(watcher);
|
|
20185
|
+
}
|
|
20186
|
+
const modelWatcher = dataModelWatcher(config);
|
|
20187
|
+
watchers.push(modelWatcher);
|
|
20188
|
+
});
|
|
20189
|
+
};
|
|
20190
|
+
const configureWatcher = async (watcher, ctx) => {
|
|
20191
|
+
watcher.on("change", (path) => {
|
|
20192
|
+
changedFiles.push(path);
|
|
20193
|
+
});
|
|
20194
|
+
watcher.on("event", async (e) => {
|
|
20195
|
+
var _a;
|
|
20196
|
+
if (e.code === "BUNDLE_START") {
|
|
20197
|
+
await onBuildStart(ctx);
|
|
20198
|
+
}
|
|
20199
|
+
if (e.code === "BUNDLE_END") {
|
|
20200
|
+
await onBundleBuildEnd(ctx);
|
|
20201
|
+
changedFiles = [];
|
|
20202
|
+
}
|
|
20203
|
+
if (e.code === "ERROR") {
|
|
20204
|
+
sendMessage("componentsBuildError", { error: (_a = e.error) === null || _a === void 0 ? void 0 : _a.message });
|
|
20205
|
+
changedFiles = [];
|
|
20206
|
+
}
|
|
20207
|
+
});
|
|
20208
|
+
};
|
|
20209
|
+
const sendMessage = (type, meta = {}) => {
|
|
20210
|
+
wss.clients.forEach((ws) => {
|
|
20211
|
+
ws.send(JSON.stringify({ type, ...meta }));
|
|
20212
|
+
});
|
|
20213
|
+
};
|
|
20214
|
+
const typeFilesFilter = (f) => EMB_OPTIONS_FILE_REGEX.test(f) || EMB_TYPE_FILE_REGEX.test(f);
|
|
20215
|
+
const onlyTypesChanged = () => changedFiles.length !== 0 &&
|
|
20216
|
+
changedFiles.filter(typeFilesFilter).length === changedFiles.length;
|
|
20217
|
+
const isTypeFileChanged = () => changedFiles.findIndex(typeFilesFilter) >= 0;
|
|
20218
|
+
const onBuildStart = async (ctx) => {
|
|
20219
|
+
if (changedFiles.length === 0 || isTypeFileChanged()) {
|
|
20220
|
+
await buildTypes(ctx);
|
|
20221
|
+
}
|
|
20222
|
+
sendMessage("componentsBuildStart", { changedFiles });
|
|
20223
|
+
};
|
|
20224
|
+
const onBundleBuildEnd = async (ctx) => {
|
|
20225
|
+
if (!onlyTypesChanged() || changedFiles.length === 0) {
|
|
20226
|
+
await buildWebComponent(ctx);
|
|
20227
|
+
}
|
|
20228
|
+
if (browserWindow == null) {
|
|
20229
|
+
const open = (await import('open')).default;
|
|
20230
|
+
browserWindow = await open(`${ctx.previewBaseUrl}/workspace/${previewWorkspace}`);
|
|
20231
|
+
}
|
|
20232
|
+
else {
|
|
20233
|
+
sendMessage("componentsBuildSuccess");
|
|
20234
|
+
}
|
|
20235
|
+
};
|
|
20236
|
+
const dataModelWatcher = (ctx) => {
|
|
20237
|
+
const fsWatcher = chokidar.watch([path$2.resolve(ctx.client.srcDir, "**/*.cube.{yaml,yml}")], {
|
|
20238
|
+
ignoreInitial: true,
|
|
20239
|
+
});
|
|
20240
|
+
fsWatcher.on("all", async () => {
|
|
20241
|
+
await sendDataModels(ctx);
|
|
20242
|
+
});
|
|
20243
|
+
return fsWatcher;
|
|
20244
|
+
};
|
|
20245
|
+
const sendDataModels = async (ctx) => {
|
|
20246
|
+
sendMessage("dataModelsUpdateStart");
|
|
20247
|
+
const isValid = await validate(ctx, false);
|
|
20248
|
+
if (isValid) {
|
|
20249
|
+
const token = await getToken();
|
|
20250
|
+
const sending = ora("synchronising data models...").start();
|
|
20251
|
+
const filesList = await findFiles(ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
20252
|
+
await archive(ctx, filesList, false);
|
|
20253
|
+
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
20254
|
+
sending.succeed(`data models synchronized`);
|
|
20255
|
+
sendMessage("dataModelsUpdateSuccess");
|
|
20256
|
+
}
|
|
20257
|
+
else {
|
|
20258
|
+
sendMessage("dataModelsUpdateError");
|
|
20259
|
+
}
|
|
20260
|
+
};
|
|
20261
|
+
const onClose = async (server, sys, watchers, config) => {
|
|
20262
|
+
server.close();
|
|
20263
|
+
wss.close();
|
|
20264
|
+
browserWindow === null || browserWindow === void 0 ? void 0 : browserWindow.unref();
|
|
20265
|
+
for (const watcher of watchers) {
|
|
20266
|
+
if (watcher.close) {
|
|
20267
|
+
await watcher.close();
|
|
20268
|
+
}
|
|
20269
|
+
}
|
|
20270
|
+
for (const getPlugin of config.plugins) {
|
|
20271
|
+
const plugin = getPlugin();
|
|
20272
|
+
await plugin.cleanup(config);
|
|
20273
|
+
}
|
|
20274
|
+
await removeIfExists(config);
|
|
20275
|
+
await sys.destroy();
|
|
20276
|
+
process.exit(0);
|
|
20277
|
+
};
|
|
20278
|
+
const getPreviewWorkspace = async (ctx) => {
|
|
20279
|
+
const token = await getToken();
|
|
20280
|
+
try {
|
|
20281
|
+
const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
|
|
20282
|
+
headers: {
|
|
20283
|
+
Authorization: `Bearer ${token}`,
|
|
20284
|
+
},
|
|
20285
|
+
});
|
|
20286
|
+
return response.data;
|
|
20287
|
+
}
|
|
20288
|
+
catch (e) {
|
|
20289
|
+
if (e.response.status === 401) {
|
|
20290
|
+
// login and retry
|
|
20291
|
+
await login();
|
|
20292
|
+
return await getPreviewWorkspace(ctx);
|
|
20293
|
+
}
|
|
20294
|
+
else {
|
|
20295
|
+
throw e;
|
|
20296
|
+
}
|
|
20297
|
+
}
|
|
20298
|
+
};
|
|
20299
|
+
|
|
20300
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, }) => {
|
|
20122
20301
|
const coreRoot = path$1.resolve(__dirname, "..");
|
|
20123
20302
|
const clientRoot = process.cwd();
|
|
20124
20303
|
return {
|
|
@@ -20144,6 +20323,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
20144
20323
|
},
|
|
20145
20324
|
pushBaseUrl: pushBaseUrl !== null && pushBaseUrl !== void 0 ? pushBaseUrl : "https://api.embeddable.com",
|
|
20146
20325
|
audienceUrl: audienceUrl !== null && audienceUrl !== void 0 ? audienceUrl : "https://auth.embeddable.com",
|
|
20326
|
+
previewBaseUrl: previewBaseUrl !== null && previewBaseUrl !== void 0 ? previewBaseUrl : "https://app.embeddable.com",
|
|
20147
20327
|
authDomain: authDomain !== null && authDomain !== void 0 ? authDomain : "auth.embeddable.com",
|
|
20148
20328
|
authClientId: authClientId !== null && authClientId !== void 0 ? authClientId : "dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V",
|
|
20149
20329
|
applicationEnvironment: applicationEnvironment !== null && applicationEnvironment !== void 0 ? applicationEnvironment : "production",
|
|
@@ -20552,5 +20732,5 @@ var fileFromPath$1 = /*#__PURE__*/Object.freeze({
|
|
|
20552
20732
|
fileFromPath: fileFromPath
|
|
20553
20733
|
});
|
|
20554
20734
|
|
|
20555
|
-
export { build, defineConfig, login, push };
|
|
20735
|
+
export { build, defineConfig, dev, login, push };
|
|
20556
20736
|
//# sourceMappingURL=index.esm.js.map
|