dh-remixer-sdk 0.0.24-e08afd3 → 0.0.24-eb3f14d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dh-remixer-sdk",
3
- "version": "0.0.24-e08afd3",
3
+ "version": "0.0.24-eb3f14d",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "templates",
@@ -17,8 +17,7 @@
17
17
  "chrome-launcher": "1.2.1",
18
18
  "chrome-remote-interface": "0.34.0",
19
19
  "estree-walker": "3.0.3",
20
- "sucrase": "3.35.0",
21
- "@sparticuz/chromium": "143.0.4"
20
+ "sucrase": "3.35.0"
22
21
  },
23
22
  "devDependencies": {
24
23
  "eslint-plugin-n": "17.24.0",
@@ -104,12 +104,8 @@ export class Prerenderer {
104
104
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
105
105
  try {
106
106
  await CDP.List({ port: this.#cdpPort });
107
- if (attempt > 1) {
108
- console.log(`[ssg-helmet] CDP ready after ${attempt} attempts`);
109
- }
110
107
  return;
111
108
  } catch (error) {
112
- console.log(`[ssg-helmet] CDP verification attempt ${attempt}/${maxAttempts} failed: ${error.message}`);
113
109
  if (attempt === maxAttempts) {
114
110
  throw new Error(
115
111
  `Chrome CDP not ready after ${maxAttempts * delayMs}ms. ` +
@@ -126,17 +122,13 @@ export class Prerenderer {
126
122
 
127
123
  await this.#startServer();
128
124
 
129
- // In Lambda (CHROME_BIN set), spawn Chrome directly to capture stderr.
130
- // Locally, use chrome-launcher for convenience.
131
125
  if (process.env.CHROME_BIN) {
132
126
  await this.#launchDirect();
133
127
  } else {
134
128
  await this.#launchWithChromeLauncher();
135
129
  }
136
130
 
137
- console.log(`[ssg-helmet] Chrome process launched on port ${this.#cdpPort}, verifying CDP readiness...`);
138
131
  await this.#verifyCDPReady();
139
- console.log(`[ssg-helmet] Chrome CDP ready`);
140
132
 
141
133
  // Connect to the default tab
142
134
  const targets = await CDP.List({ port: this.#cdpPort });
@@ -146,22 +138,12 @@ export class Prerenderer {
146
138
  this.#client = await CDP({ port: this.#cdpPort, target: pageTarget });
147
139
  await this.#client.Page.enable();
148
140
  await this.#client.Runtime.enable();
149
- console.log(`[ssg-helmet] Connected to default tab`);
150
141
  }
151
142
 
152
143
  async #launchDirect() {
153
144
  const chromeBin = process.env.CHROME_BIN;
154
145
  const debugPort = 9222 + Math.floor(Math.random() * 10000);
155
146
 
156
- // Log Chrome version first
157
- try {
158
- const ver = spawn(chromeBin, ["--version"], { stdio: ["ignore", "pipe", "pipe"] });
159
- let out = "";
160
- ver.stdout.on("data", (d) => (out += d));
161
- await new Promise((res) => ver.on("close", res));
162
- console.log(`[ssg-helmet] Chrome version: ${out.trim()}`);
163
- } catch {}
164
-
165
147
  const defaultFlags = [
166
148
  "--headless",
167
149
  "--no-sandbox",
@@ -177,30 +159,26 @@ export class Prerenderer {
177
159
  ];
178
160
 
179
161
  const chromeFlags = process.env.CHROME_FLAGS
180
- ? ["--headless=new", ...process.env.CHROME_FLAGS.split(",").map((f) => f.trim())]
162
+ ? process.env.CHROME_FLAGS.split(",").map((f) => f.trim())
181
163
  : defaultFlags;
182
164
 
183
165
  const allArgs = [
184
166
  ...chromeFlags,
167
+ `--user-data-dir=/tmp/chrome-data-${debugPort}`,
185
168
  `--remote-debugging-port=${debugPort}`,
186
169
  "--remote-debugging-address=127.0.0.1",
187
170
  "about:blank",
188
171
  ];
189
172
 
190
- console.log(`[ssg-helmet] Spawning ${chromeBin} on port ${debugPort}`);
191
- console.log(`[ssg-helmet] Args: ${allArgs.join(" ")}`);
192
-
193
173
  this.#chromeProcess = spawn(chromeBin, allArgs, {
194
- stdio: ["ignore", "pipe", "pipe"],
195
- });
196
-
197
- let stderrBuf = "";
198
- this.#chromeProcess.stderr.on("data", (d) => {
199
- stderrBuf += d.toString();
200
- });
201
- this.#chromeProcess.on("exit", (code, signal) => {
202
- console.log(`[ssg-helmet] Chrome exited: code=${code}, signal=${signal}`);
203
- if (stderrBuf) console.log(`[ssg-helmet] Chrome stderr:\n${stderrBuf.slice(0, 4000)}`);
174
+ stdio: "ignore",
175
+ env: {
176
+ ...process.env,
177
+ HOME: "/tmp",
178
+ XDG_CACHE_HOME: "/tmp/.cache",
179
+ XDG_CONFIG_HOME: "/tmp/.config",
180
+ FONTCONFIG_CACHE: "/tmp/fontconfig-cache",
181
+ },
204
182
  });
205
183
 
206
184
  this.#cdpPort = debugPort;
@@ -220,12 +198,7 @@ export class Prerenderer {
220
198
  ? ["--headless", ...process.env.CHROME_FLAGS.split(",").map((f) => f.trim())]
221
199
  : defaultFlags;
222
200
 
223
- console.log(`[ssg-helmet] Launching Chrome with flags:`, chromeFlags);
224
-
225
- this.#chrome = await chromeLauncher.launch({
226
- chromePath: process.env.CHROME_BIN || undefined,
227
- chromeFlags,
228
- });
201
+ this.#chrome = await chromeLauncher.launch({ chromeFlags });
229
202
 
230
203
  this.#cdpPort = this.#chrome.port;
231
204
  }