Skip to content

Commit

Permalink
Merge branch 'master' into markm-byte-array-2
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jun 22, 2024
2 parents e0ebd6e + 7467efa commit f51b94e
Show file tree
Hide file tree
Showing 87 changed files with 340 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 21.x]
node-version: [18.x, 20.x, 22.x]
platform: [ubuntu-latest]
# windows-latest exhibited flakey tests that are not yet worth the
# trouble to investigate, and blocked us from upgrading yarn from 1 to
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"engines": {
"node": ">=16"
},
"packageManager": "yarn@4.2.2",
"packageManager": "yarn@4.3.0",
"devDependencies": {
"@jessie.js/eslint-plugin": "^0.4.1",
"@octokit/core": "^3.4.0",
Expand All @@ -25,7 +25,7 @@
"type-coverage": "^2.26.3",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "5.5.0-beta",
"typescript": "5.5.2",
"typescript-eslint": "^7.3.1"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/base64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.2.5",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"LICENSE*",
Expand Down
10 changes: 10 additions & 0 deletions packages/bundle-source/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

# Next version

- Adds support for `--no-transforms` (`-T`) which generates bundles with
original sources.
A future version of `@endo/import-bundle` will be able to execute this
kind of bundle on XS and in Node.js, but will remain opt-in because
they cannot be made to run on the web without further work on module
virtualization in the platform without entraining a client-side
dependency on a JavaScript parser framework (namely Babel).

# v3.2.1 (2024-03-20)

- Fixes an install-time bug introduced in 3.2.0.
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ava": "^6.1.3",
"c8": "^7.14.0",
"eslint": "^8.57.0",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"keywords": [],
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/bundle-source/src/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ export const makeFileWriter = (
* fs: Pick<import('fs'), 'existsSync'> &
* { promises: Pick<
* import('fs/promises'),
* 'readFile' | 'stat' | 'writeFile' | 'mkdir' | 'rm'
* 'readFile' | 'stat' | 'writeFile' | 'mkdir' | 'rename' | 'rm'
* >,
* },
* path: Pick<import('path'), 'resolve' | 'relative' | 'normalize'>,
* path: Pick<import('path'), 'dirname' | 'resolve' | 'relative' | 'normalize'>,
* os: Pick<import('os'), 'platform'>,
* }} io
* @param {number} [pid]
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-source/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parseArgs } from 'util';
import { jsOpts, jsonOpts, makeNodeBundleCache } from '../cache.js';

const USAGE =
'bundle-source [--cache-js | --cache-json] cache/ module1.js bundleName1 module2.js bundleName2 ...';
'bundle-source [-T,--no-transforms] [--cache-js | --cache-json] cache/ module1.js bundleName1 module2.js bundleName2 ...';

