Skip to content

Commit

Permalink
Merge branch 'master' into markm-rank-strings-by-codepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed May 17, 2024
2 parents 44b1665 + 03eff8f commit 9e049f3
Show file tree
Hide file tree
Showing 48 changed files with 384 additions and 267 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"type-coverage": "^2.26.3",
"typedoc": "^0.25.12",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "~5.5.0-dev.20240327",
"typescript": "5.5.0-beta",
"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.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
4 changes: 4 additions & 0 deletions packages/captp/src/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export const makeCapTP = (
const seen = new Set();

return harden({
/**
* @param {T} specimen
* @returns {T}
*/
add(specimen) {
if (predicate(specimen)) {
seen.add(specimen);
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.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"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.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
21 changes: 14 additions & 7 deletions packages/cli/src/commands/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import bundleSource from '@endo/bundle-source';
import { makeReaderRef } from '@endo/daemon';
import { E } from '@endo/far';
import { withEndoAgent } from '../context.js';
import { parsePetNamePath } from '../pet-name.js';
import { randomHex16 } from '../random.js';

const textEncoder = new TextEncoder();
Expand Down Expand Up @@ -38,6 +39,8 @@ export const makeCommand = async ({
return;
}

const resultPath = resultName && parsePetNamePath(resultName);

/** @type {import('@endo/eventual-send').FarRef<import('@endo/stream').Reader<string>> | undefined} */
let bundleReaderRef;
/** @type {string | undefined} */
Expand Down Expand Up @@ -68,14 +71,18 @@ export const makeCommand = async ({
workerName,
url.pathToFileURL(path.resolve(importPath)).href,
powersName,
resultName,
resultPath,
)
: E(agent).makeBundle(workerName, bundleName, powersName, resultName);
const result = await resultP;
console.log(result);

if (temporaryBundleName) {
await E(agent).remove(temporaryBundleName);
: E(agent).makeBundle(workerName, bundleName, powersName, resultPath);
let result;
try {
result = await resultP;
console.log(result);
} finally {
if (temporaryBundleName) {
await E(agent).remove(temporaryBundleName);
}
}
return result;
});
};
10 changes: 10 additions & 0 deletions packages/cli/src/commands/mkdir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* global process */
import os from 'os';
import { E } from '@endo/far';
import { withEndoAgent } from '../context.js';
import { parsePetNamePath } from '../pet-name.js';

export const mkdir = async ({ agentNames, directoryPath }) =>
withEndoAgent(agentNames, { os, process }, async ({ agent }) => {
await E(agent).makeDirectory(...parsePetNamePath(directoryPath));
});
17 changes: 10 additions & 7 deletions packages/cli/src/commands/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { makeReaderRef } from '@endo/daemon';
import { E } from '@endo/far';

import { withEndoAgent } from '../context.js';
import { parsePetNamePath } from '../pet-name.js';

/**
* @param {Array<Uint8Array>} arrays
Expand Down Expand Up @@ -72,32 +73,34 @@ export const store = async ({
)})`;
}

const parsedName = parsePetNamePath(name);

await withEndoAgent(agentNames, { os, process }, async ({ agent }) => {
if (storeText !== undefined) {
await E(agent).storeValue(storeText, name);
await E(agent).storeValue(storeText, parsedName);
} else if (storeJson !== undefined) {
await E(agent).storeValue(JSON.parse(storeJson), name);
await E(agent).storeValue(JSON.parse(storeJson), parsedName);
} else if (storeBigInt !== undefined) {
await E(agent).storeValue(BigInt(storeBigInt), name);
await E(agent).storeValue(BigInt(storeBigInt), parsedName);
} else if (storeTextStdin !== undefined) {
const reader = makeNodeReader(process.stdin);
const bytes = await asyncConcat(reader);
const text = new TextDecoder().decode(bytes);
await E(agent).storeValue(text, name);
await E(agent).storeValue(text, parsedName);
} else if (storeJsonStdin !== undefined) {
const reader = makeNodeReader(process.stdin);
const bytes = await asyncConcat(reader);
const text = new TextDecoder().decode(bytes);
await E(agent).storeValue(JSON.parse(text), name);
await E(agent).storeValue(JSON.parse(text), parsedName);
} else if (storeStdin !== undefined) {
const reader = makeNodeReader(process.stdin);
const readerRef = makeReaderRef(reader);
await E(agent).storeBlob(readerRef, name);
await E(agent).storeBlob(readerRef, parsedName);
} else if (storePath !== undefined) {
const nodeReadStream = fs.createReadStream(storePath);
const reader = makeNodeReader(nodeReadStream);
const readerRef = makeReaderRef(reader);
await E(agent).storeBlob(readerRef, name);
await E(agent).storeBlob(readerRef, parsedName);
}
});
};
10 changes: 10 additions & 0 deletions packages/cli/src/endo.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ export const main = async rawArgs => {
return mkguest({ agentName, handleName, agentNames, introducedNames });
});

program
.command('mkdir <path>')
.option(...commonOptions.as)
.description('makes a directory (pet store, name hub)')
.action(async (directoryPath, cmd) => {
const { as: agentNames } = cmd.opts();
const { mkdir } = await import('./commands/mkdir.js');
return mkdir({ agentNames, directoryPath });
});

program
.command('invite <guest-name>')
.option(...commonOptions.as)
Expand Down
6 changes: 3 additions & 3 deletions packages/common/from-unique-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const { ownKeys } = Reflect;
* like `Object.fromEntries` but hardens the result.
* Use it to protect from property names computed from user-provided data.
*
* @template K,V
* @param {Iterable<[K,V]>} allEntries
* @returns {{[k: K]: V}}
* @template [T=any]
* @param {Iterable<readonly [PropertyKey, T]>} allEntries
* @returns {{ [k: string]: T; }}
*/
export const fromUniqueEntries = allEntries => {
const entriesArray = [...allEntries];
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 @@ -62,7 +62,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
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.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
17 changes: 10 additions & 7 deletions packages/daemon/src/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,11 @@ export const makeDirectoryMaker = ({
await toHub.write([toName], id);
};

/** @type {EndoDirectory['makeDirectory']} */
const makeDirectory = async directoryPetName => {
const { value: directory, id } = await formulateDirectory();
await petStore.write(directoryPetName, id);
return directory;
};

/** @type {EndoDirectory['write']} */
const write = async (petNamePath, id) => {
if (typeof petNamePath === 'string') {
petNamePath = [petNamePath];
}
if (petNamePath.length === 1) {
const petName = petNamePath[0];
await petStore.write(petName, id);
Expand All @@ -225,6 +221,13 @@ export const makeDirectoryMaker = ({
await hub.write([name], id);
};

/** @type {EndoDirectory['makeDirectory']} */
const makeDirectory = async (...directoryPetNamePath) => {
const { value: directory, id } = await formulateDirectory();
await write(directoryPetNamePath, id);
return directory;
};

/** @type {EndoDirectory} */
const directory = {
has,
Expand Down
12 changes: 5 additions & 7 deletions packages/daemon/src/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,15 @@ export const makeHostMaker = ({

/**
* @param {ERef<AsyncIterableIterator<string>>} readerRef
* @param {string} [petName]
* @param {string | string[]} [petName]
*/
const storeBlob = async (readerRef, petName) => {
/** @type {DeferredTasks<ReadableBlobDeferredTaskParams>} */
const tasks = makeDeferredTasks();

if (petName !== undefined) {
assertPetName(petName);
tasks.push(identifiers =>
petStore.write(petName, identifiers.readableBlobId),
E(directory).write(petName, identifiers.readableBlobId),
);
}

Expand All @@ -131,9 +130,8 @@ export const makeHostMaker = ({
const tasks = makeDeferredTasks();

if (petName !== undefined) {
assertPetName(petName);
tasks.push(identifiers =>
petStore.write(petName, identifiers.marshalId),
E(directory).write(petName, identifiers.marshalId),
);
}

Expand Down Expand Up @@ -244,7 +242,7 @@ export const makeHostMaker = ({
* Helper function for makeUnconfined and makeBundle.
* @param {string} powersName
* @param {string} workerName
* @param {string} [resultName]
* @param {string | string[]} [resultName]
*/
const prepareMakeCaplet = (powersName, workerName, resultName) => {
assertPowersName(powersName);
Expand All @@ -263,7 +261,7 @@ export const makeHostMaker = ({

if (resultName !== undefined) {
tasks.push(identifiers =>
petStore.write(resultName, identifiers.capletId),
E(directory).write(resultName, identifiers.capletId),
);
}

Expand Down
9 changes: 6 additions & 3 deletions packages/daemon/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ export interface NameHub {
): AsyncGenerator<PetStoreNameChange, undefined, undefined>;
lookup(...petNamePath: string[]): Promise<unknown>;
reverseLookup(value: unknown): Array<string>;
write(petNamePath: string[], id: string): Promise<void>;
write(petNamePath: string | string[], id: string): Promise<void>;
remove(...petNamePath: string[]): Promise<void>;
move(fromPetName: string[], toPetName: string[]): Promise<void>;
copy(fromPetName: string[], toPetName: string[]): Promise<void>;
}

export interface EndoDirectory extends NameHub {
makeDirectory(petName: string): Promise<EndoDirectory>;
makeDirectory(...petNamePath: string[]): Promise<EndoDirectory>;
}

export type MakeDirectoryNode = (petStore: PetStore) => EndoDirectory;
Expand Down Expand Up @@ -568,7 +568,10 @@ export interface EndoHost extends EndoAgent {
readerRef: ERef<AsyncIterableIterator<string>>,
petName: string,
): Promise<FarRef<EndoReadable>>;
storeValue<T extends Passable>(value: T, petName: string): Promise<void>;
storeValue<T extends Passable>(
value: T,
petName: string | string[],
): Promise<void>;
provideGuest(
petName?: string,
opts?: MakeHostOrGuestOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/env-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"*.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Object.assign(assert, assertions);
// quote behavior for that environment.
const bareOrQuote = bare || quote;

// XXX module exports fail if these aren't in scope
/** @import {AssertMakeErrorOptions, Details, GenericErrorConstructor} from 'ses' */

export {
// assertions
assert,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"requireindex": "~1.1.0",
"ts-api-utils": "~1.0.1",
"tsutils": "~3.21.0",
"typescript": "~5.5.0-dev.20240327",
"typescript": "5.5.0-beta",
"typescript-eslint": "^7.3.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/evasive-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"eslint": "^8.57.0",
"rollup": "^2.79.1",
"tsd": "^0.30.7",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"*.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/eventual-send/src/no-shim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import makeE from './E.js';

// XXX module exports for HandledPromise fail if these aren't in scope
/** @import {Handler, HandledExecutor} from './handled-promise.js' */

const hp = HandledPromise;
export const E = makeE(hp);
export { hp as HandledPromise };
Expand Down
2 changes: 1 addition & 1 deletion packages/exo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"*.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/lp32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.2.5",
"typescript": "~5.5.0-dev.20240327"
"typescript": "5.5.0-beta"
},
"files": [
"LICENSE*",
Expand Down
Loading

0 comments on commit 9e049f3

Please sign in to comment.