@isoloop/runtime 0.1.0-next.10 → 0.1.0-next.12

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/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @isoloop/runtime
2
+
3
+ The [Isoloop](https://isoloop.dev) runtime inside each worker: write a part of your app as an isolate, with a UI or headless, in plain TypeScript.
4
+
5
+ ## What you get
6
+
7
+ - **One way to write an isolate:** `defineIsolate` with a `start(ctx)`, for a widget, a feed, an engine or a request handler.
8
+ - **Plain DOM in a worker:** create elements, listen to input and style your surface, and the host draws it.
9
+ - **The bus:** typed publish and subscribe, straight to the bus worker, with replay after a restart.
10
+ - **The page when you need it:** async calls to measure, focus, scroll, navigate and get a canvas to draw on.
11
+ - **A lifecycle:** shutdown handlers, error reporting, and a hold against suspension.
12
+ - **Unit tests without a worker:** `createTestContext` from `@isoloop/runtime/testing`.
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ npm install @isoloop/runtime@next
18
+ ```
19
+
20
+ ## Example
21
+
22
+ ```ts
23
+ import { defineIsolate } from '@isoloop/runtime';
24
+ import { count } from './topics'; // a topic from your contracts
25
+
26
+ export default defineIsolate<HTMLElement>({
27
+ start(ctx) {
28
+ const label = document.createElement('p');
29
+ label.textContent = 'Waiting for a count';
30
+ ctx.root?.append(label);
31
+
32
+ ctx.bus.subscribe(
33
+ count,
34
+ (record) => {
35
+ label.textContent = `Count: ${record.value}`;
36
+ },
37
+ { from: 'earliest' },
38
+ );
39
+ },
40
+ });
41
+ ```
42
+
43
+ ## Learn more
44
+
45
+ - [Writing isolates](https://isoloop.dev/docs/isolates/)
46
+ - [Testing isolates and contracts](https://isoloop.dev/docs/testing/)
47
+ - [What Isoloop can't hide](https://isoloop.dev/docs/limits/)
48
+ - [API reference](https://isoloop.dev/docs/api/runtime/)
package/dist/bootstrap.js CHANGED
@@ -296,7 +296,7 @@ var init_dist = __esmMin((() => {
296
296
  };
297
297
  isInspectToIsolate = envelopeGuard(INSPECT_TO_ISOLATE);
298
298
  }));
299
- // src/busy.ts
299
+ // src/pools/busy.ts
300
300
  function createBusy(now = () => performance.now()) {
301
301
  let frame = null;
302
302
  const spent = /* @__PURE__ */ new Map();
@@ -609,7 +609,7 @@ var init_busy = __esmMin((() => {
609
609
  busy = createBusy();
610
610
  BUSY = Symbol.for("isoloop.busy");
611
611
  }));
612
- // src/freeze.ts
612
+ // src/pools/freeze.ts
613
613
  init_dist();
614
614
  init_busy();
615
615
  /** Constructors whose `prototype` and statics are frozen, if this engine has them. */
@@ -772,7 +772,7 @@ function freezeBuiltins() {
772
772
  Object.freeze(JSON);
773
773
  Object.freeze(Reflect);
774
774
  }
775
- // src/inspector.ts
775
+ // src/isolate/inspector.ts
776
776
  function createInspectorClient() {
777
777
  let port = null;
778
778
  let ended = false;
@@ -953,7 +953,7 @@ var init_inspector = __esmMin((() => {
953
953
  failure = (r) => r.ok ? void 0 : new BusError(r.error);
954
954
  endedError = () => /* @__PURE__ */ new Error("inspector: its port has ended; controls no longer act");
955
955
  }));
956
- // src/bus-client.ts
956
+ // src/bus/bus-client.ts
957
957
  function createBusClient(first, o = {}) {
958
958
  const limit = o.inboxLimit ?? 1e3;
959
959
  const now = o.now ?? (() => performance.now());
@@ -1244,7 +1244,7 @@ var init_bus_client = __esmMin((() => {
1244
1244
  };
1245
1245
  REQUEST_TIMEOUT_MS = 3e4;
1246
1246
  }));
1247
- // src/host-calls.ts
1247
+ // src/isolate/host-calls.ts
1248
1248
  function createHostCalls(opts) {
1249
1249
  const timeoutMs = opts.timeoutMs ?? 5e3;
1250
1250
  const pending = /* @__PURE__ */ new Map();
@@ -1337,7 +1337,7 @@ var init_host_calls = __esmMin((() => {
1337
1337
  "height"
1338
1338
  ].every((k) => typeof Reflect.get(x, k) === "number");
1339
1339
  }));
1340
- // src/keep-awake.ts
1340
+ // src/isolate/keep-awake.ts
1341
1341
  function createKeepAwake(now = () => performance.now()) {
1342
1342
  const holds = /* @__PURE__ */ new Map();
1343
1343
  let next = 0;
@@ -2569,7 +2569,7 @@ var init_worker = __esmMin((() => {
2569
2569
  init_dom_Bd22osRG();
2570
2570
  init_install_0dSawI50();
2571
2571
  }));
2572
- // src/render/index.ts
2572
+ // src/render/render.ts
2573
2573
  function sharedDom(scope) {
2574
2574
  if (!shared) {
2575
2575
  shared = createDom({
@@ -2703,8 +2703,8 @@ var init_render = __esmMin((() => {
2703
2703
  headListeners = /* @__PURE__ */ new Set();
2704
2704
  }));
2705
2705
  // package.json
2706
- var version = "0.1.0-next.10";
2707
- // src/vanilla.ts
2706
+ var version = "0.1.0-next.12";
2707
+ // src/isolate/vanilla.ts
2708
2708
  var vanilla_exports = /* @__PURE__ */ __exportAll({
2709
2709
  REQUIRES: () => REQUIRES,
2710
2710
  createVanillaIsolate: () => createVanillaIsolate,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BusError, majorMinor } from "@isoloop/protocol";
2
2
  import "@isoloop/dom/worker";
3
- // src/host-calls.ts
3
+ // src/isolate/host-calls.ts
4
4
  /** A host call (`ctx.host`) that failed, with an error code to branch on. */
5
5
  var HostCallError = class extends Error {
6
6
  /** What went wrong: `not_found`, `no_surface`, `forbidden`, `invalid`, `timeout`, … */
@@ -15,13 +15,13 @@ var HostCallError = class extends Error {
15
15
  this.code = code;
16
16
  }
17
17
  };
18
- // src/vanilla.ts
18
+ // src/isolate/vanilla.ts
19
19
  /**
20
20
  * This build's stamp: `major.minor` of the package version, inlined when tsdown bundles it.
21
21
  *
22
22
  * @internal
23
23
  */
24
- const REQUIRES = majorMinor("0.1.0-next.10") ?? "0.0";
24
+ const REQUIRES = majorMinor("0.1.0-next.12") ?? "0.0";
25
25
  /**
26
26
  * Types an isolate module's default export and stamps it with the version
27
27
  * it was built against.
package/dist/worker.js CHANGED
@@ -296,7 +296,7 @@ var init_dist = __esmMin((() => {
296
296
  };
297
297
  isInspectToIsolate = envelopeGuard(INSPECT_TO_ISOLATE);
298
298
  }));
299
- // src/busy.ts
299
+ // src/pools/busy.ts
300
300
  function createBusy(now = () => performance.now()) {
301
301
  let frame = null;
302
302
  const spent = /* @__PURE__ */ new Map();
@@ -609,7 +609,7 @@ var init_busy = __esmMin((() => {
609
609
  busy = createBusy();
610
610
  BUSY = Symbol.for("isoloop.busy");
611
611
  }));
612
- // src/freeze.ts
612
+ // src/pools/freeze.ts
613
613
  /** The protected properties, per prototype, that are left as frozen data. */
614
614
  function protectedProperties() {
615
615
  const out = /* @__PURE__ */ new Map();
@@ -753,7 +753,7 @@ var init_freeze = __esmMin((() => {
753
753
  ];
754
754
  ITERATOR = Symbol.iterator;
755
755
  }));
756
- // src/inspector.ts
756
+ // src/isolate/inspector.ts
757
757
  function createInspectorClient() {
758
758
  let port = null;
759
759
  let ended = false;
@@ -935,7 +935,7 @@ var init_inspector = __esmMin((() => {
935
935
  failure = (r) => r.ok ? void 0 : new BusError(r.error);
936
936
  endedError = () => /* @__PURE__ */ new Error("inspector: its port has ended; controls no longer act");
937
937
  }));
938
- // src/bus-client.ts
938
+ // src/bus/bus-client.ts
939
939
  function createBusClient(first, o = {}) {
940
940
  const limit = o.inboxLimit ?? 1e3;
941
941
  const now = o.now ?? (() => performance.now());
@@ -1226,7 +1226,7 @@ var init_bus_client = __esmMin((() => {
1226
1226
  };
1227
1227
  REQUEST_TIMEOUT_MS = 3e4;
1228
1228
  }));
1229
- // src/host-calls.ts
1229
+ // src/isolate/host-calls.ts
1230
1230
  function createHostCalls(opts) {
1231
1231
  const timeoutMs = opts.timeoutMs ?? 5e3;
1232
1232
  const pending = /* @__PURE__ */ new Map();
@@ -1319,7 +1319,7 @@ var init_host_calls = __esmMin((() => {
1319
1319
  "height"
1320
1320
  ].every((k) => typeof Reflect.get(x, k) === "number");
1321
1321
  }));
1322
- // src/keep-awake.ts
1322
+ // src/isolate/keep-awake.ts
1323
1323
  function createKeepAwake(now = () => performance.now()) {
1324
1324
  const holds = /* @__PURE__ */ new Map();
1325
1325
  let next = 0;
@@ -2551,7 +2551,7 @@ var init_worker = __esmMin((() => {
2551
2551
  init_dom_Bd22osRG();
2552
2552
  init_install_0dSawI50();
2553
2553
  }));
2554
- // src/render/index.ts
2554
+ // src/render/render.ts
2555
2555
  function sharedDom(scope) {
2556
2556
  if (!shared) {
2557
2557
  shared = createDom({
@@ -2686,8 +2686,8 @@ var init_render = __esmMin((() => {
2686
2686
  headListeners = /* @__PURE__ */ new Set();
2687
2687
  }));
2688
2688
  // package.json
2689
- var version = "0.1.0-next.10";
2690
- // src/vanilla.ts
2689
+ var version = "0.1.0-next.12";
2690
+ // src/isolate/vanilla.ts
2691
2691
  var vanilla_exports = /* @__PURE__ */ __exportAll({
2692
2692
  REQUIRES: () => REQUIRES,
2693
2693
  createVanillaIsolate: () => createVanillaIsolate,
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@isoloop/runtime",
3
- "version": "0.1.0-next.10",
4
- "description": "Isolate-side runtime that runs inside each worker.",
3
+ "version": "0.1.0-next.12",
4
+ "description": "The Isoloop runtime: write a part of your app as an isolate in a worker, with a UI or headless, in plain TypeScript.",
5
+ "keywords": [
6
+ "isoloop",
7
+ "web-workers",
8
+ "event-loop",
9
+ "isolation",
10
+ "microfrontends"
11
+ ],
12
+ "homepage": "https://isoloop.dev/docs/api/runtime/",
5
13
  "license": "MIT",
6
14
  "type": "module",
7
15
  "sideEffects": [
@@ -35,8 +43,8 @@
35
43
  }
36
44
  },
37
45
  "dependencies": {
38
- "@isoloop/dom": "0.1.0-next.10",
39
- "@isoloop/protocol": "0.1.0-next.10"
46
+ "@isoloop/dom": "0.1.0-next.12",
47
+ "@isoloop/protocol": "0.1.0-next.12"
40
48
  },
41
49
  "devDependencies": {
42
50
  "typescript": "7.0.2"