@embeddable.com/sdk-core 3.4.2 → 3.5.1
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 +1 -0
- package/lib/index.esm.js +69 -24
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +67 -22
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cleanup.ts +1 -0
- package/src/defineConfig.ts +2 -1
- package/src/defineConfit.test.ts +77 -0
- package/src/dev.ts +2 -5
- package/src/generate.test.ts +115 -0
- package/src/generate.ts +44 -2
- package/src/rollbar.mjs +40 -23
- package/src/rollbar.test.ts +87 -0
- package/templates/component.tsx.template +1 -1
package/lib/defineConfig.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ declare const _default: ({ plugins, pushBaseUrl, audienceUrl, authDomain, authCl
|
|
|
32
32
|
stencilBuild: string;
|
|
33
33
|
archiveFile: string;
|
|
34
34
|
errorFallbackComponent: string | undefined;
|
|
35
|
+
bundleHash: undefined;
|
|
35
36
|
};
|
|
36
37
|
outputOptions: {
|
|
37
38
|
typesEntryPointFilename: string;
|
package/lib/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs$1 from 'node:fs/promises';
|
|
2
|
-
import
|
|
2
|
+
import { readdir, lstat } from 'node:fs/promises';
|
|
3
3
|
import * as path$1 from 'node:path';
|
|
4
4
|
import path__default, { join } from 'node:path';
|
|
5
5
|
import * as vite from 'vite';
|
|
@@ -12,14 +12,14 @@ import { loadConfig, createCompiler } from '@stencil/core/compiler';
|
|
|
12
12
|
import * as os$1 from 'node:os';
|
|
13
13
|
import * as YAML from 'yaml';
|
|
14
14
|
import * as url$2 from 'node:url';
|
|
15
|
-
import * as path$2 from 'path';
|
|
16
|
-
import path__default$1, { basename } from 'path';
|
|
17
15
|
import require$$4$1 from 'util';
|
|
18
16
|
import require$$1 from 'os';
|
|
19
17
|
import require$$3 from 'http';
|
|
20
18
|
import require$$4 from 'https';
|
|
21
19
|
import require$$0$1 from 'url';
|
|
22
20
|
import require$$2$1, { createReadStream } from 'fs';
|
|
21
|
+
import * as path$2 from 'path';
|
|
22
|
+
import path__default$1, { basename } from 'path';
|
|
23
23
|
import axios from 'axios';
|
|
24
24
|
import * as archiver from 'archiver';
|
|
25
25
|
import { WebSocketServer } from 'ws';
|
|
@@ -431,6 +431,8 @@ async function createComponentDir(dir) {
|
|
|
431
431
|
const sorcery = require("sorcery");
|
|
432
432
|
const STYLE_IMPORTS_TOKEN = "{{STYLES_IMPORT}}";
|
|
433
433
|
const RENDER_IMPORT_TOKEN = "{{RENDER_IMPORT}}";
|
|
434
|
+
// stencil doesn't support dynamic component tag name, so we need to replace it manually
|
|
435
|
+
const COMPONENT_TAG_TOKEN = "replace-this-with-component-name";
|
|
434
436
|
var generate = async (ctx, pluginName) => {
|
|
435
437
|
await injectCSS(ctx, pluginName);
|
|
436
438
|
await injectBundleRender(ctx, pluginName);
|
|
@@ -449,9 +451,30 @@ async function injectCSS(ctx, pluginName) {
|
|
|
449
451
|
}
|
|
450
452
|
async function injectBundleRender(ctx, pluginName) {
|
|
451
453
|
const importStr = `import render from '../${ctx[pluginName].outputOptions.buildName}/${ctx[pluginName].outputOptions.fileName}';`;
|
|
452
|
-
|
|
454
|
+
let content = await fs$1.readFile(path$1.resolve(ctx.core.templatesDir, "component.tsx.template"), "utf8");
|
|
455
|
+
if (!!ctx.dev) {
|
|
456
|
+
content = content.replace(COMPONENT_TAG_TOKEN, "embeddable-component");
|
|
457
|
+
}
|
|
453
458
|
await fs$1.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
454
459
|
}
|
|
460
|
+
async function addComponentTagName(filePath, bundleHash) {
|
|
461
|
+
// find entry file with a name *.entry.js
|
|
462
|
+
const entryFiles = await findFiles(path$1.dirname(filePath), /.*\.entry\.js/);
|
|
463
|
+
if (!entryFiles.length) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const entryFileName = entryFiles[0];
|
|
467
|
+
const [entryFileContent, fileContent] = await Promise.all([
|
|
468
|
+
fs$1.readFile(entryFileName[1], "utf8"),
|
|
469
|
+
fs$1.readFile(filePath, "utf8"),
|
|
470
|
+
]);
|
|
471
|
+
const newFileContent = fileContent.replace(COMPONENT_TAG_TOKEN, `embeddable-component-${bundleHash}`);
|
|
472
|
+
const newEntryFileContent = entryFileContent.replace(COMPONENT_TAG_TOKEN.replaceAll("-", "_"), `embeddable_component_${bundleHash}`);
|
|
473
|
+
await Promise.all([
|
|
474
|
+
fs$1.writeFile(filePath, newFileContent),
|
|
475
|
+
fs$1.writeFile(entryFileName[1], newEntryFileContent),
|
|
476
|
+
]);
|
|
477
|
+
}
|
|
455
478
|
async function runStencil(ctx) {
|
|
456
479
|
var _a, _b, _c;
|
|
457
480
|
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || createNodeLogger({ process });
|
|
@@ -485,6 +508,8 @@ async function runStencil(ctx) {
|
|
|
485
508
|
const entryFileContent = await fs$1.readFile(entryFilePath, "utf8");
|
|
486
509
|
const fileHash = getContentHash(entryFileContent);
|
|
487
510
|
fileName = `embeddable-wrapper.esm-${fileHash}.js`;
|
|
511
|
+
ctx.client.bundleHash = fileHash;
|
|
512
|
+
await addComponentTagName(entryFilePath, ctx.client.bundleHash);
|
|
488
513
|
}
|
|
489
514
|
await fs$1.rename(entryFilePath, path$1.resolve(ctx.client.stencilBuild, fileName));
|
|
490
515
|
await compiler.destroy();
|
|
@@ -643,6 +668,7 @@ async function createManifest({ ctx, typesFileName, metaFileName, editorsMetaFil
|
|
|
643
668
|
metadata: {
|
|
644
669
|
nodeVersion: process.version,
|
|
645
670
|
platform: process.platform,
|
|
671
|
+
bundleHash: ctx.client.bundleHash,
|
|
646
672
|
sdkVersions,
|
|
647
673
|
packageManager,
|
|
648
674
|
packageManagerVersion,
|
|
@@ -20327,29 +20353,31 @@ const reportErrorToRollbar = async (error) => {
|
|
|
20327
20353
|
|
|
20328
20354
|
const userData = await getUserData();
|
|
20329
20355
|
|
|
20356
|
+
const sdkPackageVersion = await getSdkPackageVersionInfo(config);
|
|
20357
|
+
|
|
20330
20358
|
rollbar.configure({
|
|
20331
20359
|
payload: {
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
|
|
20335
|
-
}
|
|
20360
|
+
person: {
|
|
20361
|
+
id: userData.globalUserId,
|
|
20362
|
+
},
|
|
20363
|
+
},
|
|
20336
20364
|
});
|
|
20337
20365
|
|
|
20338
|
-
rollbar.error(error, {
|
|
20366
|
+
return rollbar.error(error, {
|
|
20339
20367
|
custom: {
|
|
20340
|
-
code_version:
|
|
20368
|
+
code_version: sdkPackageVersion,
|
|
20341
20369
|
},
|
|
20342
20370
|
});
|
|
20343
20371
|
};
|
|
20344
20372
|
|
|
20345
|
-
const getSdkPackageVersionInfo = (config) => {
|
|
20373
|
+
const getSdkPackageVersionInfo = async (config) => {
|
|
20346
20374
|
try {
|
|
20347
|
-
const packageJsonFilePath = path$
|
|
20375
|
+
const packageJsonFilePath = path$1.resolve(
|
|
20348
20376
|
config.client.rootDir,
|
|
20349
20377
|
"package.json",
|
|
20350
20378
|
);
|
|
20351
20379
|
|
|
20352
|
-
const packageJson =
|
|
20380
|
+
const packageJson = await import(packageJsonFilePath);
|
|
20353
20381
|
const devDependencies = packageJson.devDependencies;
|
|
20354
20382
|
const dependencies = packageJson.dependencies;
|
|
20355
20383
|
|
|
@@ -20358,10 +20386,26 @@ const getSdkPackageVersionInfo = (config) => {
|
|
|
20358
20386
|
};
|
|
20359
20387
|
|
|
20360
20388
|
const packageVersionInfo = {
|
|
20361
|
-
core: getDependencyVersion(
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20389
|
+
core: getDependencyVersion(
|
|
20390
|
+
"@embeddable.com/core",
|
|
20391
|
+
dependencies,
|
|
20392
|
+
devDependencies,
|
|
20393
|
+
),
|
|
20394
|
+
sdk_core: getDependencyVersion(
|
|
20395
|
+
"@embeddable.com/sdk-core",
|
|
20396
|
+
dependencies,
|
|
20397
|
+
devDependencies,
|
|
20398
|
+
),
|
|
20399
|
+
react: getDependencyVersion(
|
|
20400
|
+
"@embeddable.com/react",
|
|
20401
|
+
dependencies,
|
|
20402
|
+
devDependencies,
|
|
20403
|
+
),
|
|
20404
|
+
sdk_react: getDependencyVersion(
|
|
20405
|
+
"@embeddable.com/sdk-react",
|
|
20406
|
+
dependencies,
|
|
20407
|
+
devDependencies,
|
|
20408
|
+
),
|
|
20365
20409
|
};
|
|
20366
20410
|
|
|
20367
20411
|
return JSON.stringify(packageVersionInfo);
|
|
@@ -20373,9 +20417,9 @@ const getSdkPackageVersionInfo = (config) => {
|
|
|
20373
20417
|
|
|
20374
20418
|
async function getUserData() {
|
|
20375
20419
|
try {
|
|
20376
|
-
const token = await
|
|
20377
|
-
|
|
20378
|
-
|
|
20420
|
+
const token = await fs$1
|
|
20421
|
+
.readFile(CREDENTIALS_FILE)
|
|
20422
|
+
.then((data) => JSON.parse(data.toString()));
|
|
20379
20423
|
|
|
20380
20424
|
const decodedToken = jwtDecode(token.access_token);
|
|
20381
20425
|
|
|
@@ -20825,7 +20869,7 @@ const onBundleBuildEnd = async (ctx) => {
|
|
|
20825
20869
|
}
|
|
20826
20870
|
};
|
|
20827
20871
|
const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
20828
|
-
const fsWatcher = chokidar.watch([path$2.resolve(ctx.client.
|
|
20872
|
+
const fsWatcher = chokidar.watch([path$2.resolve(ctx.client.modelsSrc, "**/*.{cube,sc}.{yaml,yml,js}")], {
|
|
20829
20873
|
ignoreInitial: true,
|
|
20830
20874
|
});
|
|
20831
20875
|
fsWatcher.on("all", async () => {
|
|
@@ -20839,7 +20883,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx) => {
|
|
|
20839
20883
|
if (isValid) {
|
|
20840
20884
|
const token = await getToken();
|
|
20841
20885
|
const sending = ora("Synchronising data models and/or security contexts...").start();
|
|
20842
|
-
const filesList = await findFiles(ctx.client.modelsSrc
|
|
20886
|
+
const filesList = await findFiles(ctx.client.modelsSrc, YAML_OR_JS_FILES);
|
|
20843
20887
|
await archive(ctx, filesList, false);
|
|
20844
20888
|
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
20845
20889
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
@@ -20891,7 +20935,7 @@ const getPreviewWorkspace = async (ctx) => {
|
|
|
20891
20935
|
}
|
|
20892
20936
|
};
|
|
20893
20937
|
|
|
20894
|
-
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc, componentsSrc = "src", }) => {
|
|
20938
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", componentsSrc = "src", }) => {
|
|
20895
20939
|
const coreRoot = path$1.resolve(__dirname, "..");
|
|
20896
20940
|
const clientRoot = process.cwd();
|
|
20897
20941
|
if (!path$1.isAbsolute(componentsSrc)) {
|
|
@@ -20924,6 +20968,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
20924
20968
|
errorFallbackComponent: errorFallbackComponent
|
|
20925
20969
|
? path$1.resolve(clientRoot, errorFallbackComponent)
|
|
20926
20970
|
: undefined,
|
|
20971
|
+
bundleHash: undefined, // This will be set by the build process
|
|
20927
20972
|
},
|
|
20928
20973
|
outputOptions: {
|
|
20929
20974
|
typesEntryPointFilename: "embeddable-types-entry-point.js",
|
|
@@ -20940,7 +20985,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
20940
20985
|
};
|
|
20941
20986
|
|
|
20942
20987
|
var name = "@embeddable.com/sdk-core";
|
|
20943
|
-
var version = "3.
|
|
20988
|
+
var version = "3.5.1";
|
|
20944
20989
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
20945
20990
|
var keywords = [
|
|
20946
20991
|
"embeddable",
|