Skip to content

Commit

Permalink
feat: @W-11668812 explicitly import/export types (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton authored Aug 30, 2022
1 parent 4b6c330 commit 7192482
Show file tree
Hide file tree
Showing 22 changed files with 375 additions and 328 deletions.
13 changes: 9 additions & 4 deletions examples/rollup.config.js → examples/.rolluprc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { nodeResolve } from '@rollup/plugin-node-resolve';
'use strict';

const { nodeResolve } = require('@rollup/plugin-node-resolve');

function config(dir) {
return {
Expand All @@ -8,11 +9,15 @@ function config(dir) {
file: `${dir}/bundle.js`,
format: 'cjs',
},
plugins: [nodeResolve()],
plugins: [
nodeResolve({
preferBuiltins: true,
})
],
};
}

export default [
module.exports = [
config('custom-elements'),
config('custom-events'),
config('errors'),
Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"clean": "rimraf */bundle.js",
"build": "rollup -c"
"build": "rollup --config .rolluprc.cjs"
},
"dependencies": {
"@locker/near-membrane-dom": "0.11.1"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"description": "JavaScript Near Membrane Library to create a sandboxed environment",
"module": "dist/index.js",
"types": "types/index.js",
"typings": "types/index.js",
"scripts": {
"clean": "lerna run clean --stream",
"build": "lerna run build --stream",
Expand Down
2 changes: 1 addition & 1 deletion packages/near-membrane-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"main": "dist/index.cjs.js",
"module": "dist/index.js",
"sideEffects": false,
"types": "types/index.d.ts",
"typings": "types/index.d.ts",
"scripts": {
"clean": "rimraf dist types",
"build": "tsc --project tsconfig.types.json && rollup --config .rolluprc.cjs",
Expand Down
3 changes: 1 addition & 2 deletions packages/near-membrane-base/src/connector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createMembraneMarshall } from './membrane';

export type Connector = ReturnType<typeof createMembraneMarshall>;
import type { Connector } from './types';

const TypeErrorCtor = TypeError;

Expand Down
21 changes: 4 additions & 17 deletions packages/near-membrane-base/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
import {
import type {
CallableDefineProperties,
CallableEvaluate,
CallableGetPropertyValuePointer,
CallableInstallLazyPropertyDescriptors,
CallableLinkPointers,
CallableSetPrototypeOf,
DistortionCallback,
GetSelectedTarget,
GetTransferableValue,
HooksCallback,
Pointer,
ProxyTarget,
} from './membrane';
import { Connector } from './connector';
import { Instrumentation } from './instrumentation';
import { PropertyKeys } from './types';

export interface VirtualEnvironmentOptions {
// Blue connector factory.
blueConnector: Connector;
// Optional distortion callback to tame functionalities observed through the membrane.
distortionCallback?: DistortionCallback;
// Red connector factory.
redConnector: Connector;
// Instrumentation library object.
instrumentation?: Instrumentation;
}
PropertyKeys,
VirtualEnvironmentOptions,
} from './types';

const LOCKER_NEAR_MEMBRANE_UNDEFINED_VALUE_SYMBOL = Symbol.for(
'@@lockerNearMembraneUndefinedValue'
Expand Down
1 change: 0 additions & 1 deletion packages/near-membrane-base/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './connector';
export * from './environment';
export * from './instrumentation';
export * from './intrinsics';
export * from './membrane';
export * from './types';
Expand Down
12 changes: 0 additions & 12 deletions packages/near-membrane-base/src/instrumentation.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/near-membrane-base/src/intrinsics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toSafeArray } from './utils';
import { VirtualEnvironment } from './environment';
import { PropertyKeys } from './types';
import type { PropertyKeys } from './types';

const { assign: ObjectAssign } = Object;
const { ownKeys: ReflectOwnKeys } = Reflect;
Expand Down Expand Up @@ -167,7 +167,7 @@ export function linkIntrinsics(env: VirtualEnvironment, globalObject: typeof glo
// Remap intrinsics that are realm agnostic.
for (let i = 0, { length } = ReflectiveIntrinsicObjectNames; i < length; i += 1) {
const globalName = ReflectiveIntrinsicObjectNames[i];
const reflectiveValue = globalObject[globalName];
const reflectiveValue = (globalObject as any)[globalName];
if (reflectiveValue) {
// Proxy.prototype is undefined.
if (reflectiveValue.prototype) {
Expand Down
Loading

0 comments on commit 7192482

Please sign in to comment.