Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define Key, PureData using parameterized Passable (WIP) #1952

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
38b4b64
chore(deps): bump typescript-eslint
turadg Jan 9, 2024
c3b1209
chore(deps): bump typescript to 5.3.3
turadg Jan 8, 2024
81b9997
chore(types): fix imports
turadg Jan 9, 2024
5f38eeb
chore(types): update typeCoverage floor
turadg Jan 9, 2024
3867ea5
chore(types): update typeCoverage floor
turadg Jan 8, 2024
63108da
feat(types): def for Passable
turadg Jan 8, 2024
cc9491d
chore(types): update typeCoverage floor
turadg Jan 8, 2024
daadbf7
more isFake
turadg Jan 9, 2024
642571e
WIP
turadg Jan 8, 2024
b0e27e0
WIP
turadg Jan 8, 2024
2d519a4
refresh
turadg Jan 8, 2024
e9666ff
chore(types): PassStyleOf
turadg Jan 9, 2024
c09c17d
refresh floor
turadg Jan 9, 2024
a65dbe7
tighten Pattern
turadg Jan 9, 2024
850c48e
better RemotableObject
turadg Jan 9, 2024
27b8c00
type makeTagged
turadg Jan 9, 2024
826aa9e
inline singular callbacks
turadg Jan 9, 2024
2319eda
PASS_STYLE
turadg Jan 9, 2024
f40b648
specify PASS_STYLE for CopyTagged
turadg Jan 9, 2024
16f2e0b
fixup PassStyleOf
turadg Jan 9, 2024
ae3011b
Remotable good?
turadg Jan 9, 2024
331cf3d
WIP
turadg Jan 9, 2024
b1c806d
punt getInterfaceOf
turadg Jan 9, 2024
a0c1e63
WIP
turadg Jan 9, 2024
f21298e
fix sorting
turadg Jan 9, 2024
75605a1
chore(types): update typeCoverage floor
turadg Jan 9, 2024
3d927c3
restore PassableCap
turadg Jan 9, 2024
bab8f26
WIP(passable): types .js -> .d.ts
dckc Jan 10, 2024
f9f2d52
chore(passable): convert type decls to ts syntax
dckc Jan 10, 2024
1451fe0
SQUASHME: export the types
dckc Jan 10, 2024
60d085f
chore: parameterize Passable
dckc Jan 10, 2024
bf46ee8
chore(marshal): rename types.js -> .d.ts
dckc Jan 10, 2024
d224d06
chore(marshal): types JSDoc -> ts (WIP)
dckc Jan 10, 2024
ec99b2b
chore(patterns): rename types.js -> .d.ts
dckc Jan 10, 2024
d862699
SQUASHME: constrain PureData
dckc Jan 10, 2024
dfa53c0
chore(patterns): define Key using parameterized Passable
dckc Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"devDependencies": {
"@jessie.js/eslint-plugin": "^0.3.0",
"@octokit/core": "^3.4.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"ava": "^5.3.0",
"eslint": "^8.46.0",
"eslint-config-airbnb-base": "^15.0.0",
Expand All @@ -24,7 +24,7 @@
"lerna-update-wizard": "^0.17.5",
"type-coverage": "^2.26.3",
"typedoc": "^0.25.7",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"scripts": {
"clean": "lerna clean",
Expand Down
2 changes: 1 addition & 1 deletion packages/base64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"LICENSE*",
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 @@ -78,6 +78,6 @@
]
},
"typeCoverage": {
"atLeast": 67.65
"atLeast": 69.54
}
}
2 changes: 1 addition & 1 deletion packages/captp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@
]
},
"typeCoverage": {
"atLeast": 86.52
"atLeast": 85.2
}
}
4 changes: 3 additions & 1 deletion packages/captp/src/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ export const makeCapTP = (

const IS_REMOTE_PUMPKIN = harden({});
/**
* @type {import('@endo/marshal').ConvertSlotToVal<import('./types.js').CapTPSlot>}
* @type {import('@endo/marshal').ConvertValToSlot<import('./types.js').CapTPSlot>}
*/
// @ts-expect-error intentional hack
const assertValIsLocal = val => {
const slot = valToSlot.get(val);
if (slot && slot[1] === '-') {
Expand Down Expand Up @@ -499,6 +500,7 @@ export const makeCapTP = (
}

// If we imported this slot, mark it as one our peer exported.
// @ts-expect-error map lacks value type
return slotToImported.get(recvSlot.add(slot));
}

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 @@ -55,7 +55,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"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 @@ -40,7 +40,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"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 @@ -45,7 +45,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"LICENSE*",
Expand Down
4 changes: 2 additions & 2 deletions packages/compartment-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"LICENSE*",
Expand Down Expand Up @@ -97,6 +97,6 @@
"timeout": "2m"
},
"typeCoverage": {
"atLeast": 85.78
"atLeast": 86.14
}
}
2 changes: 1 addition & 1 deletion packages/daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"LICENSE*",
Expand Down
4 changes: 2 additions & 2 deletions packages/env-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"*.js",
Expand Down Expand Up @@ -83,6 +83,6 @@
"timeout": "2m"
},
"typeCoverage": {
"atLeast": 72.22
"atLeast": 74.44
}
}
4 changes: 2 additions & 2 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"lint-check": "exit 0"
},
"dependencies": {
"@typescript-eslint/utils": "^6.6.0",
"@typescript-eslint/utils": "^6.18.1",
"requireindex": "~1.1.0",
"tsutils": "~3.21.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"devDependencies": {
"eslint": "^8.46.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/eventual-send/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
"timeout": "2m"
},
"typeCoverage": {
"atLeast": 77.79
"atLeast": 77.81
}
}
4 changes: 2 additions & 2 deletions packages/exo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"*.js",
Expand All @@ -73,6 +73,6 @@
"timeout": "2m"
},
"typeCoverage": {
"atLeast": 91.45
"atLeast": 97.05
}
}
2 changes: 2 additions & 0 deletions packages/far/test/test-marshal-far-obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const testRecord = ({
}),
);

