@embeddable.com/sdk-react 3.10.7-next.5 → 3.10.7
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/index.esm.js +32 -30
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +29 -26
- package/lib/index.js.map +1 -1
- package/lib/utils/EntrypointModifier.d.ts +1 -1
- package/package.json +3 -3
- package/lib/dynamicImportHandler.js +0 -14
- package/lib/plugin.d.ts +0 -21
- package/lib/proxyHandler.d.ts +0 -4
- package/lib/utils/modules.d.ts +0 -13
- package/lib/validate/errorFormatter.d.ts +0 -3
package/lib/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var path = require('node:path');
|
|
|
4
4
|
var fs$2 = require('fs/promises');
|
|
5
5
|
var path$1 = require('path');
|
|
6
6
|
var vite = require('vite');
|
|
7
|
-
var ora = require('ora');
|
|
8
7
|
var viteReactPlugin = require('@vitejs/plugin-react');
|
|
9
8
|
var fs = require('node:fs/promises');
|
|
10
9
|
var url = require('node:url');
|
|
@@ -315,7 +314,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
315
314
|
var errorUtil;
|
|
316
315
|
(function (errorUtil) {
|
|
317
316
|
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
318
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message ===
|
|
317
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
319
318
|
})(errorUtil || (errorUtil = {}));
|
|
320
319
|
var ZodFirstPartyTypeKind;
|
|
321
320
|
(function (ZodFirstPartyTypeKind) {
|
|
@@ -411,7 +410,7 @@ var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, component
|
|
|
411
410
|
moduleParsed: async (moduleInfo) => {
|
|
412
411
|
var _a;
|
|
413
412
|
if (componentFileRegex.test(moduleInfo.id) &&
|
|
414
|
-
((_a = moduleInfo.code) === null || _a ===
|
|
413
|
+
((_a = moduleInfo.code) === null || _a === void 0 ? void 0 : _a.includes(searchEntry))) {
|
|
415
414
|
try {
|
|
416
415
|
const meta = await loadComponentMeta(moduleInfo.id);
|
|
417
416
|
const configJSON = JSON.stringify(meta, (_key, value) => typeof value === "object" &&
|
|
@@ -484,7 +483,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
484
483
|
|
|
485
484
|
var DEFAULT_LOCALE = "en-US";
|
|
486
485
|
var createBuiltInType = function (name, typeConfig) {
|
|
487
|
-
if (typeConfig ===
|
|
486
|
+
if (typeConfig === void 0) { typeConfig = {}; }
|
|
488
487
|
return ({
|
|
489
488
|
__embeddableType: "built-in",
|
|
490
489
|
toString: function () { return name; },
|
|
@@ -530,7 +529,7 @@ createBuiltInType("number", {
|
|
|
530
529
|
var _a;
|
|
531
530
|
return Array.isArray(value)
|
|
532
531
|
? "[".concat(value.join(","), "]")
|
|
533
|
-
: (
|
|
532
|
+
: (_a = value === null || value === void 0 ? void 0 : value.toLocaleString(DEFAULT_LOCALE)) !== null && _a !== void 0 ? _a : "";
|
|
534
533
|
},
|
|
535
534
|
});
|
|
536
535
|
createBuiltInType("boolean", {
|
|
@@ -539,19 +538,19 @@ createBuiltInType("boolean", {
|
|
|
539
538
|
});
|
|
540
539
|
createBuiltInType("time", {
|
|
541
540
|
transform: function (value) {
|
|
542
|
-
var date = (value === null || value ===
|
|
541
|
+
var date = (value === null || value === void 0 ? void 0 : value.date) ? new Date(value.date) : undefined;
|
|
543
542
|
var isValid = date && date.toString() !== "Invalid Date";
|
|
544
543
|
return {
|
|
545
544
|
date: isValid ? date : undefined,
|
|
546
|
-
relativeTimeString: value === null || value ===
|
|
545
|
+
relativeTimeString: value === null || value === void 0 ? void 0 : value.relativeTimeString,
|
|
547
546
|
};
|
|
548
547
|
},
|
|
549
548
|
optionLabel: function (value) {
|
|
550
549
|
var _a, _b;
|
|
551
550
|
if (!value)
|
|
552
551
|
return "";
|
|
553
|
-
if (value === null || value ===
|
|
554
|
-
return ((_b = (_a = value.date) === null || _a ===
|
|
552
|
+
if (value === null || value === void 0 ? void 0 : value.date) {
|
|
553
|
+
return ((_b = (_a = value.date) === null || _a === void 0 ? void 0 : _a.toLocaleDateString(DEFAULT_LOCALE)) !== null && _b !== void 0 ? _b : value.date.toLocaleString());
|
|
555
554
|
}
|
|
556
555
|
return value.relativeTimeString;
|
|
557
556
|
},
|
|
@@ -561,23 +560,23 @@ createBuiltInType("timeRange", {
|
|
|
561
560
|
// Return undefined instead of a null populated object
|
|
562
561
|
if (!value)
|
|
563
562
|
return undefined;
|
|
564
|
-
var _a = [value === null || value ===
|
|
563
|
+
var _a = [value === null || value === void 0 ? void 0 : value.from, value === null || value === void 0 ? void 0 : value.to], from = _a[0], to = _a[1];
|
|
565
564
|
var fromDate = new Date(from);
|
|
566
565
|
var toDate = new Date(to);
|
|
567
566
|
return {
|
|
568
567
|
from: fromDate.toString() !== "Invalid Date" ? fromDate : undefined,
|
|
569
568
|
to: toDate.toString() !== "Invalid Date" ? toDate : undefined,
|
|
570
|
-
relativeTimeString: value === null || value ===
|
|
569
|
+
relativeTimeString: value === null || value === void 0 ? void 0 : value.relativeTimeString,
|
|
571
570
|
};
|
|
572
571
|
},
|
|
573
572
|
optionLabel: function (value) {
|
|
574
573
|
var _a, _b, _c, _d, _e, _f;
|
|
575
574
|
if (!value)
|
|
576
575
|
return "";
|
|
577
|
-
if ((value === null || value ===
|
|
578
|
-
return "".concat((_b = (_a = value.from) === null || _a ===
|
|
576
|
+
if ((value === null || value === void 0 ? void 0 : value.from) && (value === null || value === void 0 ? void 0 : value.to)) {
|
|
577
|
+
return "".concat((_b = (_a = value.from) === null || _a === void 0 ? void 0 : _a.toLocaleDateString(DEFAULT_LOCALE)) !== null && _b !== void 0 ? _b : (_c = value.from) === null || _c === void 0 ? void 0 : _c.toLocaleString(), ",").concat((_e = (_d = value.to) === null || _d === void 0 ? void 0 : _d.toLocaleDateString(DEFAULT_LOCALE)) !== null && _e !== void 0 ? _e : (_f = value.to) === null || _f === void 0 ? void 0 : _f.toLocaleString());
|
|
579
578
|
}
|
|
580
|
-
return value === null || value ===
|
|
579
|
+
return value === null || value === void 0 ? void 0 : value.relativeTimeString;
|
|
581
580
|
},
|
|
582
581
|
});
|
|
583
582
|
createBuiltInType("granularity", {
|
|
@@ -724,7 +723,7 @@ const validateComponentProps = (metaInfo) => {
|
|
|
724
723
|
var _a;
|
|
725
724
|
const componentConfig = path.node.declaration
|
|
726
725
|
.arguments[2];
|
|
727
|
-
const propsNode = (_a = componentConfig.properties) === null || _a ===
|
|
726
|
+
const propsNode = (_a = componentConfig.properties) === null || _a === void 0 ? void 0 : _a.find((x) => { var _a; return ((_a = x.key) === null || _a === void 0 ? void 0 : _a.name) === "props"; });
|
|
728
727
|
// There is no props defined
|
|
729
728
|
if (!propsNode)
|
|
730
729
|
return;
|
|
@@ -753,7 +752,7 @@ const validateComponentProps = (metaInfo) => {
|
|
|
753
752
|
};
|
|
754
753
|
const validateComponentEvents = (metaInfo) => {
|
|
755
754
|
var _a, _b;
|
|
756
|
-
const definedEvents = (_b = (_a = metaInfo.meta.events) === null || _a ===
|
|
755
|
+
const definedEvents = (_b = (_a = metaInfo.meta.events) === null || _a === void 0 ? void 0 : _a.map((e) => e.name)) !== null && _b !== void 0 ? _b : [];
|
|
757
756
|
let implementedEvents = [];
|
|
758
757
|
const errors = [];
|
|
759
758
|
parseAndTraverse(metaInfo.moduleInfo.code, {
|
|
@@ -761,9 +760,9 @@ const validateComponentEvents = (metaInfo) => {
|
|
|
761
760
|
var _a, _b, _c, _d;
|
|
762
761
|
const componentConfig = path.node.declaration
|
|
763
762
|
.arguments[2];
|
|
764
|
-
const eventsNode = (_a = componentConfig.properties) === null || _a ===
|
|
763
|
+
const eventsNode = (_a = componentConfig.properties) === null || _a === void 0 ? void 0 : _a.find((p) => { var _a; return ((_a = p.key) === null || _a === void 0 ? void 0 : _a.name) === "events"; });
|
|
765
764
|
implementedEvents =
|
|
766
|
-
(_d = (_c = (_b = eventsNode === null || eventsNode ===
|
|
765
|
+
(_d = (_c = (_b = eventsNode === null || eventsNode === void 0 ? void 0 : eventsNode.value) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.map((p) => p.key.name)) !== null && _d !== void 0 ? _d : [];
|
|
767
766
|
},
|
|
768
767
|
});
|
|
769
768
|
const definedEventsSet = new Set(definedEvents);
|
|
@@ -810,7 +809,7 @@ const validateVariableInputs = (meta) => {
|
|
|
810
809
|
const inputs = variableConfig.inputs;
|
|
811
810
|
if (inputs) {
|
|
812
811
|
inputs.forEach((input, inputIdx) => {
|
|
813
|
-
const definedInput = definedInputs === null || definedInputs ===
|
|
812
|
+
const definedInput = definedInputs === null || definedInputs === void 0 ? void 0 : definedInputs.find((d) => d.name === input);
|
|
814
813
|
if (!definedInput) {
|
|
815
814
|
const path = formatErrorPath(["variables", idx, "inputs", inputIdx]);
|
|
816
815
|
errors.push(`${path}: input "${input}" is not defined`);
|
|
@@ -830,7 +829,7 @@ const validateVariableEvents = (meta) => {
|
|
|
830
829
|
const events = variableConfig.events;
|
|
831
830
|
if (events) {
|
|
832
831
|
events.forEach((event, eventIdx) => {
|
|
833
|
-
const definedEvent = definedEvents === null || definedEvents ===
|
|
832
|
+
const definedEvent = definedEvents === null || definedEvents === void 0 ? void 0 : definedEvents.find((d) => d.name === event.name);
|
|
834
833
|
if (!definedEvent) {
|
|
835
834
|
const path = formatErrorPath([
|
|
836
835
|
"variables",
|
|
@@ -843,7 +842,7 @@ const validateVariableEvents = (meta) => {
|
|
|
843
842
|
return;
|
|
844
843
|
}
|
|
845
844
|
const definedProperties = definedEvent.properties;
|
|
846
|
-
const definedProperty = definedProperties === null || definedProperties ===
|
|
845
|
+
const definedProperty = definedProperties === null || definedProperties === void 0 ? void 0 : definedProperties.find((p) => p.name === event.property);
|
|
847
846
|
if (!definedProperty) {
|
|
848
847
|
const path = formatErrorPath([
|
|
849
848
|
"variables",
|
|
@@ -876,10 +875,10 @@ const validators = {
|
|
|
876
875
|
};
|
|
877
876
|
const getModuleType = (moduleInfo) => {
|
|
878
877
|
var _a, _b;
|
|
879
|
-
if ((_a = moduleInfo.code) === null || _a ===
|
|
878
|
+
if ((_a = moduleInfo.code) === null || _a === void 0 ? void 0 : _a.includes("defineComponent")) {
|
|
880
879
|
return COMPONENT;
|
|
881
880
|
}
|
|
882
|
-
else if ((_b = moduleInfo.code) === null || _b ===
|
|
881
|
+
else if ((_b = moduleInfo.code) === null || _b === void 0 ? void 0 : _b.includes("defineEditor")) {
|
|
883
882
|
return EDITOR;
|
|
884
883
|
}
|
|
885
884
|
else {
|
|
@@ -942,7 +941,7 @@ const styledComponentsEntrypointModifier = {
|
|
|
942
941
|
var _a;
|
|
943
942
|
const packageJsonFilePath = path__namespace.resolve(ctx.client.rootDir, "package.json");
|
|
944
943
|
const packageJson = require(packageJsonFilePath);
|
|
945
|
-
return !!((_a = packageJson.dependencies) === null || _a ===
|
|
944
|
+
return !!((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a["styled-components"]);
|
|
946
945
|
},
|
|
947
946
|
};
|
|
948
947
|
|
|
@@ -950,6 +949,7 @@ const entrypointModifiers = [
|
|
|
950
949
|
styledComponentsEntrypointModifier,
|
|
951
950
|
];
|
|
952
951
|
|
|
952
|
+
const oraP$1 = import('ora');
|
|
953
953
|
function findFilesWithWrongUsage(directory, pattern, mustEndWith = []) {
|
|
954
954
|
const files = fs__namespace$1.readdirSync(directory);
|
|
955
955
|
const result = [];
|
|
@@ -996,6 +996,7 @@ const regexCubeFunction = /cube\(/;
|
|
|
996
996
|
const regexCubes = /cubes:/;
|
|
997
997
|
const usageValidator = async (directory) => {
|
|
998
998
|
let isValid = true;
|
|
999
|
+
const ora = (await oraP$1).default;
|
|
999
1000
|
const progress = ora("React: function usage validating...").start();
|
|
1000
1001
|
// defineComponent function
|
|
1001
1002
|
const filesWithWrongDefineComponentFunctionUsage = findFilesWithWrongUsage(directory, regexDefineComponentFunction, [".emb.js", ".emb.ts"]);
|
|
@@ -1063,14 +1064,16 @@ const usageValidator = async (directory) => {
|
|
|
1063
1064
|
: process.exit(1);
|
|
1064
1065
|
};
|
|
1065
1066
|
|
|
1067
|
+
const oraP = import('ora');
|
|
1066
1068
|
const EMB_FILE_REGEX = /^(.*)(?<!\.type|\.options)\.emb\.[jt]s$/;
|
|
1067
1069
|
var generate = async (ctx) => {
|
|
1068
1070
|
var _a;
|
|
1071
|
+
const ora = (await oraP).default;
|
|
1069
1072
|
await usageValidator(ctx.client.srcDir);
|
|
1070
1073
|
const filesList = await findFiles(ctx.client.srcDir, EMB_FILE_REGEX);
|
|
1071
1074
|
await prepareEntrypoint(ctx, filesList);
|
|
1072
1075
|
let result;
|
|
1073
|
-
if ((_a = ctx.dev) === null || _a ===
|
|
1076
|
+
if ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch) {
|
|
1074
1077
|
result = await runViteWatch(ctx);
|
|
1075
1078
|
}
|
|
1076
1079
|
else {
|
|
@@ -1086,7 +1089,7 @@ async function runViteBuild(ctx, watch = null) {
|
|
|
1086
1089
|
logLevel: !!watch ? "info" : "error",
|
|
1087
1090
|
resolve: {
|
|
1088
1091
|
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
|
|
1089
|
-
...(_a = ctx.client.viteConfig) === null || _a ===
|
|
1092
|
+
...(_a = ctx.client.viteConfig) === null || _a === void 0 ? void 0 : _a.resolve,
|
|
1090
1093
|
},
|
|
1091
1094
|
plugins: [
|
|
1092
1095
|
viteReactPlugin(),
|