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

Add global crypto to @astrojs/webapi #6981

Merged
merged 6 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-months-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/webapi': minor
---

Add polyfill for `crypto`
2 changes: 1 addition & 1 deletion packages/telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/dlv": "^1.1.2",
"@types/node": "^14.18.21",
"@types/node": "^18.7.21",
"@types/which-pm-runs": "^1.0.0",
"astro-scripts": "workspace:*",
"chai": "^4.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/webapi/mod.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// organize-imports-ignore
export { pathToPosix } from './lib/utils';
export { alert, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, } from './mod.js';
export { alert, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, crypto, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, } from './mod.js';
export declare const polyfill: {
(target: any, options?: PolyfillOptions): any;
internals(target: any, name: string): any;
Expand Down
2 changes: 1 addition & 1 deletion packages/webapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@rollup/plugin-typescript": "^8.3.2",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.1",
"@types/node": "^14.18.21",
"@types/node": "^18.7.21",
"@ungap/structured-clone": "^0.3.4",
"chai": "^4.3.6",
"event-target-shim": "^6.0.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/webapi/src/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
clearTimeout,
Comment,
CountQueuingStrategy,
crypto,
CSSStyleSheet,
CustomElementRegistry,
CustomEvent,
Expand Down Expand Up @@ -87,6 +88,7 @@ export {
clearTimeout,
Comment,
CountQueuingStrategy,
crypto,
CSSStyleSheet,
CustomElementRegistry,
CustomEvent,
Expand Down Expand Up @@ -211,6 +213,7 @@ export const polyfill = (target: any, options?: PolyfillOptions) => {
cancelAnimationFrame,
cancelIdleCallback,
clearTimeout,
crypto,
fetch,
requestAnimationFrame,
requestIdleCallback,
Expand Down
2 changes: 2 additions & 0 deletions packages/webapi/src/ponyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
WritableStreamDefaultController,
WritableStreamDefaultWriter,
} from 'node:stream/web' // Remove when Node 16 is dropped for Node 18.
import { webcrypto as crypto } from 'node:crypto' // Remove when Node 18 is dropped for Node 20
import { fetch, File, FormData, Headers, Request, Response } from 'undici' // Remove when Node 16 is dropped for Node 18.
import { URLPattern } from 'urlpattern-polyfill'
import {
Expand Down Expand Up @@ -133,6 +134,7 @@ export {
cancelAnimationFrame,
cancelIdleCallback,
clearTimeout,
crypto,
fetch,
requestAnimationFrame,
requestIdleCallback,
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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