@embeddable.com/sdk-core 3.13.6 → 3.14.0-next.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/buildGlobalHooks.d.ts +7 -0
- package/lib/buildPackage.d.ts +2 -0
- package/lib/defineConfig.d.ts +42 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +469 -285
- package/lib/index.esm.js.map +1 -1
- package/lib/push.d.ts +1 -1
- package/loader/entryPoint.js +9 -1
- package/loader/entryPoint.test.js +1 -0
- package/package.json +4 -3
- package/src/build.test.ts +6 -0
- package/src/build.ts +2 -0
- package/src/buildGlobalHooks.int.test.ts +215 -0
- package/src/buildGlobalHooks.ts +252 -0
- package/src/buildGlobalHooks.unit.test.ts +273 -0
- package/src/buildPackage.test.ts +167 -0
- package/src/buildPackage.ts +53 -0
- package/src/buildTypes.test.ts +108 -6
- package/src/buildTypes.ts +41 -2
- package/src/cleanup.test.ts +8 -1
- package/src/cleanup.ts +32 -1
- package/src/defineConfig.test.ts +3 -0
- package/src/defineConfig.ts +29 -3
- package/src/dev.test.ts +13 -1
- package/src/dev.ts +37 -1
- package/src/generate.test.ts +2 -0
- package/src/generate.ts +24 -13
- package/src/index.ts +2 -1
- package/src/push.ts +17 -17
- package/src/workspaceUtils.ts +5 -1
- package/templates/component.tsx.template +3 -1
- package/templates/embeddableThemeHook.js.template +28 -0
- package/lib/index.js +0 -22492
- package/lib/index.js.map +0 -1
package/lib/index.esm.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
|
-
import { readdir, lstat } from 'node:fs/promises';
|
|
3
|
-
import * as path from 'node:path';
|
|
2
|
+
import { readdir, lstat, readFile } from 'node:fs/promises';
|
|
3
|
+
import * as path$1 from 'node:path';
|
|
4
4
|
import path__default, { join } from 'node:path';
|
|
5
5
|
import * as vite from 'vite';
|
|
6
6
|
import ora from 'ora';
|
|
7
7
|
import 'node:child_process';
|
|
8
8
|
import * as crypto from 'node:crypto';
|
|
9
|
-
import * as
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import path__default$1, { basename } from 'path';
|
|
11
|
+
import fg from 'fast-glob';
|
|
12
|
+
import * as fsSync from 'node:fs';
|
|
10
13
|
import { existsSync } from 'node:fs';
|
|
11
14
|
import { createNodeLogger, createNodeSys } from '@stencil/core/sys/node';
|
|
12
15
|
import { loadConfig, createCompiler } from '@stencil/core/compiler';
|
|
@@ -20,8 +23,6 @@ import require$$3 from 'http';
|
|
|
20
23
|
import require$$4 from 'https';
|
|
21
24
|
import require$$0$1 from 'url';
|
|
22
25
|
import require$$2$1, { createReadStream } from 'fs';
|
|
23
|
-
import * as path$1 from 'path';
|
|
24
|
-
import path__default$1, { basename } from 'path';
|
|
25
26
|
import axios from 'axios';
|
|
26
27
|
import archiver from 'archiver';
|
|
27
28
|
import { select } from '@inquirer/prompts';
|
|
@@ -29,7 +30,6 @@ import * as http from 'node:http';
|
|
|
29
30
|
import { WebSocketServer } from 'ws';
|
|
30
31
|
import * as chokidar from 'chokidar';
|
|
31
32
|
import minimist from 'minimist';
|
|
32
|
-
import fg from 'fast-glob';
|
|
33
33
|
import * as dotenv from 'dotenv';
|
|
34
34
|
import finalhandler from 'finalhandler';
|
|
35
35
|
import serveStatic from 'serve-static';
|
|
@@ -286,7 +286,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
286
286
|
var errorUtil$1;
|
|
287
287
|
(function (errorUtil) {
|
|
288
288
|
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
289
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message ===
|
|
289
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
290
290
|
})(errorUtil$1 || (errorUtil$1 = {}));
|
|
291
291
|
var ZodFirstPartyTypeKind$1;
|
|
292
292
|
(function (ZodFirstPartyTypeKind) {
|
|
@@ -371,6 +371,32 @@ const getContentHash = (contentString) => {
|
|
|
371
371
|
.substring(0, 5);
|
|
372
372
|
};
|
|
373
373
|
|
|
374
|
+
const loadJson = async (filePath) => {
|
|
375
|
+
const data = await readFile(filePath, "utf-8");
|
|
376
|
+
return JSON.parse(data);
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const getComponentLibraryConfig = (componentLibrary) => {
|
|
380
|
+
let libraryName = componentLibrary;
|
|
381
|
+
const include = [];
|
|
382
|
+
const exclude = [];
|
|
383
|
+
if (typeof componentLibrary === "object" && componentLibrary !== null) {
|
|
384
|
+
libraryName = componentLibrary.name;
|
|
385
|
+
if (componentLibrary.include) {
|
|
386
|
+
include.push(...componentLibrary.include);
|
|
387
|
+
}
|
|
388
|
+
if (componentLibrary.exclude) {
|
|
389
|
+
exclude.push(...componentLibrary.exclude);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return { libraryName, include, exclude };
|
|
393
|
+
};
|
|
394
|
+
const EXTERNAL_LIBRARY_GLOBAL_HOOKS_META_NAME = "globalHooks.json";
|
|
395
|
+
const getGlobalHooksMeta = async (ctx, libraryName) => {
|
|
396
|
+
return (await loadJson(getLibraryPath(ctx, libraryName, EXTERNAL_LIBRARY_GLOBAL_HOOKS_META_NAME)));
|
|
397
|
+
};
|
|
398
|
+
const getLibraryPath = (ctx, libraryName, fileName) => path.resolve(ctx.client.rootDir, "node_modules", libraryName, "dist", fileName);
|
|
399
|
+
|
|
374
400
|
const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
|
|
375
401
|
const EMB_OPTIONS_FILE_REGEX = /^(.*)\.options\.emb\.[jt]s$/;
|
|
376
402
|
var buildTypes = async (ctx) => {
|
|
@@ -383,17 +409,19 @@ var buildTypes = async (ctx) => {
|
|
|
383
409
|
async function generate$1(ctx) {
|
|
384
410
|
const typeFiles = await findFiles(ctx.client.srcDir, EMB_TYPE_FILE_REGEX);
|
|
385
411
|
const optionsFiles = await findFiles(ctx.client.srcDir, EMB_OPTIONS_FILE_REGEX);
|
|
386
|
-
const
|
|
412
|
+
const additionalImports = await getAdditionalImportsFromInstalledLibraries(ctx);
|
|
413
|
+
const repositoryTypeImports = typeFiles
|
|
387
414
|
.concat(optionsFiles)
|
|
388
|
-
.map(([_fileName, filePath]) => `import '../${path
|
|
415
|
+
.map(([_fileName, filePath]) => `import '../${path$1
|
|
389
416
|
.relative(ctx.client.rootDir, filePath)
|
|
390
417
|
.replaceAll("\\", "/")}';`)
|
|
391
418
|
.join("\n");
|
|
392
|
-
|
|
419
|
+
const typeImports = additionalImports.join("\n") + repositoryTypeImports;
|
|
420
|
+
await fs.writeFile(path$1.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
393
421
|
}
|
|
394
422
|
async function build$1(ctx) {
|
|
395
423
|
var _a;
|
|
396
|
-
const typesFilePath = path.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename);
|
|
424
|
+
const typesFilePath = path$1.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename);
|
|
397
425
|
await vite.build({
|
|
398
426
|
logLevel: "error",
|
|
399
427
|
build: {
|
|
@@ -406,28 +434,211 @@ async function build$1(ctx) {
|
|
|
406
434
|
outDir: ctx.client.buildDir,
|
|
407
435
|
},
|
|
408
436
|
});
|
|
409
|
-
if (!((_a = ctx.dev) === null || _a ===
|
|
437
|
+
if (!((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)) {
|
|
410
438
|
const fileContent = await fs.readFile(typesFilePath, "utf8");
|
|
411
439
|
const fileHash = getContentHash(fileContent);
|
|
412
440
|
const fileName = `embeddable-types-${fileHash}.js`;
|
|
413
|
-
await fs.rename(path.resolve(ctx.client.buildDir, "embeddable-types.js"), path.resolve(ctx.client.buildDir, fileName));
|
|
441
|
+
await fs.rename(path$1.resolve(ctx.client.buildDir, "embeddable-types.js"), path$1.resolve(ctx.client.buildDir, fileName));
|
|
414
442
|
}
|
|
415
443
|
}
|
|
416
444
|
async function cleanup$1(ctx) {
|
|
417
|
-
await fs.rm(path.resolve(ctx.client.buildDir, "embeddable-types-entry-point.js"));
|
|
445
|
+
await fs.rm(path$1.resolve(ctx.client.buildDir, "embeddable-types-entry-point.js"));
|
|
446
|
+
}
|
|
447
|
+
async function getAdditionalImportsFromInstalledLibraries(ctx) {
|
|
448
|
+
const componentLibraries = ctx.client.componentLibraries;
|
|
449
|
+
const additionalImports = [];
|
|
450
|
+
for (const componentLibrary of componentLibraries) {
|
|
451
|
+
const { libraryName } = getComponentLibraryConfig(componentLibrary);
|
|
452
|
+
try {
|
|
453
|
+
fg.sync(path$1.resolve(ctx.client.rootDir, "node_modules", libraryName, "dist", "embeddable-types-*.js")).forEach((file) => {
|
|
454
|
+
const fileName = path$1.basename(file);
|
|
455
|
+
additionalImports.push(`import '${libraryName}/dist/${fileName}';`);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
catch (e) {
|
|
459
|
+
console.error(`Can't load component library: ${libraryName}`, e);
|
|
460
|
+
throw e;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return additionalImports;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const TEMP_JS_HOOK_FILE = "embeddableThemeHook.js";
|
|
467
|
+
const LIFECYCLE_OUTPUT_NAME = "embeddable-lifecycle";
|
|
468
|
+
const THEME_PROVIDER_OUTPUT_NAME = "embeddable-theme";
|
|
469
|
+
var buildGlobalHooks = async (ctx) => {
|
|
470
|
+
var _a;
|
|
471
|
+
const watch = (_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch;
|
|
472
|
+
const progress = watch ? undefined : ora("Building global hooks...").start();
|
|
473
|
+
try {
|
|
474
|
+
const { fileName: themeProvider, watcher: themeWatcher } = await buildThemeHook(ctx);
|
|
475
|
+
const { lifecycleHooks, watcher: lifecycleWatcher } = await buildLifecycleHooks(ctx);
|
|
476
|
+
await saveGlobalHooksMeta(ctx, themeProvider, lifecycleHooks);
|
|
477
|
+
progress === null || progress === void 0 ? void 0 : progress.succeed("Global hooks build completed");
|
|
478
|
+
return { themeWatcher, lifecycleWatcher };
|
|
479
|
+
}
|
|
480
|
+
catch (error) {
|
|
481
|
+
progress === null || progress === void 0 ? void 0 : progress.fail("Global hooks build failed");
|
|
482
|
+
throw error;
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* Build theme hooks for a given component library.
|
|
487
|
+
*/
|
|
488
|
+
async function buildThemeHook(ctx) {
|
|
489
|
+
var _a, _b, _c;
|
|
490
|
+
const componentLibraries = ctx.client.componentLibraries;
|
|
491
|
+
const repoThemeHookExists = existsSync(ctx.client.customizationFile);
|
|
492
|
+
const imports = [];
|
|
493
|
+
const functionNames = [];
|
|
494
|
+
for (let i = 0; i < componentLibraries.length; i++) {
|
|
495
|
+
const libraryConfig = componentLibraries[i];
|
|
496
|
+
const { libraryName } = getComponentLibraryConfig(libraryConfig);
|
|
497
|
+
const libMeta = await getGlobalHooksMeta(ctx, libraryName);
|
|
498
|
+
const themeProvider = libMeta.themeProvider;
|
|
499
|
+
if (!themeProvider)
|
|
500
|
+
continue;
|
|
501
|
+
// Prepare imports: library theme + repo theme (if exists)
|
|
502
|
+
const functionName = `libraryThemeProvider${i}`;
|
|
503
|
+
const libraryThemeImport = `import ${functionName} from '${libraryName}/dist/${themeProvider}'`;
|
|
504
|
+
functionNames.push(functionName);
|
|
505
|
+
imports.push(libraryThemeImport);
|
|
506
|
+
}
|
|
507
|
+
if (!imports.length && !repoThemeHookExists) {
|
|
508
|
+
return { fileName: undefined, watcher: undefined };
|
|
509
|
+
}
|
|
510
|
+
const repoThemeImport = repoThemeHookExists
|
|
511
|
+
? `import localThemeProvider from '${ctx.client.customizationFile}';`
|
|
512
|
+
: "const localThemeProvider = () => {};";
|
|
513
|
+
// Generate a temporary file that imports both library and repo theme
|
|
514
|
+
await generateTemporaryHookFile(ctx, imports, functionNames, repoThemeImport);
|
|
515
|
+
// Build the temporary file with Vite
|
|
516
|
+
const buildResults = await buildWithVite(ctx, getTempHookFilePath(ctx), THEME_PROVIDER_OUTPUT_NAME, (_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch, !((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch));
|
|
517
|
+
// Cleanup temporary file
|
|
518
|
+
if (!((_c = ctx.dev) === null || _c === void 0 ? void 0 : _c.watch)) {
|
|
519
|
+
await cleanupTemporaryHookFile(ctx);
|
|
520
|
+
}
|
|
521
|
+
return buildResults;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Build theme hooks for a given component library.
|
|
525
|
+
*/
|
|
526
|
+
async function buildLifecycleHooks(ctx) {
|
|
527
|
+
var _a, _b;
|
|
528
|
+
const componentLibraries = ctx.client.componentLibraries;
|
|
529
|
+
const builtLifecycleHooks = [];
|
|
530
|
+
const repoLifecycleExist = existsSync(ctx.client.lifecycleHooksFile);
|
|
531
|
+
let lifecycleWatcher = undefined;
|
|
532
|
+
// If lifecycle exists, build it right away to get the hashed output
|
|
533
|
+
if (repoLifecycleExist) {
|
|
534
|
+
const { fileName: repoLifecycleFileName, watcher } = await buildWithVite(ctx, ctx.client.lifecycleHooksFile, LIFECYCLE_OUTPUT_NAME, (_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch, false);
|
|
535
|
+
if ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch) {
|
|
536
|
+
lifecycleWatcher = watcher;
|
|
537
|
+
}
|
|
538
|
+
builtLifecycleHooks.push(repoLifecycleFileName);
|
|
539
|
+
}
|
|
540
|
+
for (const libraryConfig of componentLibraries) {
|
|
541
|
+
const { libraryName } = getComponentLibraryConfig(libraryConfig);
|
|
542
|
+
const libMeta = await getGlobalHooksMeta(ctx, libraryName);
|
|
543
|
+
const lifecycleHooks = libMeta.lifecycleHooks;
|
|
544
|
+
for (const lifecycleHook of lifecycleHooks) {
|
|
545
|
+
const libLifecycleHook = path$1.resolve(ctx.client.rootDir, "node_modules", libraryName, "dist", lifecycleHook);
|
|
546
|
+
const { fileName: lifecycleHookFileName } = await buildWithVite(ctx, libLifecycleHook, LIFECYCLE_OUTPUT_NAME);
|
|
547
|
+
builtLifecycleHooks.push(lifecycleHookFileName);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return { lifecycleHooks: builtLifecycleHooks, watcher: lifecycleWatcher };
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Write the final global hooks metadata to disk (themeHooksMeta, lifecycleHookMeta).
|
|
554
|
+
*/
|
|
555
|
+
async function saveGlobalHooksMeta(ctx, themeProvider, lifecycleHooks) {
|
|
556
|
+
const metaFilePath = path$1.resolve(ctx.client.buildDir, EXTERNAL_LIBRARY_GLOBAL_HOOKS_META_NAME);
|
|
557
|
+
const data = JSON.stringify({ themeProvider, lifecycleHooks }, null, 2);
|
|
558
|
+
fsSync.writeFileSync(metaFilePath, data);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Generate a temporary file which imports the library theme and repository theme,
|
|
562
|
+
* replacing template placeholders.
|
|
563
|
+
*/
|
|
564
|
+
async function generateTemporaryHookFile(ctx, libraryThemeImports, functionNames, repoThemeImport) {
|
|
565
|
+
const templatePath = path$1.resolve(ctx.core.templatesDir, "embeddableThemeHook.js.template");
|
|
566
|
+
const templateContent = await fs.readFile(templatePath, "utf8");
|
|
567
|
+
const newContent = templateContent
|
|
568
|
+
.replace("{{LIBRARY_THEME_IMPORTS}}", libraryThemeImports.join("\n"))
|
|
569
|
+
.replace("{{ARRAY_OF_LIBRARY_THEME_PROVIDERS}}", functionNames.join("\n"))
|
|
570
|
+
.replace("{{LOCAL_THEME_IMPORT}}", repoThemeImport);
|
|
571
|
+
// Write to temporary hook file
|
|
572
|
+
await fs.writeFile(getTempHookFilePath(ctx), newContent, "utf8");
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Build a file with Vite and return the hashed output file name (e.g., embeddable-theme-xxxx.js).
|
|
576
|
+
*/
|
|
577
|
+
async function buildWithVite(ctx, entryFile, outputFile, watch = false, useHash = true) {
|
|
578
|
+
const fileContent = await fs.readFile(entryFile, "utf8");
|
|
579
|
+
const fileHash = getContentHash(fileContent);
|
|
580
|
+
// Bundle using Vite
|
|
581
|
+
const fileName = useHash ? `${outputFile}-${fileHash}` : outputFile;
|
|
582
|
+
const fileWatcher = await vite.build({
|
|
583
|
+
logLevel: watch ? "info" : "error",
|
|
584
|
+
build: {
|
|
585
|
+
emptyOutDir: false,
|
|
586
|
+
lib: {
|
|
587
|
+
entry: entryFile,
|
|
588
|
+
formats: ["es"],
|
|
589
|
+
fileName: fileName,
|
|
590
|
+
},
|
|
591
|
+
outDir: ctx.client.buildDir,
|
|
592
|
+
watch: watch ? {} : undefined,
|
|
593
|
+
},
|
|
594
|
+
});
|
|
595
|
+
if (watch) {
|
|
596
|
+
await waitForInitialBuild(fileWatcher);
|
|
597
|
+
}
|
|
598
|
+
const watcher = watch
|
|
599
|
+
? fileWatcher
|
|
600
|
+
: undefined;
|
|
601
|
+
return { fileName: `${fileName}.js`, watcher };
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Remove the temporary hook file after building.
|
|
605
|
+
*/
|
|
606
|
+
async function cleanupTemporaryHookFile(ctx) {
|
|
607
|
+
await fs.rm(getTempHookFilePath(ctx), { force: true });
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Get the path to the temporary hook file in the build directory.
|
|
611
|
+
*/
|
|
612
|
+
function getTempHookFilePath(ctx) {
|
|
613
|
+
return path$1.resolve(ctx.client.buildDir, TEMP_JS_HOOK_FILE);
|
|
614
|
+
}
|
|
615
|
+
function waitForInitialBuild(watcher) {
|
|
616
|
+
return new Promise((resolve, reject) => {
|
|
617
|
+
function onEvent(event) {
|
|
618
|
+
if (event.code === "END") {
|
|
619
|
+
watcher.off("event", onEvent);
|
|
620
|
+
resolve();
|
|
621
|
+
}
|
|
622
|
+
else if (event.code === "ERROR") {
|
|
623
|
+
watcher.off("event", onEvent);
|
|
624
|
+
reject(event.error);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
watcher.on("event", onEvent);
|
|
628
|
+
});
|
|
418
629
|
}
|
|
419
630
|
|
|
420
|
-
var prepare = async (ctx) => {
|
|
631
|
+
var prepare$1 = async (ctx) => {
|
|
421
632
|
await removeIfExists(ctx);
|
|
422
633
|
await copyStencilConfigsToClient(ctx);
|
|
423
634
|
await createComponentDir(ctx.client.componentDir);
|
|
424
635
|
};
|
|
425
636
|
async function removeIfExists(ctx) {
|
|
426
637
|
const promises = [];
|
|
427
|
-
if (
|
|
638
|
+
if (fsSync.existsSync(ctx.client.buildDir)) {
|
|
428
639
|
promises.push(fs.rm(ctx.client.buildDir, { recursive: true }));
|
|
429
640
|
}
|
|
430
|
-
if (
|
|
641
|
+
if (fsSync.existsSync(ctx.client.tmpDir)) {
|
|
431
642
|
promises.push(fs.rm(ctx.client.tmpDir, { recursive: true }));
|
|
432
643
|
}
|
|
433
644
|
await Promise.all(promises);
|
|
@@ -450,27 +661,35 @@ var generate = async (ctx, pluginName) => {
|
|
|
450
661
|
await generateSourceMap(ctx, pluginName);
|
|
451
662
|
};
|
|
452
663
|
async function injectCSS(ctx, pluginName) {
|
|
453
|
-
const CUSTOMER_BUILD = path.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
664
|
+
const CUSTOMER_BUILD = path$1.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
454
665
|
const allFiles = await fs.readdir(CUSTOMER_BUILD);
|
|
455
|
-
const
|
|
666
|
+
const imports = allFiles
|
|
456
667
|
.filter((fileName) => fileName.endsWith(".css"))
|
|
457
|
-
.map((fileName) => `@import '../${ctx[pluginName].outputOptions.buildName}/${fileName}';`)
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
|
|
668
|
+
.map((fileName) => `@import '../${ctx[pluginName].outputOptions.buildName}/${fileName}';`);
|
|
669
|
+
const componentLibraries = ctx.client.componentLibraries;
|
|
670
|
+
for (const componentLibrary of componentLibraries) {
|
|
671
|
+
const { libraryName } = getComponentLibraryConfig(componentLibrary);
|
|
672
|
+
const allLibFiles = await fs.readdir(path$1.resolve(ctx.client.rootDir, "node_modules", libraryName, "dist"));
|
|
673
|
+
allLibFiles
|
|
674
|
+
.filter((fileName) => fileName.endsWith(".css"))
|
|
675
|
+
.forEach((fileName) => imports.push(`@import '~${libraryName}/dist/${fileName}';`));
|
|
676
|
+
}
|
|
677
|
+
const cssFilesImportsStr = imports.join("\n");
|
|
678
|
+
const content = await fs.readFile(path$1.resolve(ctx.core.templatesDir, "style.css.template"), "utf8");
|
|
679
|
+
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "style.css"), content.replace(STYLE_IMPORTS_TOKEN, cssFilesImportsStr));
|
|
461
680
|
}
|
|
462
681
|
async function injectBundleRender(ctx, pluginName) {
|
|
463
682
|
var _a;
|
|
464
683
|
const importStr = `import render from '../${ctx[pluginName].outputOptions.buildName}/${ctx[pluginName].outputOptions.fileName}';`;
|
|
465
|
-
let content = await fs.readFile(path.resolve(ctx.core.templatesDir, "component.tsx.template"), "utf8");
|
|
466
|
-
if (!!((_a = ctx.dev) === null || _a ===
|
|
684
|
+
let content = await fs.readFile(path$1.resolve(ctx.core.templatesDir, "component.tsx.template"), "utf8");
|
|
685
|
+
if (!!((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)) {
|
|
467
686
|
content = content.replace(COMPONENT_TAG_TOKEN, "embeddable-component");
|
|
468
687
|
}
|
|
469
|
-
await fs.writeFile(path.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
688
|
+
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
470
689
|
}
|
|
471
690
|
async function addComponentTagName(filePath, bundleHash) {
|
|
472
691
|
// find entry file with a name *.entry.js
|
|
473
|
-
const entryFiles = await findFiles(path.dirname(filePath), /.*\.entry\.js/);
|
|
692
|
+
const entryFiles = await findFiles(path$1.dirname(filePath), /.*\.entry\.js/);
|
|
474
693
|
if (!entryFiles.length) {
|
|
475
694
|
return;
|
|
476
695
|
}
|
|
@@ -488,9 +707,9 @@ async function addComponentTagName(filePath, bundleHash) {
|
|
|
488
707
|
}
|
|
489
708
|
async function runStencil(ctx) {
|
|
490
709
|
var _a, _b, _c;
|
|
491
|
-
const logger = ((_a = ctx.dev) === null || _a ===
|
|
492
|
-
const sys = ((_b = ctx.dev) === null || _b ===
|
|
493
|
-
const devMode = !!((_c = ctx.dev) === null || _c ===
|
|
710
|
+
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || createNodeLogger();
|
|
711
|
+
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || createNodeSys({ process });
|
|
712
|
+
const devMode = !!((_c = ctx.dev) === null || _c === void 0 ? void 0 : _c.watch);
|
|
494
713
|
const isWindows = process.platform === "win32";
|
|
495
714
|
const validated = await loadConfig({
|
|
496
715
|
initTsConfig: true,
|
|
@@ -500,10 +719,10 @@ async function runStencil(ctx) {
|
|
|
500
719
|
devMode,
|
|
501
720
|
maxConcurrentWorkers: isWindows ? 0 : 8, // workers break on windows
|
|
502
721
|
rootDir: ctx.client.buildDir,
|
|
503
|
-
configPath: path.resolve(ctx.client.buildDir, "stencil.config.ts"),
|
|
504
|
-
tsconfig: path.resolve(ctx.client.buildDir, "tsconfig.json"),
|
|
722
|
+
configPath: path$1.resolve(ctx.client.buildDir, "stencil.config.ts"),
|
|
723
|
+
tsconfig: path$1.resolve(ctx.client.buildDir, "tsconfig.json"),
|
|
505
724
|
namespace: "embeddable-wrapper",
|
|
506
|
-
srcDir: path.resolve(ctx.client.buildDir, "component"),
|
|
725
|
+
srcDir: path$1.resolve(ctx.client.buildDir, "component"),
|
|
507
726
|
sourceMap: true, // always generate source maps in both dev and prod
|
|
508
727
|
minifyJs: !devMode,
|
|
509
728
|
minifyCss: !devMode,
|
|
@@ -513,7 +732,7 @@ async function runStencil(ctx) {
|
|
|
513
732
|
},
|
|
514
733
|
],
|
|
515
734
|
watchDirs: [
|
|
516
|
-
path.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.buildName),
|
|
735
|
+
path$1.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.buildName),
|
|
517
736
|
],
|
|
518
737
|
},
|
|
519
738
|
});
|
|
@@ -533,27 +752,24 @@ async function runStencil(ctx) {
|
|
|
533
752
|
}
|
|
534
753
|
async function handleStencilBuildOutput(ctx) {
|
|
535
754
|
var _a;
|
|
536
|
-
const entryFilePath = path.resolve(ctx.client.stencilBuild, "embeddable-wrapper.esm.js");
|
|
755
|
+
const entryFilePath = path$1.resolve(ctx.client.stencilBuild, "embeddable-wrapper.esm.js");
|
|
537
756
|
let fileName = "embeddable-wrapper.esm.js";
|
|
538
|
-
if (!((_a = ctx.dev) === null || _a ===
|
|
539
|
-
|
|
540
|
-
const fileHash = getContentHash(entryFileContent);
|
|
541
|
-
fileName = `embeddable-wrapper.esm-${fileHash}.js`;
|
|
542
|
-
ctx.client.bundleHash = fileHash;
|
|
757
|
+
if (!((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch) && ctx.client.bundleHash) {
|
|
758
|
+
fileName = `embeddable-wrapper.esm-${ctx.client.bundleHash}.js`;
|
|
543
759
|
await addComponentTagName(entryFilePath, ctx.client.bundleHash);
|
|
544
760
|
}
|
|
545
|
-
await fs.rename(entryFilePath, path.resolve(ctx.client.stencilBuild, fileName));
|
|
761
|
+
await fs.rename(entryFilePath, path$1.resolve(ctx.client.stencilBuild, fileName));
|
|
546
762
|
}
|
|
547
763
|
async function generateSourceMap(ctx, pluginName) {
|
|
548
|
-
const componentBuildDir = path.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
549
|
-
const stencilBuild = path.resolve(ctx.client.stencilBuild);
|
|
550
|
-
const tmpComponentDir = path.resolve(stencilBuild, ctx[pluginName].outputOptions.buildName);
|
|
764
|
+
const componentBuildDir = path$1.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
765
|
+
const stencilBuild = path$1.resolve(ctx.client.stencilBuild);
|
|
766
|
+
const tmpComponentDir = path$1.resolve(stencilBuild, ctx[pluginName].outputOptions.buildName);
|
|
551
767
|
await fs.cp(componentBuildDir, tmpComponentDir, { recursive: true });
|
|
552
768
|
const stencilFiles = await fs.readdir(stencilBuild);
|
|
553
769
|
const jsFiles = stencilFiles.filter((file) => file.toLowerCase().endsWith(".js"));
|
|
554
770
|
await Promise.all(jsFiles.map(async (jsFile) => {
|
|
555
771
|
try {
|
|
556
|
-
const chain = await sorcery.load(path.resolve(stencilBuild, jsFile));
|
|
772
|
+
const chain = await sorcery.load(path$1.resolve(stencilBuild, jsFile));
|
|
557
773
|
// overwrite the existing file
|
|
558
774
|
await chain.write();
|
|
559
775
|
}
|
|
@@ -564,8 +780,8 @@ async function generateSourceMap(ctx, pluginName) {
|
|
|
564
780
|
await fs.rm(tmpComponentDir, { recursive: true });
|
|
565
781
|
}
|
|
566
782
|
|
|
567
|
-
const CREDENTIALS_DIR = path.resolve(os.homedir(), ".embeddable");
|
|
568
|
-
const CREDENTIALS_FILE = path.resolve(CREDENTIALS_DIR, "credentials");
|
|
783
|
+
const CREDENTIALS_DIR = path$1.resolve(os.homedir(), ".embeddable");
|
|
784
|
+
const CREDENTIALS_FILE = path$1.resolve(CREDENTIALS_DIR, "credentials");
|
|
569
785
|
|
|
570
786
|
const checkNodeVersion = async () => {
|
|
571
787
|
const spinner = ora("Checking node version...").start();
|
|
@@ -753,14 +969,15 @@ async function createManifest({ ctx, typesFileName, metaFileName, editorsMetaFil
|
|
|
753
969
|
const sdkVersions = await getSDKVersions();
|
|
754
970
|
// identify user's package manager and its version
|
|
755
971
|
let packageManager = "npm";
|
|
756
|
-
if ((_a = process.env.npm_config_user_agent) === null || _a ===
|
|
972
|
+
if ((_a = process.env.npm_config_user_agent) === null || _a === void 0 ? void 0 : _a.includes("yarn")) {
|
|
757
973
|
packageManager = "yarn";
|
|
758
974
|
}
|
|
759
|
-
if ((_b = process.env.npm_config_user_agent) === null || _b ===
|
|
975
|
+
if ((_b = process.env.npm_config_user_agent) === null || _b === void 0 ? void 0 : _b.includes("pnpm")) {
|
|
760
976
|
packageManager = "pnpm";
|
|
761
977
|
}
|
|
762
|
-
const packageManagerVersion = ((_d = (_c = process.env.npm_config_user_agent) === null || _c ===
|
|
978
|
+
const packageManagerVersion = ((_d = (_c = process.env.npm_config_user_agent) === null || _c === void 0 ? void 0 : _c.match(/(\d+\.\d+\.\d+)/)) === null || _d === void 0 ? void 0 : _d[0]) ||
|
|
763
979
|
"unknown";
|
|
980
|
+
const globalHooks = await loadJson(path$1.resolve(ctx.client.buildDir, "globalHooks.json"));
|
|
764
981
|
// write manifest file with files with hash
|
|
765
982
|
const manifest = {
|
|
766
983
|
entryFiles: {
|
|
@@ -776,31 +993,43 @@ async function createManifest({ ctx, typesFileName, metaFileName, editorsMetaFil
|
|
|
776
993
|
sdkVersions,
|
|
777
994
|
packageManager,
|
|
778
995
|
packageManagerVersion,
|
|
996
|
+
globalHooks,
|
|
779
997
|
metrics: {
|
|
780
998
|
buildTime: hrtimeToISO8601(ctx.buildTime),
|
|
781
999
|
},
|
|
782
|
-
origin: ((_e = ctx.dev) === null || _e ===
|
|
1000
|
+
origin: ((_e = ctx.dev) === null || _e === void 0 ? void 0 : _e.watch) ? "dev" : "push",
|
|
783
1001
|
},
|
|
784
1002
|
};
|
|
785
|
-
await fs.writeFile(path.join(ctx.client.tmpDir, "embeddable-manifest.json"), JSON.stringify(manifest));
|
|
1003
|
+
await fs.writeFile(path$1.join(ctx.client.tmpDir, "embeddable-manifest.json"), JSON.stringify(manifest));
|
|
786
1004
|
}
|
|
787
1005
|
async function extractBuild(ctx) {
|
|
788
1006
|
const stencilBuildFiles = await findFiles(ctx.client.stencilBuild, /embeddable-wrapper.esm-[a-z0-9]+\.js/);
|
|
789
1007
|
const [[, stencilWrapperFilePath]] = stencilBuildFiles || [];
|
|
790
|
-
const stencilWrapperFileName = path.basename(stencilWrapperFilePath);
|
|
791
|
-
await fs.rename(path.resolve(ctx.client.buildDir, ctx.client.stencilBuild), ctx.client.tmpDir);
|
|
1008
|
+
const stencilWrapperFileName = path$1.basename(stencilWrapperFilePath);
|
|
1009
|
+
await fs.rename(path$1.resolve(ctx.client.buildDir, ctx.client.stencilBuild), ctx.client.tmpDir);
|
|
792
1010
|
const typesBuildFiles = await findFiles(ctx.client.buildDir, /embeddable-types-[a-z0-9]+\.js/);
|
|
793
1011
|
const [[, typesFilePath]] = typesBuildFiles || [];
|
|
794
|
-
const typesFileName = path.basename(typesFilePath);
|
|
795
|
-
await fs.rename(typesFilePath, path.join(ctx.client.tmpDir, typesFileName));
|
|
1012
|
+
const typesFileName = path$1.basename(typesFilePath);
|
|
1013
|
+
await fs.rename(typesFilePath, path$1.join(ctx.client.tmpDir, typesFileName));
|
|
796
1014
|
const metaBuildFiles = await findFiles(ctx.client.buildDir, /embeddable-components-meta-[a-z0-9]+\.js/);
|
|
797
1015
|
const [[, metaFilePath]] = metaBuildFiles || [];
|
|
798
|
-
const metaFileName = path.basename(metaFilePath);
|
|
799
|
-
await fs.rename(metaFilePath, path.join(ctx.client.tmpDir, metaFileName));
|
|
1016
|
+
const metaFileName = path$1.basename(metaFilePath);
|
|
1017
|
+
await fs.rename(metaFilePath, path$1.join(ctx.client.tmpDir, metaFileName));
|
|
800
1018
|
const editorsMetaBuildFiles = await findFiles(ctx.client.buildDir, /embeddable-editors-meta-[a-z0-9]+\.js/);
|
|
801
1019
|
const [[, editorsMetaFilePath]] = editorsMetaBuildFiles || [];
|
|
802
|
-
const editorsMetaFileName = path.basename(editorsMetaFilePath);
|
|
803
|
-
await fs.rename(editorsMetaFilePath, path.join(ctx.client.tmpDir, editorsMetaFileName));
|
|
1020
|
+
const editorsMetaFileName = path$1.basename(editorsMetaFilePath);
|
|
1021
|
+
await fs.rename(editorsMetaFilePath, path$1.join(ctx.client.tmpDir, editorsMetaFileName));
|
|
1022
|
+
const themeFile = (await findFiles(ctx.client.buildDir, /embeddable-theme-[0-9a-f]+\.js/)) ||
|
|
1023
|
+
[];
|
|
1024
|
+
for (const [, themeFilePath] of themeFile) {
|
|
1025
|
+
const themeFilePathFileName = path$1.basename(themeFilePath);
|
|
1026
|
+
await fs.rename(themeFilePath, path$1.join(ctx.client.tmpDir, themeFilePathFileName));
|
|
1027
|
+
}
|
|
1028
|
+
const lifecycleFiles = (await findFiles(ctx.client.buildDir, /embeddable-lifecycle-[0-9a-f]+\.js/)) || [];
|
|
1029
|
+
for (const [, lifecycleFilePath] of lifecycleFiles) {
|
|
1030
|
+
const lifecycleFilePathFileName = path$1.basename(lifecycleFilePath);
|
|
1031
|
+
await fs.rename(lifecycleFilePath, path$1.join(ctx.client.tmpDir, lifecycleFilePathFileName));
|
|
1032
|
+
}
|
|
804
1033
|
await createManifest({
|
|
805
1034
|
ctx,
|
|
806
1035
|
typesFileName,
|
|
@@ -1362,7 +1591,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1362
1591
|
var errorUtil;
|
|
1363
1592
|
(function (errorUtil) {
|
|
1364
1593
|
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
1365
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message ===
|
|
1594
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
1366
1595
|
})(errorUtil || (errorUtil = {}));
|
|
1367
1596
|
|
|
1368
1597
|
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
@@ -1419,14 +1648,14 @@ function processCreateParams(params) {
|
|
|
1419
1648
|
var _a, _b;
|
|
1420
1649
|
const { message } = params;
|
|
1421
1650
|
if (iss.code === "invalid_enum_value") {
|
|
1422
|
-
return { message: message !== null && message !==
|
|
1651
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
1423
1652
|
}
|
|
1424
1653
|
if (typeof ctx.data === "undefined") {
|
|
1425
|
-
return { message: (_a = message !== null && message !==
|
|
1654
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
1426
1655
|
}
|
|
1427
1656
|
if (iss.code !== "invalid_type")
|
|
1428
1657
|
return { message: ctx.defaultError };
|
|
1429
|
-
return { message: (_b = message !== null && message !==
|
|
1658
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
1430
1659
|
};
|
|
1431
1660
|
return { errorMap: customMap, description };
|
|
1432
1661
|
}
|
|
@@ -1482,10 +1711,10 @@ class ZodType {
|
|
|
1482
1711
|
const ctx = {
|
|
1483
1712
|
common: {
|
|
1484
1713
|
issues: [],
|
|
1485
|
-
async: (_a = params === null || params ===
|
|
1486
|
-
contextualErrorMap: params === null || params ===
|
|
1714
|
+
async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
|
|
1715
|
+
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
|
1487
1716
|
},
|
|
1488
|
-
path: (params === null || params ===
|
|
1717
|
+
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
1489
1718
|
schemaErrorMap: this._def.errorMap,
|
|
1490
1719
|
parent: null,
|
|
1491
1720
|
data,
|
|
@@ -1519,7 +1748,7 @@ class ZodType {
|
|
|
1519
1748
|
};
|
|
1520
1749
|
}
|
|
1521
1750
|
catch (err) {
|
|
1522
|
-
if ((_b = (_a = err === null || err ===
|
|
1751
|
+
if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
|
|
1523
1752
|
this["~standard"].async = true;
|
|
1524
1753
|
}
|
|
1525
1754
|
ctx.common = {
|
|
@@ -1546,10 +1775,10 @@ class ZodType {
|
|
|
1546
1775
|
const ctx = {
|
|
1547
1776
|
common: {
|
|
1548
1777
|
issues: [],
|
|
1549
|
-
contextualErrorMap: params === null || params ===
|
|
1778
|
+
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
|
1550
1779
|
async: true,
|
|
1551
1780
|
},
|
|
1552
|
-
path: (params === null || params ===
|
|
1781
|
+
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
1553
1782
|
schemaErrorMap: this._def.errorMap,
|
|
1554
1783
|
parent: null,
|
|
1555
1784
|
data,
|
|
@@ -2240,10 +2469,10 @@ class ZodString extends ZodType {
|
|
|
2240
2469
|
}
|
|
2241
2470
|
return this._addCheck({
|
|
2242
2471
|
kind: "datetime",
|
|
2243
|
-
precision: typeof (options === null || options ===
|
|
2244
|
-
offset: (_a = options === null || options ===
|
|
2245
|
-
local: (_b = options === null || options ===
|
|
2246
|
-
...errorUtil.errToObj(options === null || options ===
|
|
2472
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
2473
|
+
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
2474
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
2475
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
2247
2476
|
});
|
|
2248
2477
|
}
|
|
2249
2478
|
date(message) {
|
|
@@ -2259,8 +2488,8 @@ class ZodString extends ZodType {
|
|
|
2259
2488
|
}
|
|
2260
2489
|
return this._addCheck({
|
|
2261
2490
|
kind: "time",
|
|
2262
|
-
precision: typeof (options === null || options ===
|
|
2263
|
-
...errorUtil.errToObj(options === null || options ===
|
|
2491
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
2492
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
2264
2493
|
});
|
|
2265
2494
|
}
|
|
2266
2495
|
duration(message) {
|
|
@@ -2277,8 +2506,8 @@ class ZodString extends ZodType {
|
|
|
2277
2506
|
return this._addCheck({
|
|
2278
2507
|
kind: "includes",
|
|
2279
2508
|
value: value,
|
|
2280
|
-
position: options === null || options ===
|
|
2281
|
-
...errorUtil.errToObj(options === null || options ===
|
|
2509
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
|
2510
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
2282
2511
|
});
|
|
2283
2512
|
}
|
|
2284
2513
|
startsWith(value, message) {
|
|
@@ -2415,7 +2644,7 @@ ZodString.create = (params) => {
|
|
|
2415
2644
|
return new ZodString({
|
|
2416
2645
|
checks: [],
|
|
2417
2646
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
2418
|
-
coerce: (_a = params === null || params ===
|
|
2647
|
+
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
2419
2648
|
...processCreateParams(params),
|
|
2420
2649
|
});
|
|
2421
2650
|
};
|
|
@@ -2669,7 +2898,7 @@ ZodNumber.create = (params) => {
|
|
|
2669
2898
|
return new ZodNumber({
|
|
2670
2899
|
checks: [],
|
|
2671
2900
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
2672
|
-
coerce: (params === null || params ===
|
|
2901
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
2673
2902
|
...processCreateParams(params),
|
|
2674
2903
|
});
|
|
2675
2904
|
};
|
|
@@ -2850,7 +3079,7 @@ ZodBigInt.create = (params) => {
|
|
|
2850
3079
|
return new ZodBigInt({
|
|
2851
3080
|
checks: [],
|
|
2852
3081
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
2853
|
-
coerce: (_a = params === null || params ===
|
|
3082
|
+
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
2854
3083
|
...processCreateParams(params),
|
|
2855
3084
|
});
|
|
2856
3085
|
};
|
|
@@ -2875,7 +3104,7 @@ class ZodBoolean extends ZodType {
|
|
|
2875
3104
|
ZodBoolean.create = (params) => {
|
|
2876
3105
|
return new ZodBoolean({
|
|
2877
3106
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
2878
|
-
coerce: (params === null || params ===
|
|
3107
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
2879
3108
|
...processCreateParams(params),
|
|
2880
3109
|
});
|
|
2881
3110
|
};
|
|
@@ -2985,7 +3214,7 @@ class ZodDate extends ZodType {
|
|
|
2985
3214
|
ZodDate.create = (params) => {
|
|
2986
3215
|
return new ZodDate({
|
|
2987
3216
|
checks: [],
|
|
2988
|
-
coerce: (params === null || params ===
|
|
3217
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
2989
3218
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
2990
3219
|
...processCreateParams(params),
|
|
2991
3220
|
});
|
|
@@ -3413,10 +3642,10 @@ class ZodObject extends ZodType {
|
|
|
3413
3642
|
? {
|
|
3414
3643
|
errorMap: (issue, ctx) => {
|
|
3415
3644
|
var _a, _b, _c, _d;
|
|
3416
|
-
const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b ===
|
|
3645
|
+
const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
|
3417
3646
|
if (issue.code === "unrecognized_keys")
|
|
3418
3647
|
return {
|
|
3419
|
-
message: (_d = errorUtil.errToObj(message).message) !== null && _d !==
|
|
3648
|
+
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,
|
|
3420
3649
|
};
|
|
3421
3650
|
return {
|
|
3422
3651
|
message: defaultError,
|
|
@@ -4426,7 +4655,7 @@ function createZodEnum(values, params) {
|
|
|
4426
4655
|
class ZodEnum extends ZodType {
|
|
4427
4656
|
constructor() {
|
|
4428
4657
|
super(...arguments);
|
|
4429
|
-
_ZodEnum_cache.set(this,
|
|
4658
|
+
_ZodEnum_cache.set(this, void 0);
|
|
4430
4659
|
}
|
|
4431
4660
|
_parse(input) {
|
|
4432
4661
|
if (typeof input.data !== "string") {
|
|
@@ -4496,7 +4725,7 @@ ZodEnum.create = createZodEnum;
|
|
|
4496
4725
|
class ZodNativeEnum extends ZodType {
|
|
4497
4726
|
constructor() {
|
|
4498
4727
|
super(...arguments);
|
|
4499
|
-
_ZodNativeEnum_cache.set(this,
|
|
4728
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
4500
4729
|
}
|
|
4501
4730
|
_parse(input) {
|
|
4502
4731
|
const nativeEnumValues = util$1.getValidEnumValues(this._def.values);
|
|
@@ -4996,14 +5225,14 @@ fatal) {
|
|
|
4996
5225
|
var _a, _b;
|
|
4997
5226
|
if (!r) {
|
|
4998
5227
|
const params = cleanParams(_params, data);
|
|
4999
|
-
const _fatal = (_b = (_a = params.fatal) !== null && _a !==
|
|
5228
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
5000
5229
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
5001
5230
|
}
|
|
5002
5231
|
});
|
|
5003
5232
|
}
|
|
5004
5233
|
if (!r) {
|
|
5005
5234
|
const params = cleanParams(_params, data);
|
|
5006
|
-
const _fatal = (_b = (_a = params.fatal) !== null && _a !==
|
|
5235
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
5007
5236
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
5008
5237
|
}
|
|
5009
5238
|
return;
|
|
@@ -5368,7 +5597,7 @@ const cubeModelSchema = z
|
|
|
5368
5597
|
.array()
|
|
5369
5598
|
.min(1),
|
|
5370
5599
|
})
|
|
5371
|
-
.refine((data) => data.cubes.every((cube) => { var _a, _b; return ((_a = cube.dimensions) === null || _a ===
|
|
5600
|
+
.refine((data) => data.cubes.every((cube) => { var _a, _b; return ((_a = cube.dimensions) === null || _a === void 0 ? void 0 : _a.length) || ((_b = cube.measures) === null || _b === void 0 ? void 0 : _b.length); }), {
|
|
5372
5601
|
message: "At least one measure or dimension must be defined",
|
|
5373
5602
|
path: ["cubes"],
|
|
5374
5603
|
});
|
|
@@ -5404,12 +5633,12 @@ const clientContextSchema = z.array(z
|
|
|
5404
5633
|
var provideConfig = async () => {
|
|
5405
5634
|
const configFilePath = `${process.cwd()}/embeddable.config.js`;
|
|
5406
5635
|
const tsConfigFilePath = `${process.cwd()}/embeddable.config.ts`;
|
|
5407
|
-
if (!
|
|
5636
|
+
if (!fsSync.existsSync(configFilePath) && !fsSync.existsSync(tsConfigFilePath)) {
|
|
5408
5637
|
console.log("Please create a proper `embeddable.config.js` or `embeddable.config.ts` file in the root of your project.");
|
|
5409
5638
|
process.exit(1);
|
|
5410
5639
|
}
|
|
5411
5640
|
const isWindows = process.platform === "win32";
|
|
5412
|
-
const configPath =
|
|
5641
|
+
const configPath = fsSync.existsSync(tsConfigFilePath)
|
|
5413
5642
|
? tsConfigFilePath
|
|
5414
5643
|
: configFilePath;
|
|
5415
5644
|
const pathOrUrl = isWindows ? url.pathToFileURL(configPath).href : configPath;
|
|
@@ -5421,7 +5650,7 @@ function getDefaultExportFromCjs (x) {
|
|
|
5421
5650
|
}
|
|
5422
5651
|
|
|
5423
5652
|
function getAugmentedNamespace(n) {
|
|
5424
|
-
if (n
|
|
5653
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
5425
5654
|
var f = n.default;
|
|
5426
5655
|
if (typeof f == "function") {
|
|
5427
5656
|
var a = function a () {
|
|
@@ -5445,106 +5674,8 @@ function getAugmentedNamespace(n) {
|
|
|
5445
5674
|
return a;
|
|
5446
5675
|
}
|
|
5447
5676
|
|
|
5448
|
-
var name = "rollbar";
|
|
5449
5677
|
var version = "2.26.4";
|
|
5450
|
-
var repository = {
|
|
5451
|
-
type: "git",
|
|
5452
|
-
url: "http://github.com/rollbar/rollbar.js"
|
|
5453
|
-
};
|
|
5454
|
-
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.";
|
|
5455
|
-
var keywords = [
|
|
5456
|
-
"error",
|
|
5457
|
-
"tracking",
|
|
5458
|
-
"logging",
|
|
5459
|
-
"debugging",
|
|
5460
|
-
"javascript"
|
|
5461
|
-
];
|
|
5462
|
-
var license = "MIT";
|
|
5463
|
-
var main = "src/server/rollbar.js";
|
|
5464
|
-
var browser = "dist/rollbar.umd.min.js";
|
|
5465
|
-
var types = "./index.d.ts";
|
|
5466
|
-
var dependencies = {
|
|
5467
|
-
async: "~3.2.3",
|
|
5468
|
-
"console-polyfill": "0.3.0",
|
|
5469
|
-
"error-stack-parser": "^2.0.4",
|
|
5470
|
-
"json-stringify-safe": "~5.0.0",
|
|
5471
|
-
"lru-cache": "~2.2.1",
|
|
5472
|
-
"request-ip": "~3.3.0",
|
|
5473
|
-
"source-map": "^0.5.7"
|
|
5474
|
-
};
|
|
5475
|
-
var devDependencies = {
|
|
5476
|
-
"@babel/core": "^7.22.11",
|
|
5477
|
-
"babel-eslint": "^10.0.3",
|
|
5478
|
-
"babel-loader": "^8.0.4",
|
|
5479
|
-
bluebird: "^3.3.5",
|
|
5480
|
-
chai: "^4.2.0",
|
|
5481
|
-
chalk: "^1.1.1",
|
|
5482
|
-
"coverage-istanbul-loader": "^3.0.5",
|
|
5483
|
-
eslint: "^6.8.0",
|
|
5484
|
-
"eslint-loader": "^3.0.3",
|
|
5485
|
-
express: "^4.18.2",
|
|
5486
|
-
glob: "^5.0.14",
|
|
5487
|
-
grunt: "^1.1.0",
|
|
5488
|
-
"grunt-bumpup": "^0.6.3",
|
|
5489
|
-
"grunt-cli": "^1.3.2",
|
|
5490
|
-
"grunt-contrib-concat": "^2.1.0",
|
|
5491
|
-
"grunt-contrib-connect": "^2.1.0",
|
|
5492
|
-
"grunt-contrib-copy": "^1.0.0",
|
|
5493
|
-
"grunt-contrib-jshint": "^3.2.0",
|
|
5494
|
-
"grunt-contrib-uglify": "^4.0.0",
|
|
5495
|
-
"grunt-contrib-watch": "^1.1.0",
|
|
5496
|
-
"grunt-karma": "^4.0.2",
|
|
5497
|
-
"grunt-parallel": "^0.5.1",
|
|
5498
|
-
"grunt-text-replace": "^0.4.0",
|
|
5499
|
-
"grunt-vows": "^0.4.2",
|
|
5500
|
-
"grunt-webpack": "^5.0.0",
|
|
5501
|
-
jade: "~0.27.7",
|
|
5502
|
-
"jasmine-core": "^2.3.4",
|
|
5503
|
-
"jquery-mockjax": "^2.5.0",
|
|
5504
|
-
karma: "^6.4.2",
|
|
5505
|
-
"karma-chai": "^0.1.0",
|
|
5506
|
-
"karma-chrome-launcher": "^2.2.0",
|
|
5507
|
-
"karma-expect": "^1.1.0",
|
|
5508
|
-
"karma-firefox-launcher": "^0.1.6",
|
|
5509
|
-
"karma-html2js-preprocessor": "^1.1.0",
|
|
5510
|
-
"karma-jquery": "^0.1.0",
|
|
5511
|
-
"karma-mocha": "^2.0.1",
|
|
5512
|
-
"karma-mocha-reporter": "^2.2.5",
|
|
5513
|
-
"karma-requirejs": "^0.2.2",
|
|
5514
|
-
"karma-safari-launcher": "^0.1.1",
|
|
5515
|
-
"karma-sinon": "^1.0.4",
|
|
5516
|
-
"karma-sourcemap-loader": "^0.3.5",
|
|
5517
|
-
"karma-webpack": "^5.0.0",
|
|
5518
|
-
mocha: "^10.2.0",
|
|
5519
|
-
natives: "^1.1.6",
|
|
5520
|
-
nock: "^11.9.1",
|
|
5521
|
-
"node-libs-browser": "^0.5.2",
|
|
5522
|
-
prettier: "^3.2.5",
|
|
5523
|
-
requirejs: "^2.1.20",
|
|
5524
|
-
"script-loader": "0.6.1",
|
|
5525
|
-
sinon: "^8.1.1",
|
|
5526
|
-
stackframe: "^0.2.2",
|
|
5527
|
-
"strict-loader": "^1.2.0",
|
|
5528
|
-
"time-grunt": "^1.0.0",
|
|
5529
|
-
vows: "^0.8.3",
|
|
5530
|
-
webpack: "^5.88.2"
|
|
5531
|
-
};
|
|
5532
|
-
var optionalDependencies = {
|
|
5533
|
-
decache: "^3.0.5"
|
|
5534
|
-
};
|
|
5535
|
-
var scripts = {
|
|
5536
|
-
build: "./node_modules/.bin/grunt",
|
|
5537
|
-
test: "./node_modules/.bin/grunt test",
|
|
5538
|
-
"test-browser": "./node_modules/.bin/grunt test-browser",
|
|
5539
|
-
"test-server": "./node_modules/.bin/grunt test-server",
|
|
5540
|
-
test_ci: "./node_modules/.bin/grunt test",
|
|
5541
|
-
lint: "./node_modules/.bin/eslint . --ext .js"
|
|
5542
|
-
};
|
|
5543
|
-
var cdn = {
|
|
5544
|
-
host: "cdn.rollbar.com"
|
|
5545
|
-
};
|
|
5546
5678
|
var defaults = {
|
|
5547
|
-
endpoint: "api.rollbar.com/api/1/item/",
|
|
5548
5679
|
server: {
|
|
5549
5680
|
scrubHeaders: [
|
|
5550
5681
|
"authorization",
|
|
@@ -5586,43 +5717,10 @@ var defaults = {
|
|
|
5586
5717
|
"request.cookies"
|
|
5587
5718
|
]
|
|
5588
5719
|
},
|
|
5589
|
-
|
|
5590
|
-
rewriteFilenamePatterns: [
|
|
5591
|
-
"^.*/[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/[^/]*.app/(.*)$",
|
|
5592
|
-
"^.*/[0-9A-Fa-f]{64}/codepush_ios/(.*)$",
|
|
5593
|
-
"^.*/[0-9A-Fa-f]{64}/codepush_android/(.*)$",
|
|
5594
|
-
"^.*/[0-9A-Fa-f]{64}/CodePush/(.*)$"
|
|
5595
|
-
]
|
|
5596
|
-
},
|
|
5597
|
-
logLevel: "debug",
|
|
5598
|
-
reportLevel: "debug",
|
|
5599
|
-
uncaughtErrorLevel: "error",
|
|
5600
|
-
maxItems: 0,
|
|
5601
|
-
itemsPerMin: 60
|
|
5602
|
-
};
|
|
5603
|
-
var plugins = {
|
|
5604
|
-
jquery: {
|
|
5605
|
-
version: "0.0.8"
|
|
5606
|
-
}
|
|
5607
|
-
};
|
|
5720
|
+
reportLevel: "debug"};
|
|
5608
5721
|
var require$$2 = {
|
|
5609
|
-
name: name,
|
|
5610
5722
|
version: version,
|
|
5611
|
-
|
|
5612
|
-
description: description,
|
|
5613
|
-
keywords: keywords,
|
|
5614
|
-
license: license,
|
|
5615
|
-
main: main,
|
|
5616
|
-
browser: browser,
|
|
5617
|
-
types: types,
|
|
5618
|
-
dependencies: dependencies,
|
|
5619
|
-
devDependencies: devDependencies,
|
|
5620
|
-
optionalDependencies: optionalDependencies,
|
|
5621
|
-
scripts: scripts,
|
|
5622
|
-
cdn: cdn,
|
|
5623
|
-
defaults: defaults,
|
|
5624
|
-
plugins: plugins
|
|
5625
|
-
};
|
|
5723
|
+
defaults: defaults};
|
|
5626
5724
|
|
|
5627
5725
|
var merge_1;
|
|
5628
5726
|
var hasRequiredMerge;
|
|
@@ -5912,7 +6010,6 @@ function requireUtility () {
|
|
|
5912
6010
|
}
|
|
5913
6011
|
|
|
5914
6012
|
var parseUriOptions = {
|
|
5915
|
-
strictMode: false,
|
|
5916
6013
|
key: [
|
|
5917
6014
|
'source',
|
|
5918
6015
|
'protocol',
|
|
@@ -21427,7 +21524,7 @@ const reportErrorToRollbar = async (error) => {
|
|
|
21427
21524
|
|
|
21428
21525
|
const getSdkPackageVersionInfo = async (config) => {
|
|
21429
21526
|
try {
|
|
21430
|
-
const packageJsonFilePath = path.resolve(
|
|
21527
|
+
const packageJsonFilePath = path$1.resolve(
|
|
21431
21528
|
config.client.rootDir,
|
|
21432
21529
|
"package.json",
|
|
21433
21530
|
);
|
|
@@ -21487,8 +21584,8 @@ async function getUserData() {
|
|
|
21487
21584
|
}
|
|
21488
21585
|
}
|
|
21489
21586
|
|
|
21490
|
-
const LOG_DIR = path.join(process.cwd(), ".embeddable", "logs");
|
|
21491
|
-
const ERROR_LOG_FILE = path.join(LOG_DIR, "error.log");
|
|
21587
|
+
const LOG_DIR = path$1.join(process.cwd(), ".embeddable", "logs");
|
|
21588
|
+
const ERROR_LOG_FILE = path$1.join(LOG_DIR, "error.log");
|
|
21492
21589
|
const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5 MB
|
|
21493
21590
|
const MAX_LOG_FILES = 5;
|
|
21494
21591
|
async function initLogger(command) {
|
|
@@ -21580,8 +21677,9 @@ var build = async () => {
|
|
|
21580
21677
|
removeBuildSuccessFlag();
|
|
21581
21678
|
const config = await provideConfig();
|
|
21582
21679
|
await validate(config);
|
|
21583
|
-
await prepare(config);
|
|
21680
|
+
await prepare$1(config);
|
|
21584
21681
|
await buildTypes(config);
|
|
21682
|
+
await buildGlobalHooks(config);
|
|
21585
21683
|
for (const getPlugin of config.plugins) {
|
|
21586
21684
|
const plugin = getPlugin();
|
|
21587
21685
|
breadcrumbs.push(`${plugin.pluginName}: validate`);
|
|
@@ -21714,11 +21812,11 @@ async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
|
21714
21812
|
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
21715
21813
|
}
|
|
21716
21814
|
catch (e) {
|
|
21717
|
-
if ((_b = ctx.dev) === null || _b ===
|
|
21815
|
+
if ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch) {
|
|
21718
21816
|
workspaceSpinner.stop();
|
|
21719
21817
|
throw e;
|
|
21720
21818
|
}
|
|
21721
|
-
if (((_c = e.response) === null || _c ===
|
|
21819
|
+
if (((_c = e.response) === null || _c === void 0 ? void 0 : _c.status) === 401) {
|
|
21722
21820
|
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
21723
21821
|
}
|
|
21724
21822
|
else {
|
|
@@ -21728,6 +21826,7 @@ async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
|
21728
21826
|
}
|
|
21729
21827
|
}
|
|
21730
21828
|
async function selectWorkspace(ora, ctx, token) {
|
|
21829
|
+
var _a;
|
|
21731
21830
|
const workspaceSpinner = ora({
|
|
21732
21831
|
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
21733
21832
|
color: "green",
|
|
@@ -21740,12 +21839,15 @@ async function selectWorkspace(ora, ctx, token) {
|
|
|
21740
21839
|
process.exit(1);
|
|
21741
21840
|
}
|
|
21742
21841
|
workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
|
|
21842
|
+
const isDev = (_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch;
|
|
21743
21843
|
if (availableWorkspaces.length === 1) {
|
|
21744
21844
|
selectedWorkspace = availableWorkspaces[0];
|
|
21745
21845
|
}
|
|
21746
21846
|
else {
|
|
21747
21847
|
selectedWorkspace = await select({
|
|
21748
|
-
message:
|
|
21848
|
+
message: isDev
|
|
21849
|
+
? "Select workspace to use as primary"
|
|
21850
|
+
: "Select workspace to push changes",
|
|
21749
21851
|
choices: availableWorkspaces.map((workspace) => ({
|
|
21750
21852
|
name: `${workspace.name} (${workspace.workspaceId})`,
|
|
21751
21853
|
value: workspace,
|
|
@@ -21800,10 +21902,10 @@ var push = async () => {
|
|
|
21800
21902
|
spinnerPushing.succeed(`Published to ${workspaceName} using ${workspacePreviewUrl}`);
|
|
21801
21903
|
}
|
|
21802
21904
|
catch (error) {
|
|
21803
|
-
spinnerPushing === null || spinnerPushing ===
|
|
21905
|
+
spinnerPushing === null || spinnerPushing === void 0 ? void 0 : spinnerPushing.fail("Publishing failed");
|
|
21804
21906
|
await logError({ command: "push", breadcrumbs, error });
|
|
21805
21907
|
await reportErrorToRollbar(error);
|
|
21806
|
-
console.log(((_a = error.response) === null || _a ===
|
|
21908
|
+
console.log(((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error);
|
|
21807
21909
|
process.exit(1);
|
|
21808
21910
|
}
|
|
21809
21911
|
};
|
|
@@ -21858,10 +21960,10 @@ async function buildArchive(config) {
|
|
|
21858
21960
|
const cubeFilesList = await findFiles(config.client.modelsSrc || config.client.srcDir, CUBE_FILES);
|
|
21859
21961
|
const contextFilesList = await findFiles(config.client.presetsSrc || config.client.srcDir, PRESET_FILES);
|
|
21860
21962
|
filesList.push(...cubeFilesList.map((entry) => [
|
|
21861
|
-
path
|
|
21963
|
+
path.basename(entry[1]),
|
|
21862
21964
|
entry[1],
|
|
21863
21965
|
]), ...contextFilesList.map((entry) => [
|
|
21864
|
-
path
|
|
21966
|
+
path.basename(entry[1]),
|
|
21865
21967
|
entry[1],
|
|
21866
21968
|
]));
|
|
21867
21969
|
}
|
|
@@ -21874,7 +21976,7 @@ async function buildArchive(config) {
|
|
|
21874
21976
|
}
|
|
21875
21977
|
async function archive(args) {
|
|
21876
21978
|
const { ctx, filesList, isDev } = args;
|
|
21877
|
-
const output =
|
|
21979
|
+
const output = fsSync.createWriteStream(ctx.client.archiveFile);
|
|
21878
21980
|
const archive = archiver.create("zip", {
|
|
21879
21981
|
zlib: { level: 9 },
|
|
21880
21982
|
});
|
|
@@ -21892,7 +21994,7 @@ async function archive(args) {
|
|
|
21892
21994
|
}
|
|
21893
21995
|
await archive.finalize();
|
|
21894
21996
|
return new Promise((resolve, _reject) => {
|
|
21895
|
-
output.on("close", resolve);
|
|
21997
|
+
output.on("close", () => resolve());
|
|
21896
21998
|
});
|
|
21897
21999
|
}
|
|
21898
22000
|
async function createFormData(filePath, metadata) {
|
|
@@ -21952,7 +22054,7 @@ const buildWebComponent = async (config) => {
|
|
|
21952
22054
|
};
|
|
21953
22055
|
const addToGitingore = async () => {
|
|
21954
22056
|
try {
|
|
21955
|
-
const gitignorePath = path
|
|
22057
|
+
const gitignorePath = path.resolve(process.cwd(), ".gitignore");
|
|
21956
22058
|
const gitignoreContent = await fs.readFile(gitignorePath, "utf8");
|
|
21957
22059
|
if (!gitignoreContent.includes(BUILD_DEV_DIR)) {
|
|
21958
22060
|
await fs.appendFile(gitignorePath, `\n${BUILD_DEV_DIR}\n`);
|
|
@@ -21982,7 +22084,7 @@ var dev = async () => {
|
|
|
21982
22084
|
const logger = createNodeLogger();
|
|
21983
22085
|
const sys = createNodeSys({ process });
|
|
21984
22086
|
const defaultConfig = await provideConfig();
|
|
21985
|
-
const buildDir = path
|
|
22087
|
+
const buildDir = path.resolve(defaultConfig.client.rootDir, BUILD_DEV_DIR);
|
|
21986
22088
|
const config = {
|
|
21987
22089
|
...defaultConfig,
|
|
21988
22090
|
dev: {
|
|
@@ -21993,13 +22095,13 @@ var dev = async () => {
|
|
|
21993
22095
|
client: {
|
|
21994
22096
|
...defaultConfig.client,
|
|
21995
22097
|
buildDir,
|
|
21996
|
-
componentDir: path
|
|
21997
|
-
stencilBuild: path
|
|
21998
|
-
tmpDir: path
|
|
22098
|
+
componentDir: path.resolve(buildDir, "component"),
|
|
22099
|
+
stencilBuild: path.resolve(buildDir, "dist", "embeddable-wrapper"),
|
|
22100
|
+
tmpDir: path.resolve(defaultConfig.client.rootDir, ".embeddable-dev-tmp"),
|
|
21999
22101
|
},
|
|
22000
22102
|
};
|
|
22001
22103
|
breadcrumbs.push("prepare config");
|
|
22002
|
-
await prepare(config);
|
|
22104
|
+
await prepare$1(config);
|
|
22003
22105
|
const serve = serveStatic(config.client.buildDir);
|
|
22004
22106
|
let workspacePreparation = ora("Preparing workspace...").start();
|
|
22005
22107
|
breadcrumbs.push("get preview workspace");
|
|
@@ -22019,6 +22121,13 @@ var dev = async () => {
|
|
|
22019
22121
|
}
|
|
22020
22122
|
}
|
|
22021
22123
|
workspacePreparation.succeed("Workspace is ready");
|
|
22124
|
+
const { themeWatcher, lifecycleWatcher } = await buildGlobalHooks(config);
|
|
22125
|
+
if (themeWatcher) {
|
|
22126
|
+
await globalHookWatcher(themeWatcher, config);
|
|
22127
|
+
}
|
|
22128
|
+
if (lifecycleWatcher) {
|
|
22129
|
+
await globalHookWatcher(lifecycleWatcher, config);
|
|
22130
|
+
}
|
|
22022
22131
|
const server = http.createServer(async (request, res) => {
|
|
22023
22132
|
var _a;
|
|
22024
22133
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
@@ -22076,6 +22185,12 @@ var dev = async () => {
|
|
|
22076
22185
|
const customGlobalCssWatch = globalCssWatcher(config);
|
|
22077
22186
|
watchers.push(dataModelAndSecurityContextWatch);
|
|
22078
22187
|
watchers.push(customGlobalCssWatch);
|
|
22188
|
+
if (themeWatcher) {
|
|
22189
|
+
watchers.push(themeWatcher);
|
|
22190
|
+
}
|
|
22191
|
+
if (lifecycleWatcher) {
|
|
22192
|
+
watchers.push(lifecycleWatcher);
|
|
22193
|
+
}
|
|
22079
22194
|
});
|
|
22080
22195
|
}
|
|
22081
22196
|
catch (error) {
|
|
@@ -22098,13 +22213,33 @@ const configureWatcher = async (watcher, ctx) => {
|
|
|
22098
22213
|
changedFiles = [];
|
|
22099
22214
|
}
|
|
22100
22215
|
if (e.code === "ERROR") {
|
|
22101
|
-
sendMessage("componentsBuildError", { error: (_a = e.error) === null || _a ===
|
|
22216
|
+
sendMessage("componentsBuildError", { error: (_a = e.error) === null || _a === void 0 ? void 0 : _a.message });
|
|
22217
|
+
changedFiles = [];
|
|
22218
|
+
}
|
|
22219
|
+
});
|
|
22220
|
+
};
|
|
22221
|
+
const globalHookWatcher = async (watcher, ctx) => {
|
|
22222
|
+
watcher.on("change", (path) => {
|
|
22223
|
+
changedFiles.push(path);
|
|
22224
|
+
});
|
|
22225
|
+
watcher.on("event", async (e) => {
|
|
22226
|
+
var _a;
|
|
22227
|
+
if (e.code === "BUNDLE_START") {
|
|
22228
|
+
sendMessage("componentsBuildStart", { changedFiles });
|
|
22229
|
+
}
|
|
22230
|
+
if (e.code === "BUNDLE_END") {
|
|
22231
|
+
sendMessage("componentsBuildSuccess");
|
|
22232
|
+
changedFiles = [];
|
|
22233
|
+
}
|
|
22234
|
+
if (e.code === "ERROR") {
|
|
22235
|
+
sendMessage("componentsBuildError", { error: (_a = e.error) === null || _a === void 0 ? void 0 : _a.message });
|
|
22102
22236
|
changedFiles = [];
|
|
22103
22237
|
}
|
|
22104
22238
|
});
|
|
22105
22239
|
};
|
|
22106
22240
|
const sendMessage = (type, meta = {}) => {
|
|
22107
|
-
|
|
22241
|
+
var _a;
|
|
22242
|
+
(_a = wss === null || wss === void 0 ? void 0 : wss.clients) === null || _a === void 0 ? void 0 : _a.forEach((ws) => {
|
|
22108
22243
|
ws.send(JSON.stringify({ type, ...meta }));
|
|
22109
22244
|
});
|
|
22110
22245
|
};
|
|
@@ -22161,11 +22296,11 @@ const sendDataModelsAndContextsChanges = async (ctx) => {
|
|
|
22161
22296
|
const cubeFilesList = await findFiles(ctx.client.modelsSrc, CUBE_FILES);
|
|
22162
22297
|
const contextFilesList = await findFiles(ctx.client.presetsSrc, PRESET_FILES);
|
|
22163
22298
|
// Map the files to include their full filenames
|
|
22164
|
-
const filesList = [...cubeFilesList, ...contextFilesList].map((entry) => [path
|
|
22299
|
+
const filesList = [...cubeFilesList, ...contextFilesList].map((entry) => [path.basename(entry[1]), entry[1]]);
|
|
22165
22300
|
// add manifest to the archive
|
|
22166
22301
|
filesList.push([
|
|
22167
22302
|
"embeddable-manifest.json",
|
|
22168
|
-
path
|
|
22303
|
+
path.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
|
|
22169
22304
|
]);
|
|
22170
22305
|
await archive({
|
|
22171
22306
|
ctx,
|
|
@@ -22183,7 +22318,7 @@ const sendDataModelsAndContextsChanges = async (ctx) => {
|
|
|
22183
22318
|
const onClose = async (server, sys, watchers, config) => {
|
|
22184
22319
|
server.close();
|
|
22185
22320
|
wss.close();
|
|
22186
|
-
browserWindow === null || browserWindow ===
|
|
22321
|
+
browserWindow === null || browserWindow === void 0 ? void 0 : browserWindow.unref();
|
|
22187
22322
|
for (const watcher of watchers) {
|
|
22188
22323
|
if (watcher.close) {
|
|
22189
22324
|
await watcher.close();
|
|
@@ -22255,6 +22390,11 @@ const REGION_CONFIGS = {
|
|
|
22255
22390
|
authClientId: "dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V",
|
|
22256
22391
|
},
|
|
22257
22392
|
};
|
|
22393
|
+
const ComponentLibraryConfigSchema = z.object({
|
|
22394
|
+
name: z.string(),
|
|
22395
|
+
include: z.array(z.string()).optional(),
|
|
22396
|
+
exclude: z.array(z.string()).optional(),
|
|
22397
|
+
});
|
|
22258
22398
|
const embeddableConfigSchema = z
|
|
22259
22399
|
.object({
|
|
22260
22400
|
plugins: z.array(z.function()),
|
|
@@ -22275,6 +22415,11 @@ const embeddableConfigSchema = z
|
|
|
22275
22415
|
presetsSrc: z.string().optional(),
|
|
22276
22416
|
componentsSrc: z.string().optional(),
|
|
22277
22417
|
globalCss: z.string().optional(),
|
|
22418
|
+
customizationFile: z.string().optional(),
|
|
22419
|
+
lifecycleHooksFile: z.string().optional(),
|
|
22420
|
+
componentLibraries: z
|
|
22421
|
+
.union([z.array(z.string()), z.array(ComponentLibraryConfigSchema)])
|
|
22422
|
+
.optional(),
|
|
22278
22423
|
viteConfig: z
|
|
22279
22424
|
.object({
|
|
22280
22425
|
resolve: z
|
|
@@ -22298,25 +22443,25 @@ var defineConfig = (config) => {
|
|
|
22298
22443
|
if (errors.length > 0) {
|
|
22299
22444
|
throw new Error(`Invalid Embeddable Configuration: ${errors.join("\n")}}`);
|
|
22300
22445
|
}
|
|
22301
|
-
let { plugins, region = "legacy-US", pushModels = true, pushComponents = true, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, } = config;
|
|
22446
|
+
let { plugins, region = "legacy-US", pushModels = true, pushComponents = true, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, modelsSrc = "src", presetsSrc = "src", componentsSrc = "src", globalCss = "src/global.css", viteConfig = {}, rollupOptions = {}, componentLibraries = [], customizationFile = "embeddable.theme.ts", lifecycleHooksFile = "lifecycle.config.ts", } = config;
|
|
22302
22447
|
const regionConfig = REGION_CONFIGS[region];
|
|
22303
22448
|
const __dirname = import.meta.dirname;
|
|
22304
|
-
const coreRoot = path.resolve(__dirname, "..");
|
|
22449
|
+
const coreRoot = path$1.resolve(__dirname, "..");
|
|
22305
22450
|
const clientRoot = process.cwd();
|
|
22306
|
-
if (!path.isAbsolute(componentsSrc)) {
|
|
22307
|
-
componentsSrc = path.resolve(clientRoot, componentsSrc);
|
|
22451
|
+
if (!path$1.isAbsolute(componentsSrc)) {
|
|
22452
|
+
componentsSrc = path$1.resolve(clientRoot, componentsSrc);
|
|
22308
22453
|
if (!existsSync(componentsSrc)) {
|
|
22309
22454
|
throw new Error(`componentsSrc directory ${componentsSrc} does not exist`);
|
|
22310
22455
|
}
|
|
22311
22456
|
}
|
|
22312
|
-
if (modelsSrc && !path.isAbsolute(modelsSrc)) {
|
|
22313
|
-
modelsSrc = path.resolve(clientRoot, modelsSrc);
|
|
22457
|
+
if (modelsSrc && !path$1.isAbsolute(modelsSrc)) {
|
|
22458
|
+
modelsSrc = path$1.resolve(clientRoot, modelsSrc);
|
|
22314
22459
|
if (!existsSync(modelsSrc)) {
|
|
22315
22460
|
throw new Error(`modelsSrc directory ${modelsSrc} does not exist`);
|
|
22316
22461
|
}
|
|
22317
22462
|
}
|
|
22318
|
-
if (presetsSrc && !path.isAbsolute(presetsSrc)) {
|
|
22319
|
-
presetsSrc = path.resolve(clientRoot, presetsSrc);
|
|
22463
|
+
if (presetsSrc && !path$1.isAbsolute(presetsSrc)) {
|
|
22464
|
+
presetsSrc = path$1.resolve(clientRoot, presetsSrc);
|
|
22320
22465
|
if (!existsSync(presetsSrc)) {
|
|
22321
22466
|
throw new Error(`presetsSrc directory ${presetsSrc} does not exist`);
|
|
22322
22467
|
}
|
|
@@ -22324,26 +22469,29 @@ var defineConfig = (config) => {
|
|
|
22324
22469
|
return {
|
|
22325
22470
|
core: {
|
|
22326
22471
|
rootDir: coreRoot,
|
|
22327
|
-
templatesDir: path.resolve(coreRoot, "templates"),
|
|
22328
|
-
configsDir: path.resolve(coreRoot, "configs"),
|
|
22472
|
+
templatesDir: path$1.resolve(coreRoot, "templates"),
|
|
22473
|
+
configsDir: path$1.resolve(coreRoot, "configs"),
|
|
22329
22474
|
},
|
|
22330
22475
|
client: {
|
|
22331
22476
|
rootDir: clientRoot,
|
|
22332
|
-
srcDir: path.resolve(clientRoot, componentsSrc),
|
|
22333
|
-
modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
|
|
22334
|
-
presetsSrc: presetsSrc ? path.resolve(clientRoot, presetsSrc) : undefined,
|
|
22335
|
-
buildDir: path.resolve(clientRoot, ".embeddable-build"),
|
|
22336
|
-
tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
|
|
22337
|
-
globalCss: path.resolve(clientRoot, globalCss),
|
|
22338
|
-
componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
|
|
22339
|
-
stencilBuild: path.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
|
|
22340
|
-
archiveFile: path.resolve(clientRoot, "embeddable-build.zip"),
|
|
22477
|
+
srcDir: path$1.resolve(clientRoot, componentsSrc),
|
|
22478
|
+
modelsSrc: modelsSrc ? path$1.resolve(clientRoot, modelsSrc) : undefined,
|
|
22479
|
+
presetsSrc: presetsSrc ? path$1.resolve(clientRoot, presetsSrc) : undefined,
|
|
22480
|
+
buildDir: path$1.resolve(clientRoot, ".embeddable-build"),
|
|
22481
|
+
tmpDir: path$1.resolve(clientRoot, ".embeddable-tmp"),
|
|
22482
|
+
globalCss: path$1.resolve(clientRoot, globalCss),
|
|
22483
|
+
componentDir: path$1.resolve(clientRoot, ".embeddable-build", "component"),
|
|
22484
|
+
stencilBuild: path$1.resolve(clientRoot, ".embeddable-build", "dist", "embeddable-wrapper"),
|
|
22485
|
+
archiveFile: path$1.resolve(clientRoot, "embeddable-build.zip"),
|
|
22341
22486
|
errorFallbackComponent: errorFallbackComponent
|
|
22342
|
-
? path.resolve(clientRoot, errorFallbackComponent)
|
|
22487
|
+
? path$1.resolve(clientRoot, errorFallbackComponent)
|
|
22343
22488
|
: undefined,
|
|
22344
22489
|
bundleHash: undefined, // This will be set by the build process
|
|
22345
22490
|
viteConfig,
|
|
22346
22491
|
rollupOptions,
|
|
22492
|
+
componentLibraries,
|
|
22493
|
+
customizationFile: path$1.resolve(clientRoot, customizationFile),
|
|
22494
|
+
lifecycleHooksFile: path$1.resolve(clientRoot, lifecycleHooksFile),
|
|
22347
22495
|
},
|
|
22348
22496
|
outputOptions: {
|
|
22349
22497
|
typesEntryPointFilename: "embeddable-types-entry-point.js",
|
|
@@ -22356,17 +22504,53 @@ var defineConfig = (config) => {
|
|
|
22356
22504
|
},
|
|
22357
22505
|
pushModels,
|
|
22358
22506
|
pushComponents,
|
|
22359
|
-
pushBaseUrl: pushBaseUrl !== null && pushBaseUrl !==
|
|
22360
|
-
audienceUrl: audienceUrl !== null && audienceUrl !==
|
|
22361
|
-
previewBaseUrl: previewBaseUrl !== null && previewBaseUrl !==
|
|
22362
|
-
authDomain: authDomain !== null && authDomain !==
|
|
22363
|
-
authClientId: authClientId !== null && authClientId !==
|
|
22364
|
-
applicationEnvironment: applicationEnvironment !== null && applicationEnvironment !==
|
|
22365
|
-
rollbarAccessToken: rollbarAccessToken !== null && rollbarAccessToken !==
|
|
22507
|
+
pushBaseUrl: pushBaseUrl !== null && pushBaseUrl !== void 0 ? pushBaseUrl : regionConfig.pushBaseUrl,
|
|
22508
|
+
audienceUrl: audienceUrl !== null && audienceUrl !== void 0 ? audienceUrl : regionConfig.audienceUrl,
|
|
22509
|
+
previewBaseUrl: previewBaseUrl !== null && previewBaseUrl !== void 0 ? previewBaseUrl : regionConfig.previewBaseUrl,
|
|
22510
|
+
authDomain: authDomain !== null && authDomain !== void 0 ? authDomain : regionConfig.authDomain,
|
|
22511
|
+
authClientId: authClientId !== null && authClientId !== void 0 ? authClientId : regionConfig.authClientId,
|
|
22512
|
+
applicationEnvironment: applicationEnvironment !== null && applicationEnvironment !== void 0 ? applicationEnvironment : "production",
|
|
22513
|
+
rollbarAccessToken: rollbarAccessToken !== null && rollbarAccessToken !== void 0 ? rollbarAccessToken : "5c6028038d844bf1835a0f4db5f55d9e",
|
|
22366
22514
|
plugins,
|
|
22367
22515
|
};
|
|
22368
22516
|
};
|
|
22369
22517
|
|
|
22518
|
+
var buildPackage = async () => {
|
|
22519
|
+
await initLogger("package");
|
|
22520
|
+
const breadcrumbs = [];
|
|
22521
|
+
try {
|
|
22522
|
+
const startTime = process.hrtime();
|
|
22523
|
+
await checkNodeVersion();
|
|
22524
|
+
breadcrumbs.push("checkNodeVersion");
|
|
22525
|
+
await removeBuildSuccessFlag();
|
|
22526
|
+
const config = await provideConfig();
|
|
22527
|
+
config.client.buildDir = path$1.resolve(config.client.rootDir, "dist");
|
|
22528
|
+
await prepare(config);
|
|
22529
|
+
await buildTypes(config);
|
|
22530
|
+
await buildGlobalHooks(config);
|
|
22531
|
+
for (const getPlugin of config.plugins) {
|
|
22532
|
+
const plugin = getPlugin();
|
|
22533
|
+
breadcrumbs.push(`${plugin.pluginName}: validate`);
|
|
22534
|
+
await plugin.validate(config);
|
|
22535
|
+
breadcrumbs.push(`${plugin.pluginName}: buildPackage`);
|
|
22536
|
+
await plugin.buildPackage(config);
|
|
22537
|
+
}
|
|
22538
|
+
// Calculating build time in seconds
|
|
22539
|
+
config.buildTime = process.hrtime(startTime);
|
|
22540
|
+
await storeBuildSuccessFlag();
|
|
22541
|
+
}
|
|
22542
|
+
catch (error) {
|
|
22543
|
+
await logError({ command: "package", breadcrumbs, error });
|
|
22544
|
+
console.log(error);
|
|
22545
|
+
process.exit(1);
|
|
22546
|
+
}
|
|
22547
|
+
};
|
|
22548
|
+
const prepare = async (config) => {
|
|
22549
|
+
if (fsSync.existsSync(config.client.buildDir))
|
|
22550
|
+
await fs.rm(config.client.buildDir, { recursive: true });
|
|
22551
|
+
await fs.mkdir(config.client.buildDir);
|
|
22552
|
+
};
|
|
22553
|
+
|
|
22370
22554
|
var __accessCheck = (obj, member, msg) => {
|
|
22371
22555
|
if (!member.has(obj))
|
|
22372
22556
|
throw TypeError("Cannot " + msg);
|
|
@@ -22550,7 +22734,7 @@ var _Blob = class _Blob {
|
|
|
22550
22734
|
__privateSet(this, _size, __privateGet(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));
|
|
22551
22735
|
__privateGet(this, _parts).push(part);
|
|
22552
22736
|
}
|
|
22553
|
-
const type = options.type ===
|
|
22737
|
+
const type = options.type === void 0 ? "" : String(options.type);
|
|
22554
22738
|
__privateSet(this, _type, /^[\x20-\x7E]*$/.test(type) ? type : "");
|
|
22555
22739
|
}
|
|
22556
22740
|
static [Symbol.hasInstance](value) {
|
|
@@ -22656,7 +22840,7 @@ var File = class extends Blob {
|
|
|
22656
22840
|
/**
|
|
22657
22841
|
* Returns the name of the file referenced by the File object.
|
|
22658
22842
|
*/
|
|
22659
|
-
__privateAdd(this, _name,
|
|
22843
|
+
__privateAdd(this, _name, void 0);
|
|
22660
22844
|
/**
|
|
22661
22845
|
* The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
|
|
22662
22846
|
*/
|
|
@@ -22667,7 +22851,7 @@ var File = class extends Blob {
|
|
|
22667
22851
|
);
|
|
22668
22852
|
}
|
|
22669
22853
|
__privateSet(this, _name, String(name));
|
|
22670
|
-
const lastModified = options.lastModified ===
|
|
22854
|
+
const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
|
|
22671
22855
|
if (!Number.isNaN(lastModified)) {
|
|
22672
22856
|
__privateSet(this, _lastModified, lastModified);
|
|
22673
22857
|
}
|
|
@@ -22702,8 +22886,8 @@ _lastModified = new WeakMap();
|
|
|
22702
22886
|
var _path, _start;
|
|
22703
22887
|
var _FileFromPath = class _FileFromPath {
|
|
22704
22888
|
constructor(input) {
|
|
22705
|
-
__privateAdd(this, _path,
|
|
22706
|
-
__privateAdd(this, _start,
|
|
22889
|
+
__privateAdd(this, _path, void 0);
|
|
22890
|
+
__privateAdd(this, _start, void 0);
|
|
22707
22891
|
__privateSet(this, _path, input.path);
|
|
22708
22892
|
__privateSet(this, _start, input.start || 0);
|
|
22709
22893
|
this.name = basename(__privateGet(this, _path));
|
|
@@ -22743,7 +22927,7 @@ var FileFromPath = _FileFromPath;
|
|
|
22743
22927
|
function createFileFromPath(path, { mtimeMs, size }, filenameOrOptions, options = {}) {
|
|
22744
22928
|
let filename;
|
|
22745
22929
|
if (isObject(filenameOrOptions)) {
|
|
22746
|
-
[options, filename] = [filenameOrOptions,
|
|
22930
|
+
[options, filename] = [filenameOrOptions, void 0];
|
|
22747
22931
|
} else {
|
|
22748
22932
|
filename = filenameOrOptions;
|
|
22749
22933
|
}
|
|
@@ -22767,5 +22951,5 @@ var fileFromPath$1 = /*#__PURE__*/Object.freeze({
|
|
|
22767
22951
|
fileFromPath: fileFromPath
|
|
22768
22952
|
});
|
|
22769
22953
|
|
|
22770
|
-
export { build, defineConfig, dev, login, push };
|
|
22954
|
+
export { build, buildPackage, defineConfig, dev, login, push };
|
|
22771
22955
|
//# sourceMappingURL=index.esm.js.map
|