/** @type {import('@endo/pass-style').PassStyled<'remotable'>} */
const goodRemotableProto = testRecord();

// @ts-ignore We're testing bad things anyway
Expand Down Expand Up @@ -129,6 +130,7 @@ test('passStyleOf validation of remotables', t => {
t.throws(() => passStyleOf(badRemotableProto3), NON_METHOD);
t.throws(() => passStyleOf(badRemotableProto4), NON_METHOD);

// @ts-expect-error UNTIL https://github.com/microsoft/TypeScript/issues/38385
t.is(passStyleOf(sub(goodRemotableProto)), 'remotable');

t.throws(() => passStyleOf(sub(badRemotableProto1)), EXPECTED_PASS_STYLE);
Expand Down
2 changes: 1 addition & 1 deletion packages/lp32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
"typescript": "~5.3.3"
},
"files": [
"LICENSE*",
Expand Down
2 changes: 1 addition & 1 deletion packages/marshal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@
"timeout": "2m"
},
"typeCoverage": {
"atLeast": 89.31
"atLeast": 86.69
}
}
4 changes: 4 additions & 0 deletions packages/marshal/src/deeplyFulfilled.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@ export const deeplyFulfilled = async val => {
const passStyle = passStyleOf(val);
switch (passStyle) {
case 'copyRecord': {
// @ts-expect-error FIXME narrowed
const names = ownKeys(val);
const valPs = names.map(name => deeplyFulfilled(val[name]));
return E.when(Promise.all(valPs), vals =>
harden(fromEntries(vals.map((c, i) => [names[i], c]))),
);
}
case 'copyArray': {
// @ts-expect-error FIXME narrowed
const valPs = val.map(p => deeplyFulfilled(p));
return E.when(Promise.all(valPs), vals => harden(vals));
}
case 'tagged': {
// @ts-expect-error FIXME narrowed
const tag = getTag(val);
// @ts-expect-error FIXME narrowed
return E.when(deeplyFulfilled(val.payload), payload =>
makeTagged(tag, payload),
);
Expand Down
12 changes: 6 additions & 6 deletions packages/marshal/src/encodePassable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
passableSymbolForName,
} from '@endo/pass-style';

/** @typedef {import('@endo/pass-style').PassStyle} PassStyle */
/** @typedef {import('@endo/pass-style').Passable} Passable */
/** @typedef {import('@endo/pass-style').RemotableObject} Remotable */
/** @typedef {import('@endo/pass-style/src/types.js').PassStyle} PassStyle */
/** @typedef {import('@endo/pass-style/src/types.js').Passable} Passable */
/** @typedef {import('@endo/pass-style/src/types.js').RemotableObject} Remotable */
/**
* @template {Passable} [T=Passable]
* @typedef {import('@endo/pass-style').CopyRecord<T>} CopyRecord
* @typedef {import('@endo/pass-style/src/types.js').CopyRecord<T>} CopyRecord
*/
/** @typedef {import('./types.js').RankCover} RankCover */

Expand All @@ -27,7 +27,7 @@ const { ownKeys } = Reflect;
* string-named own properties. `recordNames` returns those name *reverse*
* sorted, because that's how records are compared, encoded, and sorted.
*
* @template T
* @template {Passable} T
* @param {CopyRecord<T>} record
* @returns {string[]}
*/
Expand All @@ -44,7 +44,7 @@ harden(recordNames);
* Assuming that `record` is a CopyRecord and `names` is `recordNames(record)`,
* return the corresponding array of property values.
*
* @template T
* @template {Passable} T
* @param {CopyRecord<T>} record
* @param {string[]} names
* @returns {T[]}
Expand Down
10 changes: 5 additions & 5 deletions packages/marshal/src/encodeToCapData.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {

/** @typedef {import('@endo/pass-style').Passable} Passable */
/** @typedef {import('./types.js').Encoding} Encoding */
/** @typedef {import('@endo/pass-style').Remotable} Remotable */
/** @typedef {import('@endo/pass-style').RemotableObject} RemotableObject */
/** @typedef {import('./types.js').EncodingUnion} EncodingUnion */

const { ownKeys } = Reflect;
Expand Down Expand Up @@ -62,7 +62,7 @@ const qclassMatches = (encoded, qclass) =>
/**
* @typedef {object} EncodeToCapDataOptions
* @property {(
* remotable: Remotable,
* remotable: RemotableObject,
* encodeRecur: (p: Passable) => Encoding
* ) => Encoding} [encodeRemotableToCapData]
* @property {(
Expand Down Expand Up @@ -117,7 +117,7 @@ export const makeEncodeToCapData = (encodeOptions = {}) => {
* Readers must not care about this order anyway. We impose this requirement
* mainly to reduce non-determinism exposed outside a vat.
*
* @param {Passable} passable
* @param {any} passable
* @returns {Encoding} except that `encodeToCapData` does not generally
* `harden` this result before returning. Rather, `encodeToCapData` is not
* directly exposed.
Expand Down Expand Up @@ -269,11 +269,11 @@ harden(makeEncodeToCapData);
* @property {(
* encodedRemotable: Encoding,
* decodeRecur: (e: Encoding) => Passable
* ) => (Promise|Remotable)} [decodeRemotableFromCapData]
* ) => (Promise|RemotableObject)} [decodeRemotableFromCapData]
* @property {(
* encodedPromise: Encoding,
* decodeRecur: (e: Encoding) => Passable
* ) => (Promise|Remotable)} [decodePromiseFromCapData]
* ) => (Promise|RemotableObject)} [decodePromiseFromCapData]
* @property {(
* encodedError: Encoding,
* decodeRecur: (e: Encoding) => Passable
Expand Down
8 changes: 4 additions & 4 deletions packages/marshal/src/encodeToSmallcaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@endo/pass-style';

/** @typedef {import('@endo/pass-style').Passable} Passable */
/** @typedef {import('@endo/pass-style').Remotable} Remotable */
/** @typedef {import('@endo/pass-style').RemotableObject} RemotableObject */
// @typedef {import('./types.js').SmallcapsEncoding} SmallcapsEncoding */
// @typedef {import('./types.js').SmallcapsEncodingUnion} SmallcapsEncodingUnion */
/** @typedef {any} SmallcapsEncoding */
Expand Down Expand Up @@ -89,7 +89,7 @@ const startsSpecial = encodedStr => {
/**
* @typedef {object} EncodeToSmallcapsOptions
* @property {(
* remotable: Remotable,
* remotable: RemotableObject,
* encodeRecur: (p: Passable) => SmallcapsEncoding
* ) => SmallcapsEncoding} [encodeRemotableToSmallcaps]
* @property {(
Expand Down Expand Up @@ -161,7 +161,7 @@ export const makeEncodeToSmallcaps = (encodeOptions = {}) => {
* Readers must not care about this order anyway. We impose this requirement
* mainly to reduce non-determinism exposed outside a vat.
*
* @param {Passable} passable
* @param {any} passable
* @returns {SmallcapsEncoding} except that `encodeToSmallcaps` does not generally
* `harden` this result before returning. Rather, `encodeToSmallcaps` is not
* directly exposed.
Expand Down Expand Up @@ -299,7 +299,7 @@ harden(makeEncodeToSmallcaps);
* @property {(
* encodedRemotable: SmallcapsEncoding,
* decodeRecur: (e :SmallcapsEncoding) => Passable
* ) => Remotable} [decodeRemotableFromSmallcaps]
* ) => RemotableObject} [decodeRemotableFromSmallcaps]
* @property {(
* encodedPromise: SmallcapsEncoding,
* decodeRecur: (e :SmallcapsEncoding) => Passable
Expand Down
Loading
Loading