const options = /** @type {const} */ ({
'no-transforms': {
Expand Down
2 changes: 1 addition & 1 deletion packages/captp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@endo/ses-ava": "^1.2.2",
"ava": "^6.1.3",
"c8": "^7.14.0",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"dependencies": {
"@endo/errors": "^1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/check-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.2.5",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"*.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/cjs-module-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.2.5",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"LICENSE*",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@endo/bundle-source": "^3.2.3",
"@endo/compartment-mapper": "^1.1.5",
"@endo/daemon": "^2.3.0",
"@endo/errors": "^1.2.2",
"@endo/eventual-send": "^1.2.2",
"@endo/exo": "^1.5.0",
"@endo/far": "^1.1.2",
Expand All @@ -57,7 +58,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.2.5",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"LICENSE*",
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/commands/run.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* global globalThis, process */
import url from 'url';
import os from 'os';
import { E, Far } from '@endo/far';
Expand All @@ -10,7 +10,8 @@ import { withEndoAgent } from '../context.js';
import { parsePetNamePath } from '../pet-name.js';

const endowments = harden({
assert,
// See https://github.com/Agoric/agoric-sdk/issues/9515
assert: globalThis.assert,
E,
Far,
makeExo,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/pet-name.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { quote: q } = assert;
import { q } from '@endo/errors';

/**
* Splits a dot-delimited pet name path into an array of pet names.
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"ava": "^6.1.3",
"c8": "^7.14.0",
"tsd": "^0.30.7",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"*.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/compartment-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.2.5",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"LICENSE*",
Expand Down
5 changes: 4 additions & 1 deletion packages/compartment-mapper/test/main.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global globalThis */

import 'ses';
import test from 'ava';
import { loadLocation, importArchive, makeBundle } from '../index.js';
Expand Down Expand Up @@ -96,7 +98,8 @@ test('makeBundle / importArchive', async t => {
TextEncoder,
TextDecoder,
URL,
assert,
// See https://github.com/Agoric/agoric-sdk/issues/9515
assert: globalThis.assert,
});
const evasiveArchiverBundle = archiverBundle
.replace(/(?<!\.)\bimport\b(?![:"'])/g, 'IMPORT')
Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.2.5",
"typescript": "5.5.0-beta"
"typescript": "5.5.2"
},
"files": [
"LICENSE*",
Expand Down
3 changes: 1 addition & 2 deletions packages/daemon/src/daemon-node-powers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { makePromiseKit } from '@endo/promise-kit';
import { makePipe } from '@endo/stream';
import { makeNodeReader, makeNodeWriter } from '@endo/stream-node';
import { q } from '@endo/errors';
import { makeNetstringCapTP } from './connection.js';
import { makeReaderRef } from './reader-ref.js';
import { makePetStoreMaker } from './pet-store.js';
Expand All @@ -14,8 +15,6 @@ import { makeSerialJobs } from './serial-jobs.js';
/** @import { ERef, FarRef } from '@endo/eventual-send' */
/** @import { Config, CryptoPowers, DaemonWorkerFacet, DaemonicPersistencePowers, DaemonicPowers, EndoReadable, FilePowers, Formula, NetworkPowers, SocketPowers, WorkerDaemonFacet } from './types.js' */

const { quote: q } = assert;

const textEncoder = new TextEncoder();

/**
Expand Down
12 changes: 5 additions & 7 deletions packages/daemon/src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { makeExo } from '@endo/exo';
import { E, Far } from '@endo/far';
import { makeMarshal } from '@endo/marshal';
import { makePromiseKit } from '@endo/promise-kit';
import { q } from '@endo/errors';
import { makeError, q, X } from '@endo/errors';
import { makeRefReader } from './ref-reader.js';
import { makeDirectoryMaker } from './directory.js';
import { makeMailboxMaker } from './mail.js';
Expand Down Expand Up @@ -491,7 +491,7 @@ const makeDaemonCore = async (
const mustGetIdForRef = ref => {
const id = idForRef.get(ref);
if (id === undefined) {
throw assert.error(assert.details`No corresponding formula for ${ref}`);
throw makeError(X`No corresponding formula for ${ref}`);
}
return id;
};
Expand All @@ -501,11 +501,9 @@ const makeDaemonCore = async (
const ref = refForId.get(id);
if (ref === undefined) {
if (formulaForId.get(id) !== undefined) {
throw assert.error(
assert.details`Formula has not produced a ref ${id}`,
);
throw makeError(X`Formula has not produced a ref ${id}`);
}
throw assert.error(assert.details`Unknown identifier ${id}`);
throw makeError(X`Unknown identifier ${id}`);
}
return ref;
};
Expand Down Expand Up @@ -1576,7 +1574,7 @@ const makeDaemonCore = async (
const guestNodeNumber = url.hostname;

if (!guestHandleNumber) {
throw assert.error('Handle locator must have an "id" parameter');
throw makeError('Handle locator must have an "id" parameter');
}

const guestHandleId = formatId({
Expand Down
3 changes: 1 addition & 2 deletions packages/daemon/src/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import { E } from '@endo/far';
import { makeExo } from '@endo/exo';
import { q } from '@endo/errors';
import { makeIteratorRef } from './reader-ref.js';
import { formatLocator, idFromLocator } from './locator.js';

import { DirectoryInterface } from './interfaces.js';

const { quote: q } = assert;

/** @import { DaemonCore, MakeDirectoryNode, EndoDirectory, NameHub, LocatorNameChange, Context } from './types.js' */

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/daemon/src/formula-identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/** @import { IdRecord } from './types.js' */

const { quote: q } = assert;
import { makeError, q } from '@endo/errors';

const numberPattern = /^[0-9a-f]{128}$/;
const idPattern = /^(?<number>[0-9a-f]{128}):(?<node>[0-9a-f]{128})$/;
Expand All @@ -19,7 +19,7 @@ export const isValidNumber = allegedNumber =>
*/
export const assertValidNumber = allegedNumber => {
if (!isValidNumber(allegedNumber)) {
throw assert.error(`Invalid number ${q(allegedNumber)}`);
throw makeError(`Invalid number ${q(allegedNumber)}`);
}
};

Expand All @@ -45,11 +45,11 @@ export const assertValidId = (id, petName) => {
export const parseId = id => {
const match = idPattern.exec(id);
if (match === null) {
throw assert.error(`Invalid formula identifier ${q(id)}`);
throw makeError(`Invalid formula identifier ${q(id)}`);
}
const { groups } = match;
if (groups === undefined) {
throw assert.error(
throw makeError(
`Programmer invariant failure: expected match groups, formula identifier was ${q(
id,
)}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/formula-type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

const { quote: q } = assert;
import { q } from '@endo/errors';

// Note: Alphabetically sorted
const formulaTypes = new Set([
Expand Down
7 changes: 3 additions & 4 deletions packages/daemon/src/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { E } from '@endo/far';
import { makeExo } from '@endo/exo';
import { makeError, q } from '@endo/errors';
import { makeIteratorRef } from './reader-ref.js';
import { assertPetName, petNamePathFrom } from './pet-name.js';
import { parseId, formatId } from './formula-identifier.js';
Expand All @@ -14,8 +15,6 @@ import { makeDeferredTasks } from './deferred-tasks.js';

import { HostInterface } from './interfaces.js';

const { quote: q } = assert;

/** @param {string} name */
const assertPowersName = name => {
['NONE', 'AGENT', 'ENDO'].includes(name) || assertPetName(name);
Expand Down Expand Up @@ -494,10 +493,10 @@ export const makeHostMaker = ({

nodeNumber || assert.Fail`Invitation must have a hostname`;
if (!remoteHandleNumber) {
throw assert.error(`Invitation must have a "from" parameter`);
throw makeError(`Invitation must have a "from" parameter`);
}
if (invitationNumber === null) {
throw assert.error(`Invitation must have an "id" parameter`);
throw makeError(`Invitation must have an "id" parameter`);
}

/** @type {PeerInfo} */
Expand Down
17 changes: 8 additions & 9 deletions packages/daemon/src/locator.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// @ts-check

import { makeError, q } from '@endo/errors';
import { formatId, isValidNumber, parseId } from './formula-identifier.js';
import { isValidFormulaType } from './formula-type.js';

const { quote: q } = assert;

/**
* The endo locator format:
* ```
Expand All @@ -28,7 +27,7 @@ const isValidLocatorType = allegedType =>
*/
const assertValidLocatorType = allegedType => {
if (!isValidLocatorType(allegedType)) {
throw assert.error(`Unrecognized locator type ${q(allegedType)}`);
throw makeError(`Unrecognized locator type ${q(allegedType)}`);
}
};

Expand All @@ -40,35 +39,35 @@ export const parseLocator = allegedLocator => {
const errorPrefix = `Invalid locator ${q(allegedLocator)}:`;

if (!URL.canParse(allegedLocator)) {
throw assert.error(`${errorPrefix} Invalid URL.`);
throw makeError(`${errorPrefix} Invalid URL.`);
}
const url = new URL(allegedLocator);

if (!allegedLocator.startsWith('endo://')) {
throw assert.error(`${errorPrefix} Invalid protocol.`);
throw makeError(`${errorPrefix} Invalid protocol.`);
}

const node = url.host;
if (!isValidNumber(node)) {
throw assert.error(`${errorPrefix} Invalid node identifier.`);
throw makeError(`${errorPrefix} Invalid node identifier.`);
}

if (
url.searchParams.size !== 2 ||
!url.searchParams.has('id') ||
!url.searchParams.has('type')
) {
throw assert.error(`${errorPrefix} Invalid search params.`);
throw makeError(`${errorPrefix} Invalid search params.`);
}

const number = url.searchParams.get('id');
if (number === null || !isValidNumber(number)) {
throw assert.error(`${errorPrefix} Invalid id.`);
throw makeError(`${errorPrefix} Invalid id.`);
}

const formulaType = url.searchParams.get('type');
if (formulaType === null || !isValidLocatorType(formulaType)) {
throw assert.error(`${errorPrefix} Invalid type.`);
throw makeError(`${errorPrefix} Invalid type.`);
}

return { formulaType, node, number };
Expand Down
Loading

0 comments on commit f51b94e

Please sign in to comment.