@embeddable.com/sdk-react 3.0.2 → 3.1.0-next.0
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 +13 -12
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +13 -13
- package/lib/index.js.map +1 -1
- package/lib/loadComponentMeta.d.ts +4 -1
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -6,8 +6,6 @@ var path$1 = require('path');
|
|
|
6
6
|
var vite = require('vite');
|
|
7
7
|
var viteReactPlugin = require('@vitejs/plugin-react');
|
|
8
8
|
var fs = require('node:fs/promises');
|
|
9
|
-
var url = require('node:url');
|
|
10
|
-
var astring = require('astring');
|
|
11
9
|
require('node:child_process');
|
|
12
10
|
var zod = require('zod');
|
|
13
11
|
var parser = require('@babel/parser');
|
|
@@ -36,7 +34,6 @@ var fs__namespace$2 = /*#__PURE__*/_interopNamespaceDefault(fs$2);
|
|
|
36
34
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$1);
|
|
37
35
|
var vite__namespace = /*#__PURE__*/_interopNamespaceDefault(vite);
|
|
38
36
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
39
|
-
var url__namespace = /*#__PURE__*/_interopNamespaceDefault(url);
|
|
40
37
|
var fs__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(fs$1);
|
|
41
38
|
|
|
42
39
|
var createContext = (pluginRoot, coreCtx) => {
|
|
@@ -51,13 +48,8 @@ var createContext = (pluginRoot, coreCtx) => {
|
|
|
51
48
|
};
|
|
52
49
|
};
|
|
53
50
|
|
|
54
|
-
const loadComponentMeta = async (moduleId, ast) => {
|
|
55
|
-
const
|
|
56
|
-
.replace(".emb.", ".emb-temp.")
|
|
57
|
-
.replace(/\.ts$/, ".js");
|
|
58
|
-
await fs__namespace.writeFile(tempFilePath, astring.generate(ast));
|
|
59
|
-
const module = await import(url__namespace.pathToFileURL(tempFilePath).href + `?${Date.now()}`);
|
|
60
|
-
await fs__namespace.rm(tempFilePath);
|
|
51
|
+
const loadComponentMeta = async ({ moduleId, ast, }) => {
|
|
52
|
+
const module = await import(moduleId);
|
|
61
53
|
return module.meta;
|
|
62
54
|
};
|
|
63
55
|
|
|
@@ -73,7 +65,10 @@ var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, component
|
|
|
73
65
|
var _a;
|
|
74
66
|
if (componentFileRegex.test(moduleInfo.id) &&
|
|
75
67
|
((_a = moduleInfo.code) === null || _a === void 0 ? void 0 : _a.includes(searchEntry))) {
|
|
76
|
-
const meta = await loadComponentMeta(
|
|
68
|
+
const meta = await loadComponentMeta({
|
|
69
|
+
moduleId: moduleInfo.id,
|
|
70
|
+
ast: moduleInfo.ast,
|
|
71
|
+
});
|
|
77
72
|
const configJSON = JSON.stringify(meta, (_key, value) => typeof value === "object" &&
|
|
78
73
|
value !== null &&
|
|
79
74
|
"__embeddableType" in value
|
|
@@ -873,7 +868,10 @@ var validateComponentMetaPlugin = (componentFileRegex) => {
|
|
|
873
868
|
? getModuleType(moduleInfo)
|
|
874
869
|
: null;
|
|
875
870
|
if (moduleType) {
|
|
876
|
-
const meta = await loadComponentMeta(
|
|
871
|
+
const meta = await loadComponentMeta({
|
|
872
|
+
moduleId: moduleInfo.id,
|
|
873
|
+
ast: moduleInfo.ast,
|
|
874
|
+
});
|
|
877
875
|
metaConfigs.push({
|
|
878
876
|
moduleId: moduleInfo.id,
|
|
879
877
|
meta,
|
|
@@ -1154,7 +1152,9 @@ var build = async (ctx) => {
|
|
|
1154
1152
|
return await generate(ctx);
|
|
1155
1153
|
};
|
|
1156
1154
|
|
|
1157
|
-
var cleanup = async (ctx) =>
|
|
1155
|
+
var cleanup = async (ctx) => {
|
|
1156
|
+
await fs.rm(path.resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename));
|
|
1157
|
+
};
|
|
1158
1158
|
|
|
1159
1159
|
var index = () => {
|
|
1160
1160
|
return {
|