1tube 0.1.17 → 0.1.19
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
|
@@ -484,13 +484,23 @@ export class RuntimeOverrideStore {
|
|
|
484
484
|
if (extracted.length > 0) return { source: "sourcemap", files: extracted };
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
-
const
|
|
488
|
-
const
|
|
489
|
-
|
|
487
|
+
const emittedFiles = [...new Set(entry.moduleFiles.length ? entry.moduleFiles : [entry.bundleFile])];
|
|
488
|
+
const emittedSources: EditableSourceFile[] = [];
|
|
489
|
+
for (const moduleFile of emittedFiles) {
|
|
490
|
+
const bundle = await readTextIfExists(join(prebuiltDir, moduleFile));
|
|
491
|
+
if (bundle !== null) {
|
|
492
|
+
emittedSources.push({
|
|
493
|
+
path: moduleFile,
|
|
494
|
+
content: bundle,
|
|
495
|
+
language: langFor(moduleFile),
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (emittedSources.length > 0) {
|
|
490
500
|
return {
|
|
491
501
|
source: "bundle",
|
|
492
|
-
files:
|
|
493
|
-
warning: "Authored source was not packaged with this firmware; showing emitted JS fallback.",
|
|
502
|
+
files: emittedSources.sort((a, b) => emittedSortKey(entry.bundleFile, a.path).localeCompare(emittedSortKey(entry.bundleFile, b.path))),
|
|
503
|
+
warning: "Authored source was not packaged with this firmware; showing emitted JS fallback modules.",
|
|
494
504
|
};
|
|
495
505
|
}
|
|
496
506
|
return {
|
|
@@ -553,6 +563,12 @@ function sourceSortKey(path: string): string {
|
|
|
553
563
|
return `5:${path}`;
|
|
554
564
|
}
|
|
555
565
|
|
|
566
|
+
function emittedSortKey(entryFile: string, path: string): string {
|
|
567
|
+
if (path === entryFile) return `0:${path}`;
|
|
568
|
+
if (basename(path) === basename(entryFile)) return `1:${path}`;
|
|
569
|
+
return `5:${path}`;
|
|
570
|
+
}
|
|
571
|
+
|
|
556
572
|
function defaultManifestForFile(): Record<string, unknown> {
|
|
557
573
|
const manifest = defaultManifest();
|
|
558
574
|
return {
|
package/src/server.ts
CHANGED
|
@@ -398,6 +398,15 @@ const LOCAL_SUPABASE_DEFAULTS: Record<string, string> = {
|
|
|
398
398
|
JWT_SECRET: "super-secret-jwt-token-with-at-least-32-characters-long",
|
|
399
399
|
};
|
|
400
400
|
|
|
401
|
+
const LOCAL_SUPABASE_STATUS_KEYS: Record<string, string[]> = {
|
|
402
|
+
SUPABASE_URL: ["API_URL"],
|
|
403
|
+
JWT_SECRET: ["JWT_SECRET"],
|
|
404
|
+
SUPABASE_ANON_KEY: ["ANON_KEY"],
|
|
405
|
+
SUPABASE_PUBLISHABLE_KEY: ["PUBLISHABLE_KEY"],
|
|
406
|
+
SUPABASE_SECRET_KEY: ["SECRET_KEY"],
|
|
407
|
+
SUPABASE_SERVICE_ROLE_KEY: ["SERVICE_ROLE_KEY"],
|
|
408
|
+
};
|
|
409
|
+
|
|
401
410
|
// Only secrets the gateway *itself* uses on the hot path. Anything an edge
|
|
402
411
|
// function happens to need (publishable/secret keys, OPENAI_API_KEY, …) is
|
|
403
412
|
// the function author's contract with the host — refusing to boot because
|
|
@@ -405,8 +414,24 @@ const LOCAL_SUPABASE_DEFAULTS: Record<string, string> = {
|
|
|
405
414
|
// confusing failures.
|
|
406
415
|
const SECRETS_REQUIRED_IN_PROD = ["JWT_SECRET"];
|
|
407
416
|
|
|
408
|
-
function applyDevDefaults() {
|
|
417
|
+
async function applyDevDefaults() {
|
|
409
418
|
let applied = 0;
|
|
419
|
+
const statusEnv = await readLocalSupabaseStatusEnv();
|
|
420
|
+
for (const [target, sources] of Object.entries(LOCAL_SUPABASE_STATUS_KEYS)) {
|
|
421
|
+
if (Deno.env.get(target)) continue;
|
|
422
|
+
const value = sources
|
|
423
|
+
.map((source) => statusEnv[source])
|
|
424
|
+
.find((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
425
|
+
if (!value) continue;
|
|
426
|
+
Deno.env.set(target, value);
|
|
427
|
+
applied++;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (!Deno.env.get("SUPABASE_URL") && Deno.env.get("VITE_SUPABASE_URL")) {
|
|
431
|
+
Deno.env.set("SUPABASE_URL", Deno.env.get("VITE_SUPABASE_URL")!);
|
|
432
|
+
applied++;
|
|
433
|
+
}
|
|
434
|
+
|
|
410
435
|
for (const [key, value] of Object.entries(LOCAL_SUPABASE_DEFAULTS)) {
|
|
411
436
|
if (!Deno.env.get(key)) {
|
|
412
437
|
Deno.env.set(key, value);
|
|
@@ -418,6 +443,48 @@ function applyDevDefaults() {
|
|
|
418
443
|
}
|
|
419
444
|
}
|
|
420
445
|
|
|
446
|
+
async function readLocalSupabaseStatusEnv(): Promise<Record<string, string>> {
|
|
447
|
+
const runners: Array<{ command: string; args: string[] }> = [
|
|
448
|
+
{ command: "supabase", args: ["status", "-o", "env"] },
|
|
449
|
+
{ command: "bunx", args: ["supabase", "status", "-o", "env"] },
|
|
450
|
+
];
|
|
451
|
+
|
|
452
|
+
for (const runner of runners) {
|
|
453
|
+
try {
|
|
454
|
+
const output = await new Deno.Command(runner.command, {
|
|
455
|
+
args: runner.args,
|
|
456
|
+
stdout: "piped",
|
|
457
|
+
stderr: "null",
|
|
458
|
+
}).output();
|
|
459
|
+
if (!output.success) continue;
|
|
460
|
+
return parseSupabaseStatusEnv(new TextDecoder().decode(output.stdout));
|
|
461
|
+
} catch {
|
|
462
|
+
// CLI not installed on PATH (or bunx unavailable). Try the next runner.
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return {};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function parseSupabaseStatusEnv(text: string): Record<string, string> {
|
|
469
|
+
const out: Record<string, string> = {};
|
|
470
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
471
|
+
const line = rawLine.trim();
|
|
472
|
+
if (!line || line.startsWith("#")) continue;
|
|
473
|
+
const eq = line.indexOf("=");
|
|
474
|
+
if (eq <= 0) continue;
|
|
475
|
+
const key = line.slice(0, eq).trim();
|
|
476
|
+
let value = line.slice(eq + 1).trim();
|
|
477
|
+
if (
|
|
478
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
479
|
+
(value.startsWith("'") && value.endsWith("'"))
|
|
480
|
+
) {
|
|
481
|
+
value = value.slice(1, -1);
|
|
482
|
+
}
|
|
483
|
+
out[key] = value;
|
|
484
|
+
}
|
|
485
|
+
return out;
|
|
486
|
+
}
|
|
487
|
+
|
|
421
488
|
function enforceProdSecrets() {
|
|
422
489
|
// We deliberately do NOT reject "well-known dev default" values
|
|
423
490
|
// here. The local Supabase Docker stack ships with a fixed
|
|
@@ -463,7 +530,7 @@ function requireInternal(c: Context): Response | null {
|
|
|
463
530
|
}
|
|
464
531
|
|
|
465
532
|
if (opts.dev) {
|
|
466
|
-
applyDevDefaults();
|
|
533
|
+
await applyDevDefaults();
|
|
467
534
|
} else {
|
|
468
535
|
enforceProdSecrets();
|
|
469
536
|
}
|