@superblocksteam/sdk 2.0.34 → 2.0.35-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.
Files changed (37) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/dist/application-build.d.mts +1 -2
  3. package/dist/application-build.d.mts.map +1 -1
  4. package/dist/application-build.mjs +3 -29
  5. package/dist/application-build.mjs.map +1 -1
  6. package/dist/cli-replacement/dev.d.mts +1 -2
  7. package/dist/cli-replacement/dev.d.mts.map +1 -1
  8. package/dist/cli-replacement/dev.mjs +2 -3
  9. package/dist/cli-replacement/dev.mjs.map +1 -1
  10. package/dist/dev-utils/dev-server.d.mts.map +1 -1
  11. package/dist/dev-utils/dev-server.mjs +18 -28
  12. package/dist/dev-utils/dev-server.mjs.map +1 -1
  13. package/dist/flag.d.ts +1 -0
  14. package/dist/flag.d.ts.map +1 -1
  15. package/dist/flag.js +3 -0
  16. package/dist/flag.js.map +1 -1
  17. package/dist/types/common.d.ts +1 -0
  18. package/dist/types/common.d.ts.map +1 -1
  19. package/dist/types/common.js.map +1 -1
  20. package/package.json +6 -6
  21. package/src/application-build.mts +1 -32
  22. package/src/cli-replacement/dev.mts +9 -16
  23. package/src/dev-utils/dev-server.mts +20 -35
  24. package/src/flag.ts +4 -0
  25. package/src/types/common.ts +1 -0
  26. package/tsconfig.tsbuildinfo +1 -1
  27. package/turbo.json +1 -0
  28. package/dist/dev-utils/vite-plugin-react-transform.d.mts +0 -7
  29. package/dist/dev-utils/vite-plugin-react-transform.d.mts.map +0 -1
  30. package/dist/dev-utils/vite-plugin-react-transform.mjs +0 -111
  31. package/dist/dev-utils/vite-plugin-react-transform.mjs.map +0 -1
  32. package/dist/dev-utils/vite-plugin-sb-cdn.d.mts +0 -34
  33. package/dist/dev-utils/vite-plugin-sb-cdn.d.mts.map +0 -1
  34. package/dist/dev-utils/vite-plugin-sb-cdn.mjs +0 -755
  35. package/dist/dev-utils/vite-plugin-sb-cdn.mjs.map +0 -1
  36. package/src/dev-utils/vite-plugin-react-transform.mts +0 -131
  37. package/src/dev-utils/vite-plugin-sb-cdn.mts +0 -1033
@@ -17,18 +17,18 @@ import fs from "fs-extra";
17
17
  import { resolveCommand } from "package-manager-detector";
18
18
  import { detect } from "package-manager-detector/detect";
19
19
 
20
- import {
21
- AUTO_UPGRADE_EXIT_CODE,
22
- createDevServer,
23
- SuperblocksSdk,
24
- } from "../index.js";
20
+ import { AUTO_UPGRADE_EXIT_CODE, createDevServer } from "../index.js";
25
21
  import { getTracer } from "../telemetry/index.js";
26
22
  import { getErrorMeta, getLogger, type Logger } from "../telemetry/logging.js";
27
23
  import {
28
24
  checkVersionsAndWritePackageJson,
29
25
  getCurrentCliVersion,
30
26
  } from "./automatic-upgrades.js";
