@agentshouse/app-bridge 0.1.0-alpha.2 → 0.1.0-alpha.3

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 CHANGED
@@ -66,6 +66,9 @@ host.open('/rooms/atlas');
66
66
  ```
67
67
 
68
68
  The host plays the shell and the worker: it delivers the address the App starts
69
- at, records every push and replace and answers each with the address the shell
70
- would then show, records an admitted ceremony, refuses one that is not a
69
+ at and each address `open` plays as Back or Forward through the shell's own
70
+ slice below the App's path, admitting nothing, so it delivers `//notes` exactly
71
+ as a browser at `/apps/<app>//notes` does. It records every push and replace
72
+ and answers each with the address the shell would then show, records an
73
+ admitted ceremony, refuses a push, replace or ceremony that is not a
71
74
  same-origin absolute path, publishes a status, and attaches a Runtime port.
@@ -1,3 +1,4 @@
1
+ import { appAddressOf } from '../../src/apps/remainder.js';
1
2
  import { HOUSE_ADDRESS_MAX_CHARS } from './wire.js';
2
3
  const HOST_ORIGIN = 'https://house.invalid';
3
4
  function sameOriginPath(value) {
@@ -16,7 +17,7 @@ export function createHouseBridgeTestHost(options = {}) {
16
17
  const listeners = new Set();
17
18
  const queued = [];
18
19
  let started = false;
19
- let address = sameOriginPath(options.address ?? '/') ?? '/';
20
+ let address = appAddressOf('/', options.address ?? '/');
20
21
  function deliver(data, ports = []) {
21
22
  const event = { data, ports };
22
23
  if (!started) {
@@ -108,9 +109,7 @@ export function createHouseBridgeTestHost(options = {}) {
108
109
  return address;
109
110
  },
110
111
  open(asked) {
111
- const target = sameOriginPath(asked);
112
- if (target !== null)
113
- arrive(target, false);
112
+ arrive(appAddressOf('/', asked), false);
114
113
  },
115
114
  publish(status) {
116
115
  deliver({ house: 'status', status });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/app-bridge",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Renderer-side client of the agents.house App bridge: navigation, ceremonies, status and Site image reads, with an in-page test host.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -10,17 +10,19 @@
10
10
  },
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./index.d.ts",
14
- "default": "./index.js"
13
+ "types": "./client/src/index.d.ts",
14
+ "default": "./client/src/index.js"
15
15
  },
16
16
  "./test-host": {
17
- "types": "./test-host.d.ts",
18
- "default": "./test-host.js"
17
+ "types": "./client/src/test-host.d.ts",
18
+ "default": "./client/src/test-host.js"
19
19
  }
20
20
  },
21
21
  "files": [
22
- "*.js",
23
- "*.d.ts",
22
+ "client/src/*.js",
23
+ "client/src/*.d.ts",
24
+ "src/apps/remainder.js",
25
+ "src/apps/remainder.d.ts",
24
26
  "README.md"
25
27
  ]
26
28
  }
@@ -0,0 +1,2 @@
1
+ export declare function appAddressOf(root: string, address: string): string;
2
+ export declare function shellAddressOf(root: string, appAddress: string): string;
@@ -0,0 +1,16 @@
1
+ function split(address) {
2
+ const mark = address.search(/[?#]/u);
3
+ return mark < 0
4
+ ? { path: address, rest: '' }
5
+ : { path: address.slice(0, mark), rest: address.slice(mark) };
6
+ }
7
+ export function appAddressOf(root, address) {
8
+ const { path, rest } = split(address);
9
+ const below = root === '/' ? path : path.slice(root.length);
10
+ return `${below.startsWith('/') ? below : `/${below}`}${rest}`;
11
+ }
12
+ export function shellAddressOf(root, appAddress) {
13
+ const { path, rest } = split(appAddress);
14
+ const below = path === '/' ? '' : path;
15
+ return `${root === '/' ? '' : root}${below}${rest}` || '/';
16
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes