@superatomai/sdk-node 0.0.76-dsp → 0.0.77-dsp

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/dist/index.js CHANGED
@@ -2876,6 +2876,23 @@ function getBundleDir(configDir) {
2876
2876
  }
2877
2877
  return bundleDir;
2878
2878
  }
2879
+ function getCSS(bundleDir) {
2880
+ try {
2881
+ if (!fs2.existsSync(bundleDir) || !fs2.statSync(bundleDir).isDirectory()) return null;
2882
+ const cssFile = fs2.readdirSync(bundleDir).find((file) => file.startsWith("index-") && file.endsWith(".css"));
2883
+ if (!cssFile) {
2884
+ logger.info(`No index-*.css in ${bundleDir} \u2014 sending the bundle without styles`);
2885
+ return null;
2886
+ }
2887
+ const filePath = path2.join(bundleDir, cssFile);
2888
+ logger.info(`Loading bundle styles from ${filePath}`);
2889
+ return fs2.readFileSync(filePath, "utf8");
2890
+ } catch (error) {
2891
+ const message = error instanceof Error ? error.message : String(error);
2892
+ logger.warn(`Failed to load bundle styles: ${message}`);
2893
+ return null;
2894
+ }
2895
+ }
2879
2896
  function getJS(bundleDir) {
2880
2897
  try {
2881
2898
  if (!fs2.existsSync(bundleDir)) {
@@ -2919,6 +2936,29 @@ function getJS(bundleDir) {
2919
2936
 
2920
2937
  // src/handlers/bundle-request.ts
2921
2938
  var CHUNK_SIZE = 900 * 1024;
2939
+ function sendChunked(text, type, id, fromId, sendMessage) {
2940
+ const totalChunks = Math.max(1, Math.ceil(Buffer.byteLength(text, "utf8") / CHUNK_SIZE));
2941
+ for (let i = 0; i < totalChunks; i++) {
2942
+ const start = i * CHUNK_SIZE;
2943
+ const end = Math.min(start + CHUNK_SIZE, text.length);
2944
+ const isComplete = i === totalChunks - 1;
2945
+ const progress = (i + 1) / totalChunks * 100;
2946
+ sendMessage({
2947
+ id: `${id}-${type === "BUNDLE_CSS_CHUNK" ? "css-" : ""}chunk-${i}`,
2948
+ type,
2949
+ from: { type: "data-agent" },
2950
+ to: fromId ? { id: fromId } : void 0,
2951
+ payload: {
2952
+ chunk: text.substring(start, end),
2953
+ chunkIndex: i,
2954
+ totalChunks,
2955
+ isComplete,
2956
+ progress: parseFloat(progress.toFixed(2))
2957
+ }
2958
+ });
2959
+ logger.debug(`Sent ${type} ${i + 1}/${totalChunks} (${progress.toFixed(2)}%)`);
2960
+ }
2961
+ }
2922
2962
  async function handleBundleRequest(data, bundleDir, sendMessage) {
2923
2963
  try {
2924
2964
  const id = data.id || "unknown";
@@ -2927,30 +2967,13 @@ async function handleBundleRequest(data, bundleDir, sendMessage) {
2927
2967
  const js = getJS(dir);
2928
2968
  const bundleSize = Buffer.byteLength(js, "utf8");
2929
2969
  logger.info(`Bundle size: ${(bundleSize / 1024).toFixed(2)} KB`);
2930
- const totalChunks = Math.ceil(bundleSize / CHUNK_SIZE);
2931
- logger.info(`Splitting bundle into ${totalChunks} chunks`);
2932
- for (let i = 0; i < totalChunks; i++) {
2933
- const start = i * CHUNK_SIZE;
2934
- const end = Math.min(start + CHUNK_SIZE, js.length);
2935
- const chunk = js.substring(start, end);
2936
- const isComplete = i === totalChunks - 1;
2937
- const progress = (i + 1) / totalChunks * 100;
2938
- const chunkMessage = {
2939
- id: `${id}-chunk-${i}`,
2940
- type: "BUNDLE_CHUNK",
2941
- from: { type: "data-agent" },
2942
- to: fromId ? { id: fromId } : void 0,
2943
- payload: {
2944
- chunk,
2945
- chunkIndex: i,
2946
- totalChunks,
2947
- isComplete,
2948
- progress: parseFloat(progress.toFixed(2))
2949
- }
2950
- };
2951
- sendMessage(chunkMessage);
2952
- logger.debug(`Sent chunk ${i + 1}/${totalChunks} (${progress.toFixed(2)}%)`);
2970
+ const css = getCSS(dir);
2971
+ if (css) {
2972
+ logger.info(`Bundle styles: ${(Buffer.byteLength(css, "utf8") / 1024).toFixed(2)} KB`);
2973
+ sendChunked(css, "BUNDLE_CSS_CHUNK", id, fromId, sendMessage);
2953
2974
  }
2975
+ logger.info(`Splitting bundle into ${Math.ceil(bundleSize / CHUNK_SIZE)} chunks`);
2976
+ sendChunked(js, "BUNDLE_CHUNK", id, fromId, sendMessage);
2954
2977
  logger.info("Bundle sending complete");
2955
2978
  } catch (error) {
2956
2979
  logger.error("Failed to handle bundle request:", error);
package/dist/index.mjs CHANGED
@@ -2763,6 +2763,23 @@ function getBundleDir(configDir) {
2763
2763
  }
2764
2764
  return bundleDir;
2765
2765
  }
2766
+ function getCSS(bundleDir) {
2767
+ try {
2768
+ if (!fs2.existsSync(bundleDir) || !fs2.statSync(bundleDir).isDirectory()) return null;
2769
+ const cssFile = fs2.readdirSync(bundleDir).find((file) => file.startsWith("index-") && file.endsWith(".css"));
2770
+ if (!cssFile) {
2771
+ logger.info(`No index-*.css in ${bundleDir} \u2014 sending the bundle without styles`);
2772
+ return null;
2773
+ }
2774
+ const filePath = path2.join(bundleDir, cssFile);
2775
+ logger.info(`Loading bundle styles from ${filePath}`);
2776
+ return fs2.readFileSync(filePath, "utf8");
2777
+ } catch (error) {
2778
+ const message = error instanceof Error ? error.message : String(error);
2779
+ logger.warn(`Failed to load bundle styles: ${message}`);
2780
+ return null;
2781
+ }
2782
+ }
2766
2783
  function getJS(bundleDir) {
2767
2784
  try {
2768
2785
  if (!fs2.existsSync(bundleDir)) {
@@ -2806,6 +2823,29 @@ function getJS(bundleDir) {
2806
2823
 
2807
2824
  // src/handlers/bundle-request.ts
2808
2825
  var CHUNK_SIZE = 900 * 1024;
2826
+ function sendChunked(text, type, id, fromId, sendMessage) {
2827
+ const totalChunks = Math.max(1, Math.ceil(Buffer.byteLength(text, "utf8") / CHUNK_SIZE));
2828
+ for (let i = 0; i < totalChunks; i++) {
2829
+ const start = i * CHUNK_SIZE;
2830
+ const end = Math.min(start + CHUNK_SIZE, text.length);
2831
+ const isComplete = i === totalChunks - 1;
2832
+ const progress = (i + 1) / totalChunks * 100;
2833
+ sendMessage({
2834
+ id: `${id}-${type === "BUNDLE_CSS_CHUNK" ? "css-" : ""}chunk-${i}`,
2835
+ type,
2836
+ from: { type: "data-agent" },
2837
+ to: fromId ? { id: fromId } : void 0,
2838
+ payload: {
2839
+ chunk: text.substring(start, end),
2840
+ chunkIndex: i,
2841
+ totalChunks,
2842
+ isComplete,
2843
+ progress: parseFloat(progress.toFixed(2))
2844
+ }
2845
+ });
2846
+ logger.debug(`Sent ${type} ${i + 1}/${totalChunks} (${progress.toFixed(2)}%)`);
2847
+ }
2848
+ }
2809
2849
  async function handleBundleRequest(data, bundleDir, sendMessage) {
2810
2850
  try {
2811
2851
  const id = data.id || "unknown";
@@ -2814,30 +2854,13 @@ async function handleBundleRequest(data, bundleDir, sendMessage) {
2814
2854
  const js = getJS(dir);
2815
2855
  const bundleSize = Buffer.byteLength(js, "utf8");
2816
2856
  logger.info(`Bundle size: ${(bundleSize / 1024).toFixed(2)} KB`);
2817
- const totalChunks = Math.ceil(bundleSize / CHUNK_SIZE);
2818
- logger.info(`Splitting bundle into ${totalChunks} chunks`);
2819
- for (let i = 0; i < totalChunks; i++) {
2820
- const start = i * CHUNK_SIZE;
2821
- const end = Math.min(start + CHUNK_SIZE, js.length);
2822
- const chunk = js.substring(start, end);
2823
- const isComplete = i === totalChunks - 1;
2824
- const progress = (i + 1) / totalChunks * 100;
2825
- const chunkMessage = {
2826
- id: `${id}-chunk-${i}`,
2827
- type: "BUNDLE_CHUNK",
2828
- from: { type: "data-agent" },
2829
- to: fromId ? { id: fromId } : void 0,
2830
- payload: {
2831
- chunk,
2832
- chunkIndex: i,
2833
- totalChunks,
2834
- isComplete,
2835
- progress: parseFloat(progress.toFixed(2))
2836
- }
2837
- };
2838
- sendMessage(chunkMessage);
2839
- logger.debug(`Sent chunk ${i + 1}/${totalChunks} (${progress.toFixed(2)}%)`);
2857
+ const css = getCSS(dir);
2858
+ if (css) {
2859
+ logger.info(`Bundle styles: ${(Buffer.byteLength(css, "utf8") / 1024).toFixed(2)} KB`);
2860
+ sendChunked(css, "BUNDLE_CSS_CHUNK", id, fromId, sendMessage);
2840
2861
  }
2862
+ logger.info(`Splitting bundle into ${Math.ceil(bundleSize / CHUNK_SIZE)} chunks`);
2863
+ sendChunked(js, "BUNDLE_CHUNK", id, fromId, sendMessage);
2841
2864
  logger.info("Bundle sending complete");
2842
2865
  } catch (error) {
2843
2866
  logger.error("Failed to handle bundle request:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superatomai/sdk-node",
3
- "version": "0.0.76-dsp",
3
+ "version": "0.0.77-dsp",
4
4
  "description": "Node.js TypeScript SDK for Superatom",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",