@ultimat3/testing 22.12.0 → 22.14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/testing",
3
- "version": "22.12.0",
3
+ "version": "22.14.0",
4
4
  "description": "Test harness: cloned template DBs per worker, frozen clock, sealed network, 6 test types",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,18 +35,18 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@ultimat3/action": "22.12.0",
39
- "@ultimat3/cache": "22.12.0",
40
- "@ultimat3/core": "22.12.0",
41
- "@ultimat3/db": "22.12.0",
42
- "@ultimat3/entity": "22.12.0",
43
- "@ultimat3/i18n": "22.12.0",
44
- "@ultimat3/jobs": "22.12.0",
45
- "@ultimat3/mail": "22.12.0",
46
- "@ultimat3/policy": "22.12.0",
47
- "@ultimat3/query": "22.12.0",
48
- "@ultimat3/realtime": "22.12.0",
49
- "@ultimat3/render": "22.12.0",
50
- "@ultimat3/time": "22.12.0"
38
+ "@ultimat3/action": "22.14.0",
39
+ "@ultimat3/cache": "22.14.0",
40
+ "@ultimat3/core": "22.14.0",
41
+ "@ultimat3/db": "22.14.0",
42
+ "@ultimat3/entity": "22.14.0",
43
+ "@ultimat3/i18n": "22.14.0",
44
+ "@ultimat3/jobs": "22.14.0",
45
+ "@ultimat3/mail": "22.14.0",
46
+ "@ultimat3/policy": "22.14.0",
47
+ "@ultimat3/query": "22.14.0",
48
+ "@ultimat3/realtime": "22.14.0",
49
+ "@ultimat3/render": "22.14.0",
50
+ "@ultimat3/time": "22.14.0"
51
51
  }
52
52
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { mkdtempSync, rmSync } from 'node:fs';
7
7
  import { tmpdir } from 'node:os';
8
- import { join } from 'node:path';
8
+ import { basename, join } from 'node:path';
9
9
  import { islandMountMissing, islandNotBuilt } from './errors';
10
10
  import { createIslandDocument, FakeElement, handlerFor, parseHtml } from './island-dom';
11
11
  import type { ResizeInput } from './island-observers';
@@ -16,12 +16,23 @@ import { deliverResize } from './island-observers';
16
16
  export interface IslandChunkLike {
17
17
  /** App-root-relative POSIX path of the client entry the chunk was built from. */
18
18
  readonly file: string;
19
- /** The built JavaScript, self-contained: an island chunk imports nothing at runtime. */
19
+ /**
20
+ * The built JavaScript. It may import the bundle's shared chunks by a relative `./<name>`, which
21
+ * is why `shared` below is written beside it before it is imported.
22
+ */
23
+ readonly code: string;
24
+ }
25
+
26
+ /** A module two or more islands import, served beside them under its own name. */
27
+ export interface SharedChunkLike {
28
+ readonly url: string;
20
29
  readonly code: string;
21
30
  }
22
31
 
23
32
  export interface IslandBundleLike {
24
33
  readonly chunks: readonly IslandChunkLike[];
34
+ /** Optional, so a builder of your own that splits nothing is still assignable. */
35
+ readonly shared?: readonly SharedChunkLike[];
25
36
  }
26
37
 
27
38
  /**
@@ -265,6 +276,12 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
265
276
  const { documentElement, globals, resizeObservers } = createIslandDocument();
266
277
  const restore = installGlobals({ ...globals, ...options.globals });
267
278
  try {
279
+ // Beside the entry, under the name its bytes import them by: the same relative resolution a
280
+ // browser does under `/islands/`. Named by their content-addressed URL, so a rewrite is the same
281
+ // bytes at the same name.
282
+ for (const shared of bundle.shared ?? []) {
283
+ await Bun.write(join(moduleDirPath(), basename(shared.url)), shared.code);
284
+ }
268
285
  const path = modulePathFor(chunk.code);
269
286
  await Bun.write(path, chunk.code);
270
287
  const entry = entryOf(await import(path), chunk.file);
package/src/index.ts CHANGED
@@ -164,6 +164,7 @@ export type {
164
164
  IslandChunkLike,
165
165
  MountedIsland,
166
166
  MountIslandOptions,
167
+ SharedChunkLike,
167
168
  } from './fixture-island';
168
169
  export { mountIsland } from './fixture-island';
169
170
  export type { JobRunTrace, RunJobs, StepTally } from './fixture-jobs';