@embeddable.com/sdk-core 4.4.0-next.0 → 4.4.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/defineConfig.d.ts +4 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +10 -4
- package/lib/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/defineConfig.ts +5 -0
- package/src/dev.test.ts +28 -0
- package/src/dev.ts +1 -0
- package/src/generate.test.ts +65 -3
- package/src/generate.ts +5 -2
- package/src/index.ts +1 -1
- package/src/push.test.ts +49 -2
- package/src/push.ts +2 -0
- package/templates/component.tsx.template +13 -4
package/lib/defineConfig.d.ts
CHANGED
|
@@ -100,8 +100,12 @@ export type ResolvedEmbeddableConfig = {
|
|
|
100
100
|
buildName: string;
|
|
101
101
|
componentsEntryPointFilename: string;
|
|
102
102
|
};
|
|
103
|
+
pluginFlags?: PluginFlags;
|
|
103
104
|
};
|
|
104
105
|
};
|
|
106
|
+
export type PluginFlags = {
|
|
107
|
+
supportsOnComponentReadyHook: boolean;
|
|
108
|
+
};
|
|
105
109
|
export declare const embeddableConfigSchema: z.ZodObject<{
|
|
106
110
|
plugins: z.ZodArray<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, "many">;
|
|
107
111
|
region: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"EU">, z.ZodLiteral<"US">, z.ZodLiteral<"legacy-US">]>>;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { default as push } from "./push";
|
|
|
4
4
|
export { default as dev } from "./dev";
|
|
5
5
|
export { default as defineConfig } from "./defineConfig";
|
|
6
6
|
export { default as buildPackage } from "./buildPackage";
|
|
7
|
-
export type { ResolvedEmbeddableConfig } from "./defineConfig";
|
|
7
|
+
export type { ResolvedEmbeddableConfig, PluginFlags } from "./defineConfig";
|
package/lib/index.esm.js
CHANGED
|
@@ -609,6 +609,7 @@ async function createComponentDir(dir) {
|
|
|
609
609
|
|
|
610
610
|
const STYLE_IMPORTS_TOKEN = "{{STYLES_IMPORT}}";
|
|
611
611
|
const RENDER_IMPORT_TOKEN = "{{RENDER_IMPORT}}";
|
|
612
|
+
const PLUGIN_FLAGS_TOKEN = "{{PLUGIN_FLAGS}}";
|
|
612
613
|
// stencil doesn't support dynamic component tag name, so we need to replace it manually
|
|
613
614
|
const COMPONENT_TAG_TOKEN = "replace-this-with-component-name";
|
|
614
615
|
let triggeredBuildCount = 0;
|
|
@@ -697,16 +698,18 @@ async function injectCSS(ctx, pluginName) {
|
|
|
697
698
|
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "style.css"), content.replace(STYLE_IMPORTS_TOKEN, cssFilesImportsStr));
|
|
698
699
|
}
|
|
699
700
|
async function injectBundleRender(ctx, pluginName) {
|
|
700
|
-
var _a;
|
|
701
|
+
var _a, _b;
|
|
701
702
|
const importFilePath = path$1
|
|
702
703
|
.relative(ctx.client.componentDir, path$1.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName))
|
|
703
704
|
.replaceAll("\\", "/");
|
|
704
705
|
const importStr = `import render from '${importFilePath}/${ctx[pluginName].outputOptions.fileName}';`;
|
|
706
|
+
const pluginFlags = (_a = ctx[pluginName].pluginFlags) !== null && _a !== void 0 ? _a : {};
|
|
707
|
+
const pluginFlagsStr = `const pluginFlags: Partial<PluginFlags> = ${JSON.stringify(pluginFlags)}`;
|
|
705
708
|
let content = await fs.readFile(path$1.resolve(ctx.core.templatesDir, "component.tsx.template"), "utf8");
|
|
706
|
-
if (!!((
|
|
709
|
+
if (!!((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.watch)) {
|
|
707
710
|
content = content.replace(COMPONENT_TAG_TOKEN, "embeddable-component");
|
|
708
711
|
}
|
|
709
|
-
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
712
|
+
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr).replace(PLUGIN_FLAGS_TOKEN, pluginFlagsStr));
|
|
710
713
|
}
|
|
711
714
|
async function injectEmptyCSS(ctx) {
|
|
712
715
|
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "style.css"), "");
|
|
@@ -715,7 +718,7 @@ async function injectBundleRenderStub(ctx) {
|
|
|
715
718
|
const stubStr = `const render = (..._args: any[]) => {};`;
|
|
716
719
|
let content = await fs.readFile(path$1.resolve(ctx.core.templatesDir, "component.tsx.template"), "utf8");
|
|
717
720
|
content = content.replace(COMPONENT_TAG_TOKEN, "embeddable-component");
|
|
718
|
-
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, stubStr));
|
|
721
|
+
await fs.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, stubStr).replace(PLUGIN_FLAGS_TOKEN, "const pluginFlags: Partial<PluginFlags> = {}"));
|
|
719
722
|
}
|
|
720
723
|
async function addComponentTagName(filePath, bundleHash) {
|
|
721
724
|
// find entry file with a name *.entry.js
|
|
@@ -21641,6 +21644,7 @@ async function sendBuildByApiKey(ctx, { apiKey, email, message, cubeVersion, })
|
|
|
21641
21644
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
21642
21645
|
pushModels: ctx.pushModels,
|
|
21643
21646
|
pushComponents: ctx.pushComponents,
|
|
21647
|
+
pushEmbeddables: ctx.pushEmbeddables,
|
|
21644
21648
|
starterEmbeddableIds: (_a = ctx.starterEmbeddables) === null || _a === void 0 ? void 0 : _a[ctx.region],
|
|
21645
21649
|
authorEmail: email,
|
|
21646
21650
|
description: message,
|
|
@@ -21656,6 +21660,7 @@ async function sendBuild(ctx, { workspaceId, token, message, cubeVersion, }) {
|
|
|
21656
21660
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
21657
21661
|
pushModels: ctx.pushModels,
|
|
21658
21662
|
pushComponents: ctx.pushComponents,
|
|
21663
|
+
pushEmbeddables: ctx.pushEmbeddables,
|
|
21659
21664
|
starterEmbeddableIds: (_a = ctx.starterEmbeddables) === null || _a === void 0 ? void 0 : _a[ctx.region],
|
|
21660
21665
|
authorEmail: "",
|
|
21661
21666
|
description: message,
|
|
@@ -22232,6 +22237,7 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
|
22232
22237
|
instanceUrl,
|
|
22233
22238
|
pushModels: ctx.pushModels,
|
|
22234
22239
|
pushComponents: ctx.pushComponents,
|
|
22240
|
+
pushEmbeddables: ctx.pushEmbeddables,
|
|
22235
22241
|
}, {
|
|
22236
22242
|
headers: {
|
|
22237
22243
|
Authorization: `Bearer ${token}`,
|