31
- import type { AuthHotReloadServer, TokenManager } from "../index.js";
27
+ import type {
28
+ AuthHotReloadServer,
29
+ TokenManager,
30
+ SuperblocksSdk,
31
+ } from "../index.js";
32
32
  import type {
33
33
  ApplicationConfig,
34
34
  ApplicationConfigWithTokenConfigAndUserInfo,
@@ -148,7 +148,6 @@ export async function dev(options: {
148
148
  applicationConfig,
149
149
  autoUpgradeMode,
150
150
  tokenManager,
151
- getCurrentToken,
152
151
  authHotReloadServer,
153
152
  sdk,
154
153
  } = options;
@@ -214,12 +213,6 @@ export async function dev(options: {
214
213
 
215
214
  try {
216
215
  await maskUnixSignals(async () => {
217
- const sdk = new SuperblocksSdk(
218
- getCurrentToken(),
219
- tokenConfig.superblocksBaseUrl,
220
- "",
221
- );
222
-
223
216
  if (lockService) {
224
217
  await tracer.startActiveSpan("acquiringInitialLock", async (span) => {
225
218
  try {
@@ -249,12 +242,12 @@ export async function dev(options: {
249
242
  const [localContents, serverHash, currentUser] =
250
243
  await tracer.startActiveSpan("fetchInitInfo", async (span) => {
251
244
  const results = await Promise.all([
252
- sdk.hashLocalDirectory(cwd),
253
- sdk.dbfsGetApplicationDirectoryHash({
245
+ sdk!.hashLocalDirectory(cwd),
246
+ sdk!.dbfsGetApplicationDirectoryHash({
254
247
  applicationId: applicationConfig.id,
255
248
  branch: applicationConfig.branchName,
256
249
  }),
257
- sdk.fetchCurrentUser(),
250
+ sdk!.fetchCurrentUser(),
258
251
  ]);
259
252
  span.end();
260
253
  return results;
@@ -19,7 +19,6 @@ import {
19
19
  } from "./custom-build.mjs";
20
20
  import { buildManifestStubPlugin } from "./vite-plugin-build-manifest-stub.mjs";
21
21
  import { ddRumPlugin } from "./vite-plugin-dd-rum.mjs";
22
- import { superblocksCdnPlugin } from "./vite-plugin-sb-cdn.mjs";
23
22
  import type { SuperblocksSdk } from "../sdk.js";
24
23
  import type { AiService } from "@superblocksteam/vite-plugin-file-sync/ai-service";
25
24
  import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
@@ -235,6 +234,7 @@ export async function createDevServer({
235
234
  const featureFlags = await sdk?.getFeatureFlagsForCurrentUser();
236
235
 
237
236
  // TODO(code-mode): should this include any validation checks, such as getting a token?
237
+
238
238
  startVite({
239
239
  port,
240
240
  app,
@@ -248,6 +248,7 @@ export async function createDevServer({
248
248
  httpServer,
249
249
  features: {
250
250
  enableSessionRecording: featureFlags?.enableSessionRecording() ?? false,
251
+ chakraComponents: featureFlags?.isChakraComponentsEnabled() ?? false,
251
252
  },
252
253
  }).then(
253
254
  (result) => {
@@ -372,6 +373,7 @@ async function startVite({
372
373
  httpServer: http.Server;
373
374
  features: {
374
375
  enableSessionRecording: boolean;
376
+ chakraComponents: boolean;
375
377
  };
376
378
  }): Promise<{
377
379
  viteServer: ViteDevServer;
@@ -399,12 +401,8 @@ async function startVite({
399
401
  `Custom components ${isCustomBuildEnabled ? "enabled" : "disabled"}`,
400
402
  );
401
403
  const customFolder = path.join(root, "custom");
402
-
403
404
  const draftsFolder = path.join(root, ".superblocks");
404
405
 
405
- const cdnUrl = process.env.SUPERBLOCKS_CDN_URL ?? "http://localhost:4040/cdn";
406
- logger.debug(`Using CDN URL: ${cdnUrl}`);
407
-
408
406
  const env = loadEnv(mode, root, "");
409
407
 
410
408
  const hmrPort = await getFreePort();
@@ -453,18 +451,7 @@ async function startVite({
453
451
  const viteServer = await createServer({
454
452
  root,
455
453
  mode,
456
- resolve: {
457
- alias: {
458
- "react-router": "@superblocksteam/library",
459
- },
460
- },
461
454
  clearScreen: process.env.SUPERBLOCKS_CLI_ENV !== "local",
462
- optimizeDeps: {
463
- include: ["lodash", "react-is"],
464
- exclude: [],
465
- },
466
- // See https://vite.dev/config/server-options.html#server-middlewaremode
467
- // appType: "custom",
468
455
  server: {
469
456
  middlewareMode: true,
470
457
  watch: {
@@ -477,13 +464,17 @@ async function startVite({
477
464
  },
478
465
  },
479
466
  build: {
480
- commonjsOptions: {
481
- include: ["react-is"],
482
- },
483
467
  rollupOptions: {
484
468
  external: [`${customFolder}/**/*`],
485
469
  },
486
470
  },
471
+ define: {
472
+ // this replaces a string in @superblocksteam/shared
473
+ "process.env.SUPERBLOCKS_PUBLIC_INTEGRATIONS_CDN_URL": process.env
474
+ .SUPERBLOCKS_PUBLIC_INTEGRATIONS_CDN_URL
475
+ ? JSON.stringify(process.env.SUPERBLOCKS_PUBLIC_INTEGRATIONS_CDN_URL)
476
+ : "undefined",
477
+ },
487
478
  plugins: [
488
479
  tsconfigPaths(),
489
480
  customComponentsPlugin(),
@@ -491,20 +482,18 @@ async function startVite({
491
482
  // Add a virtual "stub" module for the build manifest
492
483
  buildManifestStubPlugin(),
493
484
 
494
- // for now, only use the CDN locally
495
- superblocksCdnPlugin({
496
- imports: {
497
- "@superblocksteam/library": getValidFileUrl(cdnUrl, "index.js"),
498
- },
499
- cssImports: {
500
- "@superblocksteam/library/index.css": getValidFileUrl(
501
- cdnUrl,
502
- "index.css",
503
- ),
485
+ react({
486
+ babel: {
487
+ plugins: [
488
+ [
489
+ import.meta.resolve("@babel/plugin-proposal-decorators"),
490
+ {
491
+ version: "2023-11",
492
+ },
493
+ ],
494
+ ],
504
495
  },
505
496
  }),
506
-
507
- react(),
508
497
  ddRumPlugin({
509
498
  clientToken: env.SUPERBLOCKS_LIBRARY_DD_CLIENT_TOKEN ?? "",
510
499
  applicationId: env.SUPERBLOCKS_LIBRARY_DD_APPLICATION_ID ?? "",
@@ -555,7 +544,3 @@ function getFreePort() {
555
544
  });
556
545
  });
557
546
  }
558
-
559
- function getValidFileUrl(url: string, file: string): string {
560
- return new URL(file, url.endsWith("/") ? url : url + "/").href;
561
- }
package/src/flag.ts CHANGED
@@ -27,6 +27,10 @@ export class FeatureFlags {
27
27
  );
28
28
  }
29
29
 
30
+ isChakraComponentsEnabled(): boolean {
31
+ return this.flags["ui.chakra-components"] ?? false;
32
+ }
33
+
30
34
  enableSessionRecording(): boolean {
31
35
  return this.flags["ui.code-mode.enable-session-recording"] ?? false;
32
36
  }
@@ -12,6 +12,7 @@ export interface FlagBootstrap {
12
12
  "superblocks.git.split.large.steps.enabled"?: boolean;
13
13
  "superblocks.git.split.large.steps.new.enabled"?: boolean;
14
14
  "superblocks.git.split.large.step.lines"?: number;
15
+ "ui.chakra-components"?: boolean;
15
16
  "ui.code-mode.enable-session-recording"?: boolean;
16
17
  }
17
18