Add global crypto to @astrojs/webapi (#6981)
* add crypto to be polyfilled * chore: changeset * chore: update deps for node types --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Princesseuh <princssdev@gmail.com>
This commit is contained in:
parent
52af9ad188
commit
bf63f615fc
7 changed files with 17 additions and 7 deletions
5
.changeset/fifty-months-mix.md
Normal file
5
.changeset/fifty-months-mix.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/webapi': minor
|
||||
---
|
||||
|
||||
Add polyfill for `crypto`
|
|
@ -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",
|
||||
|
|
2
packages/webapi/mod.d.ts
vendored
2
packages/webapi/mod.d.ts
vendored
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
clearTimeout,
|
||||
Comment,
|
||||
CountQueuingStrategy,
|
||||
crypto,
|
||||
CSSStyleSheet,
|
||||
CustomElementRegistry,
|
||||
CustomEvent,
|
||||
|
@ -87,6 +88,7 @@ export {
|
|||
clearTimeout,
|
||||
Comment,
|
||||
CountQueuingStrategy,
|
||||
crypto,
|
||||
CSSStyleSheet,
|
||||
CustomElementRegistry,
|
||||
CustomEvent,
|
||||
|
@ -211,6 +213,7 @@ export const polyfill = (target: any, options?: PolyfillOptions) => {
|
|||
cancelAnimationFrame,
|
||||
cancelIdleCallback,
|
||||
clearTimeout,
|
||||
crypto,
|
||||
fetch,
|
||||
requestAnimationFrame,
|
||||
requestIdleCallback,
|
||||
|
|
|
@ -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 {
|
||||
|
@ -133,6 +134,7 @@ export {
|
|||
cancelAnimationFrame,
|
||||
cancelIdleCallback,
|
||||
clearTimeout,
|
||||
crypto,
|
||||
fetch,
|
||||
requestAnimationFrame,
|
||||
requestIdleCallback,
|
||||
|
|
|
@ -5201,8 +5201,8 @@ importers:
|
|||
specifier: ^1.1.2
|
||||
version: 1.1.2
|
||||
'@types/node':
|
||||
specifier: ^14.18.21
|
||||
version: 14.18.21
|
||||
specifier: ^18.7.21
|
||||
version: 18.16.3
|
||||
'@types/which-pm-runs':
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
|
@ -5241,8 +5241,8 @@ importers:
|
|||
specifier: ^9.1.1
|
||||
version: 9.1.1
|
||||
'@types/node':
|
||||
specifier: ^14.18.21
|
||||
version: 14.18.21
|
||||
specifier: ^18.7.21
|
||||
version: 18.16.3
|
||||
'@ungap/structured-clone':
|
||||
specifier: ^0.3.4
|
||||
version: 0.3.4
|
||||
|
|
Loading…
Reference in a new issue