Skip to content

Commit

Permalink
fix polyfills package, don't publish polyfills package (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime authored May 2, 2024
1 parent aa49e49 commit 423e1d2
Show file tree
Hide file tree
Showing 28 changed files with 17 additions and 146 deletions.
6 changes: 6 additions & 0 deletions .changeset/afraid-lizards-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@penumbra-zone/polyfills': major
---

- don't publish
- remove polyfills now present in esnext
1 change: 0 additions & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
},
"devDependencies": {
"@penumbra-zone/keys": "workspace:*",
"@penumbra-zone/polyfills": "workspace:*",
"@penumbra-zone/protobuf": "workspace:*",
"@radix-ui/react-icons": "^1.3.0",
"@types/firefox-webext-browser": "^120.0.3",
Expand Down
1 change: 0 additions & 1 deletion apps/extension/src/approve-origin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { localExtStorage } from '@penumbra-zone/storage/chrome/local';
import { OriginApproval, PopupType } from './message/popup';
import { popup } from './popup';
import Map from '@penumbra-zone/polyfills/Map.groupBy';
import { UserChoice } from '@penumbra-zone/types/user-choice';

export const originAlreadyApproved = async (url: string): Promise<boolean> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import {
} from '@penumbra-zone/client/global';
import { isPraxFailureMessageEvent, isPraxPortMessageEvent, PraxMessage } from './message-event';

import '@penumbra-zone/polyfills/Promise.withResolvers';
import { PraxConnection } from '../message/prax';

const request = Promise.withResolvers();
const request = Promise.withResolvers<void>();

// this is just withResolvers, plus a sync-queryable state attribute
const connection = Object.assign(Promise.withResolvers<MessagePort>(), { state: false });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { UserChoice } from '@penumbra-zone/types/user-choice';
import { SettingsScreen } from '../settings-screen';
import { useStoreShallow } from '../../../../utils/use-store-shallow';
import { allSitesFilteredOutSelector } from '../../../../state/connected-sites';
import Map from '@penumbra-zone/polyfills/Map.groupBy';
import { KnownSitesGroup } from './known-sites-group';

const settingsConnectedSitesSelector = (state: AllSlices) => ({
Expand Down
3 changes: 1 addition & 2 deletions apps/extension/src/routes/popup/settings/settings-rpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { useState } from 'react';
import { ShareGradientIcon } from '../../../icons/share-gradient';
import { GrpcEndpointForm } from '../../../shared/components/grpc-endpoint-form';
import { SettingsScreen } from './settings-screen';
import '@penumbra-zone/polyfills/Promise.withResolvers';

export const SettingsRPC = () => {
const [countdownTime, setCountdownTime] = useState<number>();
const submitButtonLabel =
Number(countdownTime) > 0 ? `Saved! Restarting in ${countdownTime}...` : 'Save';

const countdown = (seconds: number) => {
const { promise, resolve } = Promise.withResolvers();
const { promise, resolve } = Promise.withResolvers<void>();
setCountdownTime(seconds);
setInterval(() => {
if (!seconds) resolve(undefined);
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const fixEmptyGrpcEndpointAfterOnboarding = async () => {
* requests against it.
*/
const waitUntilGrpcEndpointExists = async () => {
const grpcEndpointPromise = Promise.withResolvers();
const grpcEndpointPromise = Promise.withResolvers<void>();
const grpcEndpoint = await localExtStorage.get('grpcEndpoint');

if (grpcEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PromiseWithResolvers } from '@penumbra-zone/polyfills/Promise.withResolvers';
import { Button } from '@penumbra-zone/ui/components/ui/button';
import {
Dialog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AllSlices } from '../../../state';
import { useStoreShallow } from '../../../utils/use-store-shallow';
import { ServicesMessage } from '@penumbra-zone/types/services';
import debounce from 'lodash/debounce';
import { PromiseWithResolvers } from '@penumbra-zone/polyfills/Promise.withResolvers';
import { useRpcEndpoints } from '../../../hooks/registry';

const randomSort = () => (Math.random() >= 0.5 ? 1 : -1);
Expand Down Expand Up @@ -105,7 +104,7 @@ export const useGrpcEndpointForm = () => {

// If the chain id has changed, our cache is invalid
if (chainIdChanged) {
const promiseWithResolvers = Promise.withResolvers();
const promiseWithResolvers = Promise.withResolvers<void>();
setConfirmChangedChainIdPromise(promiseWithResolvers);

try {
Expand Down
1 change: 0 additions & 1 deletion apps/minifront/array-from-async.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/eslint-config-custom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
'@typescript-eslint/no-invalid-void-type': 'off',
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
// Catches untyped let declarations
Expand Down
1 change: 0 additions & 1 deletion packages/polyfills/array-from-async.d.ts

This file was deleted.

18 changes: 1 addition & 17 deletions packages/polyfills/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
{
"name": "@penumbra-zone/polyfills",
"version": "3.0.0",
"private": true,
"license": "(MIT OR Apache-2.0)",
"type": "module",
"scripts": {
"build": "tsc && vite build",
"clean": "rm -rfv dist",
"lint": "eslint \"**/*.ts*\"",
"test": "vitest run"
},
"exports": {
"./ReadableStream[Symbol.asyncIterator]": "./src/ReadableStream_Symbol.asyncIterator_.ts",
"./*": "./src/*.ts"
},
"publishConfig": {
"files": [
"dist"
],
"exports": {
"./ReadableStream[Symbol.asyncIterator]": {
"import": "./dist/ReadableStream_Symbol.asyncIterator_.js",
"types": "./src/ReadableStream_Symbol.asyncIterator_.d.ts"
},
"./*": {
"import": "./dist/*.js",
"types": "./dist/*.d.ts"
}
}
},
"dependencies": {
"array-from-async": "^3.0.0"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/polyfills/src/Array.fromAsync.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./array-from-async.d.ts" />
import fromAsync from 'array-from-async';

type FromAsync = <T, U = T>(
Expand Down
11 changes: 0 additions & 11 deletions packages/polyfills/src/Map.groupBy.ts

This file was deleted.

44 changes: 0 additions & 44 deletions packages/polyfills/src/Promise.withResolvers.test.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/polyfills/src/Promise.withResolvers.ts

This file was deleted.

File renamed without changes.
27 changes: 0 additions & 27 deletions packages/polyfills/vite.config.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@penumbra-zone/constants": "workspace:*",
"@penumbra-zone/crypto-web": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
"@penumbra-zone/polyfills": "workspace:*",
"@penumbra-zone/types": "workspace:*",
"@penumbra-zone/wasm": "workspace:*",
"exponential-backoff": "^3.1.1"
Expand Down
3 changes: 1 addition & 2 deletions packages/services-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0",
"@penumbra-zone/polyfills": "workspace:*"
"@bufbuild/protobuf": "^1.9.0"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
Expand Down
1 change: 0 additions & 1 deletion packages/services-context/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { syncLastBlockWithLocal } from '@penumbra-zone/storage/chrome/syncer';
import { ViewServer } from '@penumbra-zone/wasm/view-server';
import { ServicesInterface, ServicesMessage, WalletServices } from '@penumbra-zone/types/services';
import type { JsonValue } from '@bufbuild/protobuf';
import '@penumbra-zone/polyfills/Promise.withResolvers';
import {
FullViewingKey,
WalletId,
Expand Down
1 change: 0 additions & 1 deletion packages/services/array-from-async.d.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/services/src/view-service/util/build-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import { PartialMessage } from '@bufbuild/protobuf';
import { ConnectError } from '@connectrpc/connect';

import '@penumbra-zone/polyfills/Promise.withResolvers';
import { FullViewingKey } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/keys/v1/keys_pb';

export const optimisticBuild = async function* (
Expand Down Expand Up @@ -56,7 +55,7 @@ export const optimisticBuild = async function* (

const progressStream = async function* <T>(tasks: PromiseLike<T>[], cancel: PromiseLike<never>) {
// deliberately not a 'map' - tasks and promises have no direct relationship.
const tasksRemaining = Array.from(tasks, () => Promise.withResolvers());
const tasksRemaining = Array.from(tasks, () => Promise.withResolvers<void>());

// tasksRemaining will be consumed in order, as tasks complete in any order.
tasks.forEach(task => void task.then(() => tasksRemaining.shift()?.resolve()));
Expand Down
1 change: 0 additions & 1 deletion packages/transport-dom/array-from-async.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/transport-dom/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {

import '@penumbra-zone/polyfills/ReadableStream[Symbol.asyncIterator]';
import ReadableStream from '@penumbra-zone/polyfills/ReadableStream.from';
import '@penumbra-zone/polyfills/Promise.withResolvers';

const forceTransportOptions = {
httpClient: null as never,
Expand Down
2 changes: 1 addition & 1 deletion packages/tsconfig/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"target": "ES2022",
"target": "ESNext",
"module": "ES2022"
},
"exclude": ["node_modules"]
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 423e1d2

Please sign in to comment.