@fungi.computer/oyster 0.52.0 → 0.52.2

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.
@@ -68,10 +68,11 @@ export async function appTestCopyPage(installationId, copy, declaration, pageMod
68
68
  </form>
69
69
  <a href="/recovery">App recovery</a>
70
70
  </header>
71
+ <!-- No src: the page module navigates the frame once it listens, so a
72
+ first document cannot claim the connection and then be replaced. -->
71
73
  <iframe
72
74
  id="oyster-app"
73
75
  sandbox="${appSandbox}"
74
- src="${config.uiUrl}"
75
76
  title="${installationId} test copy"
76
77
  ></iframe>
77
78
  <script type="application/json" id="oyster-config">
@@ -1,8 +1,8 @@
1
1
  import { readFile, realpath } from "node:fs/promises";
2
2
  import { dirname, extname, join } from "node:path";
3
3
  import { fileURLToPath, pathToFileURL, URL } from "node:url";
4
- import { build } from "esbuild";
5
4
  import { parse } from "parse5";
5
+ import { loadLazily } from "../lazy-import.js";
6
6
  import { isInsideSnapshot } from "./snapshot-programs/snapshot-path.js";
7
7
  // Only code contributes package imports. Vite, not this planning pass, owns
8
8
  // loading, validating and emitting assets (including extension-specific loaders).
@@ -67,6 +67,8 @@ export async function appRuntimeImports(options) {
67
67
  if (path !== undefined)
68
68
  modules.push({ entryPoints: [await contained(join(root, path))] });
69
69
  const imports = new Set();
70
+ // esbuild is loaded by the first App build, not by Worker startup.
71
+ const { build } = await loadLazily(() => import("esbuild"), "Oyster's App build tool (esbuild)");
70
72
  for (const module of modules) {
71
73
  const result = await build({
72
74
  ...module,
@@ -5362,8 +5362,8 @@ var require_coerce = __commonJS({
5362
5362
  const minor = match4[3] || "0";
5363
5363
  const patch = match4[4] || "0";
5364
5364
  const prerelease = options.includePrerelease && match4[5] ? `-${match4[5]}` : "";
5365
- const build2 = options.includePrerelease && match4[6] ? `+${match4[6]}` : "";
5366
- return parse6(`${major}.${minor}.${patch}${prerelease}${build2}`, options);
5365
+ const build = options.includePrerelease && match4[6] ? `+${match4[6]}` : "";
5366
+ return parse6(`${major}.${minor}.${patch}${prerelease}${build}`, options);
5367
5367
  };
5368
5368
  module.exports = coerce;
5369
5369
  }
@@ -22999,12 +22999,12 @@ async function createDefinitionEmission(source, recipe) {
22999
22999
  let declarationCode;
23000
23000
  const declarationPlugin = {
23001
23001
  name: "derived-app-declaration",
23002
- setup(build2) {
23003
- build2.onResolve(
23002
+ setup(build) {
23003
+ build.onResolve(
23004
23004
  { filter: /^fungi:app-declaration$/ },
23005
23005
  (args2) => args2.kind === "entry-point" ? { path: "app-declaration.js", namespace: declarationNamespace } : void 0
23006
23006
  );
23007
- build2.onLoad(
23007
+ build.onLoad(
23008
23008
  { filter: /.*/, namespace: declarationNamespace },
23009
23009
  () => ({
23010
23010
  contents: `import { appBackend } from ${JSON.stringify(definitionPath)}; import { buildAppDeclaration } from ${JSON.stringify(buildOnlySdk)}; export const appDeclaration = buildAppDeclaration(appBackend, ${JSON.stringify(packageDeclaration)});`,
@@ -24405,7 +24405,6 @@ import { dirname as dirname3, isAbsolute as isAbsolute4, join as join3, relative
24405
24405
  import { readFile as readFile2, realpath as realpath2 } from "node:fs/promises";
24406
24406
  import { dirname as dirname2, extname, join as join2 } from "node:path";
24407
24407
  import { fileURLToPath, pathToFileURL as pathToFileURL2, URL as URL3 } from "node:url";
24408
- import { build } from "esbuild";
24409
24408
 
24410
24409
  // ../../node_modules/.pnpm/parse5@8.0.1/node_modules/parse5/dist/common/unicode.js
24411
24410
  var UNDEFINED_CODE_POINTS = /* @__PURE__ */ new Set([
@@ -32290,6 +32289,15 @@ function parse3(html, options) {
32290
32289
  return Parser.parse(html, options);
32291
32290
  }
32292
32291
 
32292
+ // src/lazy-import.ts
32293
+ async function loadLazily(load3, what) {
32294
+ try {
32295
+ return await load3();
32296
+ } catch (cause) {
32297
+ throw new Error(`${what} failed to load`, { cause });
32298
+ }
32299
+ }
32300
+
32293
32301
  // src/build/app-imports.ts
32294
32302
  var codeExtensions = /* @__PURE__ */ new Set([
32295
32303
  ".js",
@@ -32344,6 +32352,10 @@ async function appRuntimeImports(options) {
32344
32352
  if (path !== void 0)
32345
32353
  modules.push({ entryPoints: [await contained(join2(root, path))] });
32346
32354
  const imports = /* @__PURE__ */ new Set();
32355
+ const { build } = await loadLazily(
32356
+ () => import("esbuild"),
32357
+ "Oyster's App build tool (esbuild)"
32358
+ );
32347
32359
  for (const module of modules) {
32348
32360
  const result2 = await build({
32349
32361
  ...module,
@@ -32411,14 +32423,14 @@ var manifestSchema = fromJsonString2(
32411
32423
  );
32412
32424
  function readBuildManifest(packageJson) {
32413
32425
  const manifest = decodeUnknownSync(manifestSchema)(packageJson);
32414
- const build2 = manifest.fungi?.build;
32426
+ const build = manifest.fungi?.build;
32415
32427
  return {
32416
32428
  ...manifest,
32417
32429
  fungi: {
32418
32430
  ...manifest.fungi,
32419
- build: build2 === void 0 ? void 0 : decodeUnknownSync(workspaceBuildPolicySchema, {
32431
+ build: build === void 0 ? void 0 : decodeUnknownSync(workspaceBuildPolicySchema, {
32420
32432
  onExcessProperty: "error"
32421
- })(build2)
32433
+ })(build)
32422
32434
  }
32423
32435
  };
32424
32436
  }
@@ -32583,19 +32595,19 @@ async function resolveWorkspaceBuild(options) {
32583
32595
  const path = within(root, join3(appDirectory, stylesheet));
32584
32596
  steps.push({ kind: "tailwind", input: path, output: path });
32585
32597
  }
32586
- const build2 = {
32598
+ const build = {
32587
32599
  directory,
32588
32600
  packageName,
32589
32601
  react: policy.react === true,
32590
32602
  dependencies: Object.freeze(dependencies),
32591
32603
  steps: Object.freeze(steps)
32592
32604
  };
32593
- if (policy.shellEntry === void 0) return Object.freeze(build2);
32605
+ if (policy.shellEntry === void 0) return Object.freeze(build);
32594
32606
  const shellEntry = relative3(
32595
32607
  join3(root, directory),
32596
32608
  join3(root, appDirectory, policy.shellEntry)
32597
32609
  ).split(sep3).join("/");
32598
- return Object.freeze({ ...build2, shellEntry });
32610
+ return Object.freeze({ ...build, shellEntry });
32599
32611
  }
32600
32612
 
32601
32613
  // src/build/bundled-html.ts
@@ -35996,8 +36008,8 @@ var workspacePackageSchema = Struct({
35996
36008
  name: String4.pipe(check(isMinLength(1))),
35997
36009
  path: String4.pipe(check(isMinLength(1)))
35998
36010
  });
35999
- function productionWorkspaceSelectors(build2) {
36000
- return ["--filter-prod", `${build2.packageName}...`];
36011
+ function productionWorkspaceSelectors(build) {
36012
+ return ["--filter-prod", `${build.packageName}...`];
36001
36013
  }
36002
36014
  function capturedWorkspaceBuild(snapshot, entry, run2, backendEntry) {
36003
36015
  return flatMap2(