diff --git a/__tests__/new.ts b/__tests__/new.ts index 886f2e49f158..e2ff220c5d6b 100644 --- a/__tests__/new.ts +++ b/__tests__/new.ts @@ -1,5 +1,5 @@ -import { Temporal } from '@js-temporal/polyfill'; import React, { createContext, useContext } from 'react'; +import { Temporal } from 'temporal-polyfill'; import { Endpoint, diff --git a/docs/rest/api/schema.md b/docs/rest/api/schema.md index dbbebc8f9812..c0fcade20249 100644 --- a/docs/rest/api/schema.md +++ b/docs/rest/api/schema.md @@ -46,7 +46,7 @@ We have two nested [entity](./Entity.md) types within our `article`: `users` and ```typescript import { schema, Entity } from '@data-client/endpoint'; -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; class User extends Entity { id = ''; @@ -79,7 +79,7 @@ class Article extends Entity { ```javascript import { schema, Entity } from '@data-client/endpoint'; -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; class User extends Entity { } diff --git a/examples/github-app/package.json b/examples/github-app/package.json index 4f9981973580..198c5dc1a103 100644 --- a/examples/github-app/package.json +++ b/examples/github-app/package.json @@ -58,7 +58,7 @@ "@data-client/img": "0.15.0", "@data-client/react": "0.15.7", "@data-client/rest": "0.15.7", - "@js-temporal/polyfill": "^0.5.1", + "temporal-polyfill": "^0.3.0", "antd": "6.3.3", "core-js": "^3.48.0", "history": "^5.3.0", diff --git a/examples/github-app/src/components/human.ts b/examples/github-app/src/components/human.ts index 961ade3d419f..44f24d3d0460 100644 --- a/examples/github-app/src/components/human.ts +++ b/examples/github-app/src/components/human.ts @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; export function humanTime(date: Temporal.Instant, language: string) { const REL = new Intl.RelativeTimeFormat(language, { diff --git a/examples/github-app/src/pages/IssueDetail/CommentInline.tsx b/examples/github-app/src/pages/IssueDetail/CommentInline.tsx index 8b46c088fdc7..2fe8492d4e4b 100644 --- a/examples/github-app/src/pages/IssueDetail/CommentInline.tsx +++ b/examples/github-app/src/pages/IssueDetail/CommentInline.tsx @@ -2,7 +2,6 @@ import { useNavigator } from '@anansi/core'; import { Link, useRoutes } from '@anansi/router'; import { EllipsisOutlined } from '@ant-design/icons'; import { useCache, useController } from '@data-client/react'; -import { Intl } from '@js-temporal/polyfill'; import { css } from '@linaria/core'; import { Card, Avatar, Button, Tag, Popover } from 'antd'; import React, { memo, useCallback, useState } from 'react'; @@ -10,6 +9,7 @@ import Markdown from 'react-markdown'; import rehypeHighlight from 'rehype-highlight'; import remarkGfm from 'remark-gfm'; import remarkRemoveComments from 'remark-remove-comments'; +import { Intl } from 'temporal-polyfill'; import FlexRow from '@/components/FlexRow'; import { CommentResource, Comment } from '@/resources/Comment'; diff --git a/examples/github-app/src/pages/ProfileDetail/UserEvents.tsx b/examples/github-app/src/pages/ProfileDetail/UserEvents.tsx index 5c9f03801a2d..5f3d6d1add85 100644 --- a/examples/github-app/src/pages/ProfileDetail/UserEvents.tsx +++ b/examples/github-app/src/pages/ProfileDetail/UserEvents.tsx @@ -2,10 +2,10 @@ import { useNavigator } from '@anansi/core'; import { Link } from '@anansi/router'; import { BranchesOutlined, PullRequestOutlined } from '@ant-design/icons'; import { useSuspense } from '@data-client/react'; -import { Intl } from '@js-temporal/polyfill'; import { Timeline, Typography, Divider } from 'antd'; import { groupBy } from 'lodash'; import { useMemo } from 'react'; +import { Intl } from 'temporal-polyfill'; import { EventResource, diff --git a/examples/github-app/src/pages/ProfileDetail/index.tsx b/examples/github-app/src/pages/ProfileDetail/index.tsx index e21cf279d6a6..31646cc36278 100644 --- a/examples/github-app/src/pages/ProfileDetail/index.tsx +++ b/examples/github-app/src/pages/ProfileDetail/index.tsx @@ -1,8 +1,8 @@ import { useNavigator } from '@anansi/core'; import { useSuspense } from '@data-client/react'; -import { Intl } from '@js-temporal/polyfill'; import { Card, Layout } from 'antd'; import Markdown from 'react-markdown'; +import { Intl } from 'temporal-polyfill'; import { UserResource } from '@/resources/User'; diff --git a/examples/github-app/src/resources/Comment.ts b/examples/github-app/src/resources/Comment.ts index 2247b39979ab..fa56ded4e348 100644 --- a/examples/github-app/src/resources/Comment.ts +++ b/examples/github-app/src/resources/Comment.ts @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { GithubEntity, githubResource } from './Base'; import { User } from './User'; diff --git a/examples/github-app/src/resources/Event.tsx b/examples/github-app/src/resources/Event.tsx index efc6ca2c5dd5..1ed58f4a867b 100644 --- a/examples/github-app/src/resources/Event.tsx +++ b/examples/github-app/src/resources/Event.tsx @@ -7,8 +7,8 @@ import { ForkOutlined, } from '@ant-design/icons'; import { schema } from '@data-client/rest'; -import { Temporal } from '@js-temporal/polyfill'; import type { JSX } from 'react'; +import { Temporal } from 'temporal-polyfill'; import { githubResource, GithubEntity } from './Base'; import { Issue } from './Issue'; diff --git a/examples/github-app/src/resources/Issue.tsx b/examples/github-app/src/resources/Issue.tsx index a00e3da16b9d..0e2b98a453a2 100644 --- a/examples/github-app/src/resources/Issue.tsx +++ b/examples/github-app/src/resources/Issue.tsx @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { GithubEntity, githubResource } from './Base'; import { Label } from './Label'; diff --git a/examples/github-app/src/resources/Pull.ts b/examples/github-app/src/resources/Pull.ts index 146990ed92f4..cb6995621552 100644 --- a/examples/github-app/src/resources/Pull.ts +++ b/examples/github-app/src/resources/Pull.ts @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { GithubEntity, githubResource } from './Base'; import { Label } from './Label'; diff --git a/examples/github-app/src/resources/Reaction.tsx b/examples/github-app/src/resources/Reaction.tsx index 72b73ca51b44..a9dd0e655e69 100644 --- a/examples/github-app/src/resources/Reaction.tsx +++ b/examples/github-app/src/resources/Reaction.tsx @@ -1,5 +1,5 @@ import { HeartOutlined } from '@ant-design/icons'; -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { githubResource, GithubEntity } from './Base'; import PreviewEndpoint from './PreviewEndpoint'; diff --git a/examples/github-app/src/resources/Repository.tsx b/examples/github-app/src/resources/Repository.tsx index 6129efd5a7d6..b089693de019 100644 --- a/examples/github-app/src/resources/Repository.tsx +++ b/examples/github-app/src/resources/Repository.tsx @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { GithubEntity, githubResource, GithubGqlEndpoint } from './Base'; diff --git a/examples/github-app/src/resources/Review.ts b/examples/github-app/src/resources/Review.ts index 477c07a2a076..8c882c325c44 100644 --- a/examples/github-app/src/resources/Review.ts +++ b/examples/github-app/src/resources/Review.ts @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { GithubEntity } from './Base'; diff --git a/examples/github-app/src/resources/User.ts b/examples/github-app/src/resources/User.ts index f4528dceb74e..c0fde1e2e2a8 100644 --- a/examples/github-app/src/resources/User.ts +++ b/examples/github-app/src/resources/User.ts @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { githubResource, GithubEndpoint, GithubEntity } from './Base'; diff --git a/package.json b/package.json index a4c789f705c9..5a4500b6a5fe 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "@data-client/react": "workspace:*", "@data-client/rest": "workspace:*", "@data-client/test": "workspace:*", - "@js-temporal/polyfill": "^0.5.0", "@react-navigation/native": "^7.0.0", "@react-navigation/native-stack": "^7.0.0", "@testing-library/dom": "^10.4.0", @@ -103,6 +102,7 @@ "react-test-renderer": "19.2.3", "rimraf": "^6.0.0", "rollup": "4.59.0", + "temporal-polyfill": "^0.3.0", "typescript": "6.0.2", "whatwg-fetch": "3.0.0" }, diff --git a/packages/endpoint/package.json b/packages/endpoint/package.json index 7666b3bd9809..0613b4575552 100644 --- a/packages/endpoint/package.json +++ b/packages/endpoint/package.json @@ -139,11 +139,11 @@ "@anansi/browserslist-config": "^1.4.2", "@data-client/core": "workspace:*", "@data-client/normalizr": "workspace:*", - "@js-temporal/polyfill": "^0.5.0", "@types/jest": "30.0.0", "@types/node": "^24.0.0", "immutable": "5.1.5", "nock": "13.3.1", - "rollup-plugins": "workspace:*" + "rollup-plugins": "workspace:*", + "temporal-polyfill": "^0.3.0" } } diff --git a/packages/endpoint/src/__tests__/validateRequired.test.ts b/packages/endpoint/src/__tests__/validateRequired.test.ts index 89a0d4733805..8fe42332ba99 100644 --- a/packages/endpoint/src/__tests__/validateRequired.test.ts +++ b/packages/endpoint/src/__tests__/validateRequired.test.ts @@ -1,7 +1,7 @@ // eslint-env jest import { jest, describe, beforeAll, afterAll, it, expect } from '@jest/globals'; -import { Temporal } from '@js-temporal/polyfill'; import { IDEntity } from '__tests__/new'; +import { Temporal } from 'temporal-polyfill'; import SimpleMemoCache from '../schemas/__tests__/denormalize'; import Entity from '../schemas/Entity'; diff --git a/packages/endpoint/src/schemas/__tests__/Entity.test.ts b/packages/endpoint/src/schemas/__tests__/Entity.test.ts index 5e245be2847d..15322175199f 100644 --- a/packages/endpoint/src/schemas/__tests__/Entity.test.ts +++ b/packages/endpoint/src/schemas/__tests__/Entity.test.ts @@ -1,8 +1,8 @@ import { normalize, INVALID } from '@data-client/normalizr'; import { denormalize as plainDenormalize } from '@data-client/normalizr'; import { denormalize as immDenormalize } from '@data-client/normalizr/imm'; -import { Temporal } from '@js-temporal/polyfill'; import { IDEntity } from '__tests__/new'; +import { Temporal } from 'temporal-polyfill'; import { SimpleMemoCache, fromJSEntities } from './denormalize'; import { AbstractInstanceType } from '../../'; diff --git a/packages/endpoint/src/schemas/__tests__/EntityMixin.test.ts b/packages/endpoint/src/schemas/__tests__/EntityMixin.test.ts index 1636ac9a59a9..fc7b67448b35 100644 --- a/packages/endpoint/src/schemas/__tests__/EntityMixin.test.ts +++ b/packages/endpoint/src/schemas/__tests__/EntityMixin.test.ts @@ -2,7 +2,7 @@ import { normalize, INVALID } from '@data-client/normalizr'; import { denormalize as plainDenormalize } from '@data-client/normalizr'; import { denormalize as immDenormalize } from '@data-client/normalizr/imm'; -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { SimpleMemoCache, fromJSEntities } from './denormalize'; import { schema, EntityMixin, Values } from '../..'; diff --git a/packages/endpoint/src/schemas/__tests__/Object.test.js b/packages/endpoint/src/schemas/__tests__/Object.test.js index 2b9faedde149..a3ceac86dda0 100644 --- a/packages/endpoint/src/schemas/__tests__/Object.test.js +++ b/packages/endpoint/src/schemas/__tests__/Object.test.js @@ -4,9 +4,9 @@ import { denormalize as plainDenormalize, } from '@data-client/normalizr'; import { denormalize as immDenormalize } from '@data-client/normalizr/imm'; -import { Temporal } from '@js-temporal/polyfill'; import { IDEntity } from '__tests__/new'; import { fromJS } from 'immutable'; +import { Temporal } from 'temporal-polyfill'; import { fromJSEntities } from './denormalize'; import { schema } from '../../'; diff --git a/packages/endpoint/src/schemas/__tests__/Serializable.test.ts b/packages/endpoint/src/schemas/__tests__/Serializable.test.ts index 6d2c231d6560..711be8cd396b 100644 --- a/packages/endpoint/src/schemas/__tests__/Serializable.test.ts +++ b/packages/endpoint/src/schemas/__tests__/Serializable.test.ts @@ -1,7 +1,7 @@ // eslint-env jest import { normalize } from '@data-client/normalizr'; -import { Temporal } from '@js-temporal/polyfill'; import { IDEntity } from '__tests__/new'; +import { Temporal } from 'temporal-polyfill'; import SimpleMemoCache from './denormalize'; diff --git a/packages/normalizr/README.md b/packages/normalizr/README.md index 757ea41fd79d..f7acaf66b656 100644 --- a/packages/normalizr/README.md +++ b/packages/normalizr/README.md @@ -88,7 +88,7 @@ We have two [nested](https://dataclient.io/rest/guides/relational-data) [entity] ```js import { schema, Entity } from '@data-client/endpoint'; -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; // Define a users schema class User extends Entity {} diff --git a/packages/normalizr/package.json b/packages/normalizr/package.json index 1ecf9219fa72..d343d8d5a60d 100644 --- a/packages/normalizr/package.json +++ b/packages/normalizr/package.json @@ -127,10 +127,10 @@ "devDependencies": { "@anansi/browserslist-config": "^1.4.2", "@data-client/endpoint": "workspace:*", - "@js-temporal/polyfill": "^0.5.0", "@types/jest": "30.0.0", "@types/node": "^24.0.0", "immutable": "5.1.5", - "rollup-plugins": "workspace:*" + "rollup-plugins": "workspace:*", + "temporal-polyfill": "^0.3.0" } } diff --git a/packages/normalizr/src/__tests__/WeakDependencyMap.test.ts b/packages/normalizr/src/__tests__/WeakDependencyMap.test.ts index 3273cd578363..53150894b169 100644 --- a/packages/normalizr/src/__tests__/WeakDependencyMap.test.ts +++ b/packages/normalizr/src/__tests__/WeakDependencyMap.test.ts @@ -1,4 +1,4 @@ -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; import { EntityPath } from '../interface'; import { MemoPolicy } from '../memo/Policy'; diff --git a/packages/react/package.json b/packages/react/package.json index 5faec1f06655..00576fc88d14 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -200,7 +200,6 @@ "@data-client/rest": "workspace:*", "@data-client/test": "workspace:*", "@jest/globals": "^30.0.0", - "@js-temporal/polyfill": "^0.5.0", "@react-navigation/native": "^7.0.0", "@react-navigation/native-stack": "^7.2.0", "@testing-library/dom": "^10.4.0", @@ -220,6 +219,7 @@ "react-native-safe-area-context": "^5.0.0", "react-native-screens": "^4.1.0", "react-test-renderer": "^19.0.0", - "rollup-plugins": "workspace:*" + "rollup-plugins": "workspace:*", + "temporal-polyfill": "^0.3.0" } } diff --git a/packages/react/src/__tests__/useFetch-use.web.tsx b/packages/react/src/__tests__/useFetch-use.web.tsx index 7f5fa4eb515b..04104ca6e0e3 100644 --- a/packages/react/src/__tests__/useFetch-use.web.tsx +++ b/packages/react/src/__tests__/useFetch-use.web.tsx @@ -10,7 +10,6 @@ import { Collection, Values } from '@data-client/endpoint'; import { normalize } from '@data-client/normalizr'; import { DataProvider } from '@data-client/react'; import { jest } from '@jest/globals'; -import { Temporal } from '@js-temporal/polyfill'; import { render } from '@testing-library/react'; import { CoolerArticleResource, @@ -32,6 +31,7 @@ import { createEntityMeta } from '__tests__/utils'; import nock from 'nock'; import { use } from 'react'; import React, { Suspense } from 'react'; +import { Temporal } from 'temporal-polyfill'; // relative imports to avoid circular dependency in tsconfig references import { useController, ControllerContext, StateContext } from '..'; diff --git a/packages/react/src/hooks/__tests__/useSuspense.native.tsx b/packages/react/src/hooks/__tests__/useSuspense.native.tsx index 704a9107d6ff..7631c4ee97df 100644 --- a/packages/react/src/hooks/__tests__/useSuspense.native.tsx +++ b/packages/react/src/hooks/__tests__/useSuspense.native.tsx @@ -15,7 +15,6 @@ import { MockResolver, } from '@data-client/test'; import { jest } from '@jest/globals'; -import { Temporal } from '@js-temporal/polyfill'; import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { render, act, screen } from '@testing-library/react-native'; @@ -38,6 +37,7 @@ import nock from 'nock'; import React, { Suspense } from 'react'; import { Text, View } from 'react-native'; import { InteractionManager } from 'react-native'; +import { Temporal } from 'temporal-polyfill'; // relative imports to avoid circular dependency in tsconfig references import { diff --git a/packages/react/src/hooks/__tests__/useSuspense.web.tsx b/packages/react/src/hooks/__tests__/useSuspense.web.tsx index dbfeb2351c17..f5055de9a367 100644 --- a/packages/react/src/hooks/__tests__/useSuspense.web.tsx +++ b/packages/react/src/hooks/__tests__/useSuspense.web.tsx @@ -16,7 +16,6 @@ import { } from '@data-client/endpoint'; import { normalize } from '@data-client/normalizr'; import { jest } from '@jest/globals'; -import { Temporal } from '@js-temporal/polyfill'; import { render } from '@testing-library/react'; import { CoolerArticleResource, @@ -37,6 +36,7 @@ import { import { createEntityMeta } from '__tests__/utils'; import nock from 'nock'; import React, { Suspense } from 'react'; +import { Temporal } from 'temporal-polyfill'; // relative imports to avoid circular dependency in tsconfig references import { diff --git a/packages/vue/package.json b/packages/vue/package.json index bf492f17e531..3b259beb5f62 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -113,7 +113,6 @@ "@anansi/browserslist-config": "^1.4.2", "@data-client/rest": "workspace:*", "@jest/globals": "^30.0.0", - "@js-temporal/polyfill": "^0.5.0", "@types/jest": "30.0.0", "@types/node": "^24.0.0", "@vue/test-utils": "^2.4.0", @@ -121,6 +120,7 @@ "jest-mock": "^30.0.0", "nock": "13.3.1", "rollup-plugins": "workspace:*", + "temporal-polyfill": "^0.3.0", "vue": "^3.4.0" } } diff --git a/scripts/copywebsitetypes.sh b/scripts/copywebsitetypes.sh index c3744dc2969c..ec58c61dfe77 100755 --- a/scripts/copywebsitetypes.sh +++ b/scripts/copywebsitetypes.sh @@ -14,7 +14,7 @@ cp ./packages/react/nextjs.d.ts ./website/src/components/Playground/editor-types cp ./packages/react/ssr.d.ts ./website/src/components/Playground/editor-types/@data-client/react/ssr.d.ts cp ./packages/react/redux.d.ts ./website/src/components/Playground/editor-types/@data-client/react/redux.d.ts cp ./node_modules/@types/react/index.d.ts ./website/src/components/Playground/editor-types/react.d.ts -cp ./node_modules/@js-temporal/polyfill/index.d.ts ./website/src/components/Playground/editor-types/temporal.d.ts +cp ./node_modules/temporal-spec/index.d.ts ./website/src/components/Playground/editor-types/temporal.d.ts cp ./node_modules/bignumber.js/bignumber.d.ts ./website/src/components/Playground/editor-types/bignumber.d.ts cp ./node_modules/@types/qs/index.d.ts ./website/src/components/Playground/editor-types/qs.d.ts yarn run rollup --config ./scripts/rollup-plugins/uuid-types.rollup.config.js diff --git a/website/blog/2024-01-15-v0.9-release-announcement.md b/website/blog/2024-01-15-v0.9-release-announcement.md index fc059236a3f2..adcf4a838aa2 100644 --- a/website/blog/2024-01-15-v0.9-release-announcement.md +++ b/website/blog/2024-01-15-v0.9-release-announcement.md @@ -286,7 +286,7 @@ class MyEntity extends Entity { Alternatively, use Temporal: ```ts -import { Temporal } from '@js-temporal/polyfill'; +import { Temporal } from 'temporal-polyfill'; class MyEntity extends Entity { createdAt = Temporal.Instant.fromEpochSeconds(0); diff --git a/website/package.json b/website/package.json index 561a0b75b701..ae379f1c95b8 100644 --- a/website/package.json +++ b/website/package.json @@ -44,7 +44,6 @@ "@docusaurus/preset-classic": "^3.0.1", "@docusaurus/theme-live-codeblock": "^3.0.1", "@docusaurus/theme-mermaid": "^3.0.1", - "@js-temporal/polyfill": "^0.5.0", "@mdx-js/react": "^3.1.0", "@monaco-editor/react": "^4.8.0-rc.0", "@number-flow/react": "^0.6.0", @@ -56,6 +55,7 @@ "react-dom": "^19.0.0", "react-json-tree": "0.20.0", "react-live": "^4.0.0", + "temporal-polyfill": "^0.3.0", "typescript": "6.0.2", "uuid": "^13.0.0" }, diff --git a/website/src/components/Playground/PreviewWithScope.tsx b/website/src/components/Playground/PreviewWithScope.tsx index c00f4f8b92b6..2247ddb8f8e7 100644 --- a/website/src/components/Playground/PreviewWithScope.tsx +++ b/website/src/components/Playground/PreviewWithScope.tsx @@ -2,7 +2,6 @@ import * as graphql from '@data-client/graphql'; import * as rhReact from '@data-client/react'; import * as rhReactNext from '@data-client/react/next'; import * as rest from '@data-client/rest'; -import { Temporal, Intl as PolyIntl } from '@js-temporal/polyfill'; import BigNumber from 'bignumber.js'; import { use } from 'react'; import { LiveProvider } from 'react-live'; @@ -11,6 +10,7 @@ import { v4 as uuid } from 'uuid'; import * as designSystem from './DesignSystem'; import Preview from './Preview'; import PreviewWrapper from './PreviewWrapper'; +import { Temporal, Intl, DateTimeFormat } from './temporal'; import transformCode from './transformCode'; import type { PreviewProps } from './types'; import ResetableErrorBoundary from '../ResettableErrorBoundary'; @@ -31,11 +31,6 @@ const mockFetch = (getResponse, name, delay = 150) => { return fetch; }; -const Intl = { - ...globalThis.Intl, - ...PolyIntl, -}; - const scope = { ...rhReact, ...rhReactNext, @@ -49,7 +44,7 @@ const scope = { ResetableErrorBoundary, Temporal, Intl, - DateTimeFormat: PolyIntl.DateTimeFormat, + DateTimeFormat, ...designSystem, }; diff --git a/website/src/components/Playground/editor-types/temporal.d.ts b/website/src/components/Playground/editor-types/temporal.d.ts index ac2d6be085c4..c29e54693f77 100644 --- a/website/src/components/Playground/editor-types/temporal.d.ts +++ b/website/src/components/Playground/editor-types/temporal.d.ts @@ -1,6 +1,10 @@ +/* +NOTE: keep synced with all other definition files +*/ + export namespace Temporal { - export type ComparisonResult = -1 | 0 | 1; - export type RoundingMode = + type ComparisonResult = -1 | 0 | 1; + type RoundingMode = | 'ceil' | 'floor' | 'expand' @@ -15,7 +19,7 @@ export namespace Temporal { * Options for assigning fields using `with()` or entire objects with * `from()`. * */ - export type AssignmentOptions = { + type AssignmentOptions = { /** * How to deal with out-of-range values * @@ -26,7 +30,7 @@ export namespace Temporal { * * The default is `'constrain'`. */ - overflow?: 'constrain' | 'reject'; + overflow?: 'constrain' | 'reject' | undefined; }; /** @@ -34,7 +38,7 @@ export namespace Temporal { * objects with `Duration.from()`, and for arithmetic with * `Duration.prototype.add()` and `Duration.prototype.subtract()`. * */ - export type DurationOptions = { + type DurationOptions = { /** * How to deal with out-of-range values * @@ -45,13 +49,13 @@ export namespace Temporal { * * The default is `'constrain'`. */ - overflow?: 'constrain' | 'balance'; + overflow?: 'constrain' | 'balance' | undefined; }; /** * Options for conversions of `Temporal.PlainDateTime` to `Temporal.Instant` * */ - export type ToInstantOptions = { + type ToInstantOptions = { /** * Controls handling of invalid or ambiguous times caused by time zone * offset changes like Daylight Saving time (DST) transitions. @@ -75,7 +79,7 @@ export namespace Temporal { * The default is `'compatible'`. * * */ - disambiguation?: 'compatible' | 'earlier' | 'later' | 'reject'; + disambiguation?: 'compatible' | 'earlier' | 'later' | 'reject' | undefined; }; type OffsetDisambiguationOptions = { @@ -111,17 +115,15 @@ export namespace Temporal { * be used to choose the correct instant. However, if the offset is used * then the `disambiguation` option will be ignored. */ - offset?: 'use' | 'prefer' | 'ignore' | 'reject'; + offset?: 'use' | 'prefer' | 'ignore' | 'reject' | undefined; }; - export type ZonedDateTimeAssignmentOptions = Partial< - AssignmentOptions & ToInstantOptions & OffsetDisambiguationOptions - >; + type ZonedDateTimeAssignmentOptions = AssignmentOptions & ToInstantOptions & OffsetDisambiguationOptions; /** * Options for arithmetic operations like `add()` and `subtract()` * */ - export type ArithmeticOptions = { + type ArithmeticOptions = { /** * Controls handling of out-of-range arithmetic results. * @@ -130,19 +132,19 @@ export namespace Temporal { * * The default is `'constrain'`. */ - overflow?: 'constrain' | 'reject'; + overflow?: 'constrain' | 'reject' | undefined; }; - export type DateUnit = 'year' | 'month' | 'week' | 'day'; - export type TimeUnit = 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'; - export type DateTimeUnit = DateUnit | TimeUnit; + type DateUnit = 'year' | 'month' | 'week' | 'day'; + type TimeUnit = 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'; + type DateTimeUnit = DateUnit | TimeUnit; /** * When the name of a unit is provided to a Temporal API as a string, it is * usually singular, e.g. 'day' or 'hour'. But plural unit names like 'days' * or 'hours' are also accepted. * */ - export type PluralUnit = { + type PluralUnit = { year: 'years'; month: 'months'; week: 'weeks'; @@ -155,16 +157,16 @@ export namespace Temporal { nanosecond: 'nanoseconds'; }[T]; - export type LargestUnit = 'auto' | T | PluralUnit; - export type SmallestUnit = T | PluralUnit; - export type TotalUnit = T | PluralUnit; + type LargestUnit = 'auto' | T | PluralUnit; + type SmallestUnit = T | PluralUnit; + type TotalUnit = T | PluralUnit; /** * Options for outputting precision in toString() on types with seconds */ - export type ToStringPrecisionOptions = { - fractionalSecondDigits?: 'auto' | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; - smallestUnit?: SmallestUnit<'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'>; + type ToStringPrecisionOptions = { + fractionalSecondDigits?: 'auto' | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined; + smallestUnit?: SmallestUnit<'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'> | undefined; /** * Controls how rounding is performed: @@ -180,40 +182,36 @@ export namespace Temporal { * negative infinity which is usually unexpected. For this reason, `trunc` * is recommended for most use cases. */ - roundingMode?: RoundingMode; + roundingMode?: RoundingMode | undefined; }; - export type ShowCalendarOption = { - calendarName?: 'auto' | 'always' | 'never' | 'critical'; + type ShowCalendarOption = { + calendarName?: 'auto' | 'always' | 'never' | 'critical' | undefined; }; - export type CalendarTypeToStringOptions = Partial; + type CalendarTypeToStringOptions = ToStringPrecisionOptions & ShowCalendarOption; - export type ZonedDateTimeToStringOptions = Partial< - CalendarTypeToStringOptions & { - timeZoneName?: 'auto' | 'never' | 'critical'; - offset?: 'auto' | 'never'; - } - >; + type ZonedDateTimeToStringOptions = CalendarTypeToStringOptions & { + timeZoneName?: 'auto' | 'never' | 'critical' | undefined; + offset?: 'auto' | 'never' | undefined; + }; - export type InstantToStringOptions = Partial< - ToStringPrecisionOptions & { - timeZone: TimeZoneLike; - } - >; + type InstantToStringOptions = ToStringPrecisionOptions & { + timeZone?: TimeZoneLike | undefined; + }; /** * Options to control the result of `until()` and `since()` methods in * `Temporal` types. */ - export interface DifferenceOptions { + interface DifferenceOptions { /** * The unit to round to. For example, to round to the nearest minute, use * `smallestUnit: 'minute'`. This property is optional for `until()` and * `since()`, because those methods default behavior is not to round. * However, the same property is required for `round()`. */ - smallestUnit?: SmallestUnit; + smallestUnit?: SmallestUnit | undefined; /** * The largest unit to allow in the resulting `Temporal.Duration` object. @@ -231,14 +229,14 @@ export namespace Temporal { * The default is always `'auto'`, though the meaning of this depends on the * type being used. */ - largestUnit?: LargestUnit; + largestUnit?: LargestUnit | undefined; /** * Allows rounding to an integer number of units. For example, to round to * increments of a half hour, use `{ smallestUnit: 'minute', * roundingIncrement: 30 }`. */ - roundingIncrement?: number; + roundingIncrement?: number | undefined; /** * Controls how rounding is performed: @@ -256,7 +254,7 @@ export namespace Temporal { * negative infinity which is usually unexpected. For this reason, `trunc` * is recommended for most use cases. */ - roundingMode?: RoundingMode; + roundingMode?: RoundingMode | undefined; } /** @@ -266,7 +264,7 @@ export namespace Temporal { * properties are optional. A string is treated the same as an object whose * `smallestUnit` property value is that string. */ - export type RoundTo = + type RoundTo = | SmallestUnit | { /** @@ -282,7 +280,7 @@ export namespace Temporal { * increments of a half hour, use `{ smallestUnit: 'minute', * roundingIncrement: 30 }`. */ - roundingIncrement?: number; + roundingIncrement?: number | undefined; /** * Controls how rounding is performed: @@ -298,7 +296,7 @@ export namespace Temporal { * negative infinity which is usually unexpected. For this reason, `trunc` * is recommended for most use cases. */ - roundingMode?: RoundingMode; + roundingMode?: RoundingMode | undefined; }; /** @@ -309,7 +307,7 @@ export namespace Temporal { * properties are optional. A string parameter is treated the same as an * object whose `smallestUnit` property value is that string. */ - export type DurationRoundTo = + type DurationRoundTo = | SmallestUnit | (( | { @@ -340,7 +338,7 @@ export namespace Temporal { * If `smallestUnit` is larger, then `smallestUnit` will be used as * `largestUnit`, superseding a caller-supplied or default value. */ - largestUnit?: LargestUnit; + largestUnit?: LargestUnit | undefined; } | { /** @@ -349,7 +347,7 @@ export namespace Temporal { * required, but is optional if `largestUnit` is provided and not * undefined. */ - smallestUnit?: SmallestUnit; + smallestUnit?: SmallestUnit | undefined; /** * The largest unit to allow in the resulting `Temporal.Duration` @@ -378,7 +376,7 @@ export namespace Temporal { * to increments of a half hour, use `{ smallestUnit: 'minute', * roundingIncrement: 30 }`. */ - roundingIncrement?: number; + roundingIncrement?: number | undefined; /** * Controls how rounding is performed: @@ -397,7 +395,7 @@ export namespace Temporal { * unexpected. For this reason, `trunc` is recommended for most "round * down" use cases. */ - roundingMode?: RoundingMode; + roundingMode?: RoundingMode | undefined; /** * The starting point to use for rounding and conversions when @@ -423,13 +421,19 @@ export namespace Temporal { * time zone transitions and all days will be assumed to be 24 hours * long. */ - relativeTo?: Temporal.PlainDateTime | Temporal.ZonedDateTime | PlainDateTimeLike | ZonedDateTimeLike | string; + relativeTo?: + | Temporal.PlainDateTime + | Temporal.ZonedDateTime + | PlainDateTimeLike + | ZonedDateTimeLike + | string + | undefined; }); /** * Options to control behavior of `Duration.prototype.total()` */ - export type DurationTotalOf = + type DurationTotalOf = | TotalUnit | { /** @@ -459,13 +463,19 @@ export namespace Temporal { * this option is omitted), then the operation will ignore time zone * transitions and all days will be assumed to be 24 hours long. */ - relativeTo?: Temporal.ZonedDateTime | Temporal.PlainDateTime | ZonedDateTimeLike | PlainDateTimeLike | string; + relativeTo?: + | Temporal.ZonedDateTime + | Temporal.PlainDateTime + | ZonedDateTimeLike + | PlainDateTimeLike + | string + | undefined; }; /** * Options to control behavior of `Duration.compare()` */ - export interface DurationArithmeticOptions { + interface DurationArithmeticOptions { /** * The starting point to use when variable-length units (years, months, * weeks depending on the calendar) are involved. This option is required if @@ -486,32 +496,61 @@ export namespace Temporal { * this option is omitted), then the operation will ignore time zone * transitions and all days will be assumed to be 24 hours long. */ - relativeTo?: Temporal.ZonedDateTime | Temporal.PlainDateTime | ZonedDateTimeLike | PlainDateTimeLike | string; + relativeTo?: + | Temporal.ZonedDateTime + | Temporal.PlainDateTime + | ZonedDateTimeLike + | PlainDateTimeLike + | string + | undefined; } /** * Options to control behaviour of `ZonedDateTime.prototype.getTimeZoneTransition()` */ - export type TransitionDirection = 'next' | 'previous' | { direction: 'next' | 'previous' }; - - // Handle Intl.LocalesArgument regardless of whether the TS version has it yet - type LocalesArgument = ConstructorParameters[0]; - // Provide a quick replacement for Intl.DurationFormatOptions if not in TS - type DurationFormatOptions = typeof Intl extends { DurationFormat: any } - ? ConstructorParameters<(typeof Intl)['DurationFormat']>[1] - : Record; - - export type DurationLike = { - years?: number; - months?: number; - weeks?: number; - days?: number; - hours?: number; - minutes?: number; - seconds?: number; - milliseconds?: number; - microseconds?: number; - nanoseconds?: number; + type TransitionDirection = 'next' | 'previous' | { direction: 'next' | 'previous' }; + + type DurationLike = { + years?: number | undefined; + months?: number | undefined; + weeks?: number | undefined; + days?: number | undefined; + hours?: number | undefined; + minutes?: number | undefined; + seconds?: number | undefined; + milliseconds?: number | undefined; + microseconds?: number | undefined; + nanoseconds?: number | undefined; + }; + + /** + * Options for Intl.DurationFormat + */ + export type DurationFormatOptions = { + localeMatcher?: 'lookup' | 'best fit' | undefined; + numberingSystem?: string | undefined; + style?: 'long' | 'short' | 'narrow' | 'digital' | undefined; + years?: 'long' | 'short' | 'narrow' | undefined; + yearsDisplay?: 'always' | 'auto' | undefined; + months?: 'long' | 'short' | 'narrow' | undefined; + monthsDisplay?: 'always' | 'auto' | undefined; + weeks?: 'long' | 'short' | 'narrow' | undefined; + weeksDisplay?: 'always' | 'auto' | undefined; + days?: 'long' | 'short' | 'narrow' | undefined; + daysDisplay?: 'always' | 'auto' | undefined; + hours?: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit' | undefined; + hoursDisplay?: 'always' | 'auto' | undefined; + minutes?: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit' | undefined; + minutesDisplay?: 'always' | 'auto' | undefined; + seconds?: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit' | undefined; + secondsDisplay?: 'always' | 'auto' | undefined; + milliseconds?: 'long' | 'short' | 'narrow' | 'numeric' | undefined; + millisecondsDisplay?: 'always' | 'auto' | undefined; + microseconds?: 'long' | 'short' | 'narrow' | 'numeric' | undefined; + microsecondsDisplay?: 'always' | 'auto' | undefined; + nanoseconds?: 'long' | 'short' | 'narrow' | 'numeric' | undefined; + nanosecondsDisplay?: 'always' | 'auto' | undefined; + fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined; }; /** @@ -521,7 +560,7 @@ export namespace Temporal { * * See https://tc39.es/proposal-temporal/docs/duration.html for more details. */ - export class Duration { + class Duration { static from(item: Temporal.Duration | DurationLike | string): Temporal.Duration; static compare( one: Temporal.Duration | DurationLike | string, @@ -559,7 +598,7 @@ export namespace Temporal { subtract(other: Temporal.Duration | DurationLike | string): Temporal.Duration; round(roundTo: DurationRoundTo): Temporal.Duration; total(totalOf: DurationTotalOf): number; - toLocaleString(locales?: LocalesArgument, options?: DurationFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: DurationFormatOptions): string; toJSON(): string; toString(options?: ToStringPrecisionOptions): string; valueOf(): never; @@ -580,7 +619,7 @@ export namespace Temporal { * * See https://tc39.es/proposal-temporal/docs/instant.html for more details. */ - export class Instant { + class Instant { static fromEpochMilliseconds(epochMilliseconds: number): Temporal.Instant; static fromEpochNanoseconds(epochNanoseconds: bigint): Temporal.Instant; static from(item: Temporal.Instant | string): Temporal.Instant; @@ -607,7 +646,7 @@ export namespace Temporal { roundTo: RoundTo<'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'> ): Temporal.Instant; toZonedDateTimeISO(tzLike: TimeZoneLike): Temporal.ZonedDateTime; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: InstantToStringOptions): string; valueOf(): never; @@ -619,14 +658,14 @@ export namespace Temporal { * */ export type CalendarLike = string | ZonedDateTime | PlainDateTime | PlainDate | PlainYearMonth | PlainMonthDay; - export type PlainDateLike = { + type PlainDateLike = { era?: string | undefined; eraYear?: number | undefined; - year?: number; - month?: number; - monthCode?: string; - day?: number; - calendar?: CalendarLike; + year?: number | undefined; + month?: number | undefined; + monthCode?: string | undefined; + day?: number | undefined; + calendar?: CalendarLike | undefined; }; /** @@ -636,9 +675,9 @@ export namespace Temporal { * which happens during the whole day no matter which time zone it's happening * in. * - * See https://tc39.es/proposal-temporal/docs/plaindate.html for more details. + * See https://tc39.es/proposal-temporal/docs/date.html for more details. */ - export class PlainDate { + class PlainDate { static from(item: Temporal.PlainDate | PlainDateLike | string, options?: AssignmentOptions): Temporal.PlainDate; static compare( one: Temporal.PlainDate | PlainDateLike | string, @@ -680,32 +719,32 @@ export namespace Temporal { | string | { timeZone: TimeZoneLike; - plainTime?: Temporal.PlainTime | PlainTimeLike | string; + plainTime?: Temporal.PlainTime | PlainTimeLike | string | undefined; } ): Temporal.ZonedDateTime; toPlainYearMonth(): Temporal.PlainYearMonth; toPlainMonthDay(): Temporal.PlainMonthDay; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: ShowCalendarOption): string; valueOf(): never; readonly [Symbol.toStringTag]: 'Temporal.PlainDate'; } - export type PlainDateTimeLike = { + type PlainDateTimeLike = { era?: string | undefined; eraYear?: number | undefined; - year?: number; - month?: number; - monthCode?: string; - day?: number; - hour?: number; - minute?: number; - second?: number; - millisecond?: number; - microsecond?: number; - nanosecond?: number; - calendar?: CalendarLike; + year?: number | undefined; + month?: number | undefined; + monthCode?: string | undefined; + day?: number | undefined; + hour?: number | undefined; + minute?: number | undefined; + second?: number | undefined; + millisecond?: number | undefined; + microsecond?: number | undefined; + nanosecond?: number | undefined; + calendar?: CalendarLike | undefined; }; /** @@ -716,9 +755,9 @@ export namespace Temporal { * and `Temporal.PlainMonthDay` all carry less information and should be used when * complete information is not required. * - * See https://tc39.es/proposal-temporal/docs/plaindatetime.html for more details. + * See https://tc39.es/proposal-temporal/docs/datetime.html for more details. */ - export class PlainDateTime { + class PlainDateTime { static from( item: Temporal.PlainDateTime | PlainDateTimeLike | string, options?: AssignmentOptions @@ -788,21 +827,21 @@ export namespace Temporal { toZonedDateTime(tzLike: TimeZoneLike, options?: ToInstantOptions): Temporal.ZonedDateTime; toPlainDate(): Temporal.PlainDate; toPlainTime(): Temporal.PlainTime; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: CalendarTypeToStringOptions): string; valueOf(): never; readonly [Symbol.toStringTag]: 'Temporal.PlainDateTime'; } - export type PlainMonthDayLike = { + type PlainMonthDayLike = { era?: string | undefined; eraYear?: number | undefined; - year?: number; - month?: number; - monthCode?: string; - day?: number; - calendar?: CalendarLike; + year?: number | undefined; + month?: number | undefined; + monthCode?: string | undefined; + day?: number | undefined; + calendar?: CalendarLike | undefined; }; /** @@ -810,9 +849,9 @@ export namespace Temporal { * without a year. For example, it could be used to represent a yearly * recurring event, like "Bastille Day is on the 14th of July." * - * See https://tc39.es/proposal-temporal/docs/plainmonthday.html for more details. + * See https://tc39.es/proposal-temporal/docs/monthday.html for more details. */ - export class PlainMonthDay { + class PlainMonthDay { static from( item: Temporal.PlainMonthDay | PlainMonthDayLike | string, options?: AssignmentOptions @@ -824,20 +863,20 @@ export namespace Temporal { equals(other: Temporal.PlainMonthDay | PlainMonthDayLike | string): boolean; with(monthDayLike: PlainMonthDayLike, options?: AssignmentOptions): Temporal.PlainMonthDay; toPlainDate(year: { year: number }): Temporal.PlainDate; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: ShowCalendarOption): string; valueOf(): never; readonly [Symbol.toStringTag]: 'Temporal.PlainMonthDay'; } - export type PlainTimeLike = { - hour?: number; - minute?: number; - second?: number; - millisecond?: number; - microsecond?: number; - nanosecond?: number; + type PlainTimeLike = { + hour?: number | undefined; + minute?: number | undefined; + second?: number | undefined; + millisecond?: number | undefined; + microsecond?: number | undefined; + nanosecond?: number | undefined; }; /** @@ -853,9 +892,9 @@ export namespace Temporal { * `Temporal.PlainDateTime` by combining it with a `Temporal.PlainDate` using the * `toPlainDateTime()` method. * - * See https://tc39.es/proposal-temporal/docs/plaintime.html for more details. + * See https://tc39.es/proposal-temporal/docs/time.html for more details. */ - export class PlainTime { + class PlainTime { static from(item: Temporal.PlainTime | PlainTimeLike | string, options?: AssignmentOptions): Temporal.PlainTime; static compare( one: Temporal.PlainTime | PlainTimeLike | string, @@ -890,7 +929,7 @@ export namespace Temporal { round( roundTo: RoundTo<'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'> ): Temporal.PlainTime; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: ToStringPrecisionOptions): string; valueOf(): never; @@ -898,22 +937,17 @@ export namespace Temporal { } /** - * To provide a time zone to any non-constructor Temporal method, any of the - * following are allowed: - * - An IANA time zone ID string like "Europe/Paris" - * - An RFC 9557 string that includes a time zone annotation like - * "2025-03-13T05:40:57.499+01:00[Europe/Paris]" - * - A `Temporal.ZonedDateTime` object - */ - export type TimeZoneLike = string | ZonedDateTime; + * Any of these types can be passed to Temporal methods instead of a time zone ID. + * */ + type TimeZoneLike = string | ZonedDateTime; - export type PlainYearMonthLike = { + type PlainYearMonthLike = { era?: string | undefined; eraYear?: number | undefined; - year?: number; - month?: number; - monthCode?: string; - calendar?: CalendarLike; + year?: number | undefined; + month?: number | undefined; + monthCode?: string | undefined; + calendar?: CalendarLike | undefined; }; /** @@ -921,9 +955,9 @@ export namespace Temporal { * example, it could be used to represent a particular instance of a monthly * recurring event, like "the June 2019 meeting". * - * See https://tc39.es/proposal-temporal/docs/plainyearmonth.html for more details. + * See https://tc39.es/proposal-temporal/docs/yearmonth.html for more details. */ - export class PlainYearMonth { + class PlainYearMonth { static from( item: Temporal.PlainYearMonth | PlainYearMonthLike | string, options?: AssignmentOptions @@ -959,32 +993,32 @@ export namespace Temporal { options?: DifferenceOptions<'year' | 'month'> ): Temporal.Duration; toPlainDate(day: { day: number }): Temporal.PlainDate; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: ShowCalendarOption): string; valueOf(): never; readonly [Symbol.toStringTag]: 'Temporal.PlainYearMonth'; } - export type ZonedDateTimeLike = { + type ZonedDateTimeLike = { era?: string | undefined; eraYear?: number | undefined; - year?: number; - month?: number; - monthCode?: string; - day?: number; - hour?: number; - minute?: number; - second?: number; - millisecond?: number; - microsecond?: number; - nanosecond?: number; - offset?: string; - timeZone?: TimeZoneLike; - calendar?: CalendarLike; + year?: number | undefined; + month?: number | undefined; + monthCode?: string | undefined; + day?: number | undefined; + hour?: number | undefined; + minute?: number | undefined; + second?: number | undefined; + millisecond?: number | undefined; + microsecond?: number | undefined; + nanosecond?: number | undefined; + offset?: string | undefined; + timeZone?: TimeZoneLike | undefined; + calendar?: CalendarLike | undefined; }; - export class ZonedDateTime { + class ZonedDateTime { static from( item: Temporal.ZonedDateTime | ZonedDateTimeLike | string, options?: ZonedDateTimeAssignmentOptions @@ -1053,7 +1087,7 @@ export namespace Temporal { toPlainDateTime(): Temporal.PlainDateTime; toPlainDate(): Temporal.PlainDate; toPlainTime(): Temporal.PlainTime; - toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string; toJSON(): string; toString(options?: ZonedDateTimeToStringOptions): string; valueOf(): never; @@ -1066,7 +1100,7 @@ export namespace Temporal { * * See https://tc39.es/proposal-temporal/docs/now.html for more details. */ - export const Now: { + const Now: { /** * Get the exact system date and time as a `Temporal.Instant`. * @@ -1142,18 +1176,17 @@ export namespace Temporal { }; } -declare namespace Intl { +export namespace Intl { type Formattable = | Date | Temporal.Instant - | Temporal.ZonedDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay; - export interface DateTimeFormat extends globalThis.Intl.DateTimeFormat { + interface DateTimeFormat extends globalThis.Intl.DateTimeFormat { /** * Format a date into a string according to the locale and formatting * options of this `Intl.DateTimeFormat` object. @@ -1193,23 +1226,21 @@ declare namespace Intl { formatRangeToParts(startDate: Date | number, endDate: Date | number): globalThis.Intl.DateTimeRangeFormatPart[]; } - export const DateTimeFormat: { + const DateTimeFormat: { /** * Creates `Intl.DateTimeFormat` objects that enable language-sensitive * date and time formatting. */ - new (locales?: string | string[], options?: globalThis.Intl.DateTimeFormatOptions): DateTimeFormat; - (locales?: string | string[], options?: globalThis.Intl.DateTimeFormatOptions): DateTimeFormat; + new (locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): DateTimeFormat; + (locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): DateTimeFormat; /** * Get an array containing those of the provided locales that are supported * in date and time formatting without having to fall back to the runtime's * default locale. */ - supportedLocalesOf(locales: string | string[], options?: globalThis.Intl.DateTimeFormatOptions): string[]; + supportedLocalesOf(locales: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string[]; }; } -export { Intl as Intl }; - export function toTemporalInstant(this: Date): Temporal.Instant; diff --git a/website/src/components/Playground/monaco-init.ts b/website/src/components/Playground/monaco-init.ts index 9211c479ffbc..ed17f7463520 100644 --- a/website/src/components/Playground/monaco-init.ts +++ b/website/src/components/Playground/monaco-init.ts @@ -335,8 +335,8 @@ if ( 'file:///node_modules/@number-flow/react/index.d.ts', ); monaco.languages.typescript.typescriptDefaults.addExtraLib( - `declare module "@js-temporal/polyfill" { ${temporal} }`, - 'file:///node_modules/@js-temporal/polyfill/index.d.ts', + `declare module "temporal-polyfill" { ${temporal} }`, + 'file:///node_modules/temporal-polyfill/index.d.ts', ); monaco.languages.typescript.typescriptDefaults.addExtraLib( `declare module "uuid" { ${uuid} }`, @@ -353,7 +353,7 @@ if ( `declare globals { export { default as NumberFlow } from '@number-flow/react'; }`, ); monaco.languages.typescript.typescriptDefaults.addExtraLib( - `declare globals { export { Temporal, DateTimeFormat } from '@js-temporal/polyfill'; }`, + `declare globals { export { Temporal, DateTimeFormat } from 'temporal-polyfill'; }`, ); rhLibs.forEach((lib, i) => { diff --git a/website/src/components/Playground/temporal.ts b/website/src/components/Playground/temporal.ts new file mode 100644 index 000000000000..f9b059586ff9 --- /dev/null +++ b/website/src/components/Playground/temporal.ts @@ -0,0 +1,11 @@ +import { Temporal as PolyTemporal, Intl as PolyIntl } from 'temporal-polyfill'; + +export const Temporal = globalThis.Temporal ?? PolyTemporal; + +export const Intl = + globalThis.Temporal ? globalThis.Intl : { ...globalThis.Intl, ...PolyIntl }; + +export const DateTimeFormat = + globalThis.Temporal ? + globalThis.Intl.DateTimeFormat + : PolyIntl.DateTimeFormat; diff --git a/yarn.lock b/yarn.lock index cd16f9ef4f03..edcd9e49e6f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3243,12 +3243,12 @@ __metadata: "@babel/runtime": "npm:^7.20.0" "@data-client/core": "workspace:*" "@data-client/normalizr": "workspace:*" - "@js-temporal/polyfill": "npm:^0.5.0" "@types/jest": "npm:30.0.0" "@types/node": "npm:^24.0.0" immutable: "npm:5.1.5" nock: "npm:13.3.1" rollup-plugins: "workspace:*" + temporal-polyfill: "npm:^0.3.0" languageName: unknown linkType: soft @@ -3300,11 +3300,11 @@ __metadata: "@anansi/browserslist-config": "npm:^1.4.2" "@babel/runtime": "npm:^7.20.0" "@data-client/endpoint": "workspace:*" - "@js-temporal/polyfill": "npm:^0.5.0" "@types/jest": "npm:30.0.0" "@types/node": "npm:^24.0.0" immutable: "npm:5.1.5" rollup-plugins: "workspace:*" + temporal-polyfill: "npm:^0.3.0" languageName: unknown linkType: soft @@ -3319,7 +3319,6 @@ __metadata: "@data-client/test": "workspace:*" "@data-client/use-enhanced-reducer": "workspace:^" "@jest/globals": "npm:^30.0.0" - "@js-temporal/polyfill": "npm:^0.5.0" "@react-navigation/native": "npm:^7.0.0" "@react-navigation/native-stack": "npm:^7.2.0" "@testing-library/dom": "npm:^10.4.0" @@ -3340,6 +3339,7 @@ __metadata: react-native-screens: "npm:^4.1.0" react-test-renderer: "npm:^19.0.0" rollup-plugins: "workspace:*" + temporal-polyfill: "npm:^0.3.0" peerDependencies: "@react-navigation/native": ^6.0.0 || ^7.0.0 "@types/react": ^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-0 || ^19.0.0 @@ -3450,7 +3450,6 @@ __metadata: "@data-client/core": "workspace:^" "@data-client/rest": "workspace:*" "@jest/globals": "npm:^30.0.0" - "@js-temporal/polyfill": "npm:^0.5.0" "@types/jest": "npm:30.0.0" "@types/node": "npm:^24.0.0" "@vue/test-utils": "npm:^2.4.0" @@ -3458,6 +3457,7 @@ __metadata: jest-mock: "npm:^30.0.0" nock: "npm:13.3.1" rollup-plugins: "workspace:*" + temporal-polyfill: "npm:^0.3.0" vue: "npm:^3.4.0" peerDependencies: "@types/vue": ^3.0.0 @@ -5296,15 +5296,6 @@ __metadata: languageName: node linkType: hard -"@js-temporal/polyfill@npm:^0.5.0": - version: 0.5.1 - resolution: "@js-temporal/polyfill@npm:0.5.1" - dependencies: - jsbi: "npm:^4.3.0" - checksum: 10c0/d9a843e22167e6c98946dc03f8a480d062ece5d01ca850930c8f00af1bd99cfe513a98c3420b24a9920c47e7a61a82e5c8866da47ecdc0e7ee2cd3bf6e440b46 - languageName: node - linkType: hard - "@kwsites/file-exists@npm:^1.1.1": version: 1.1.1 resolution: "@kwsites/file-exists@npm:1.1.1" @@ -18718,13 +18709,6 @@ __metadata: languageName: node linkType: hard -"jsbi@npm:^4.3.0": - version: 4.3.0 - resolution: "jsbi@npm:4.3.0" - checksum: 10c0/1817ac1b50ea3f4438bcd84cadc9aee7a8657829f65b55ea6f151f401dbbd3babedbfdd3e4f481bd7b5472abb7823efa640fd7e5eee7c30cea6431f7a8b74696 - languageName: node - linkType: hard - "jsbn@npm:1.1.0": version: 1.1.0 resolution: "jsbn@npm:1.1.0" @@ -24663,7 +24647,6 @@ __metadata: "@docusaurus/preset-classic": "npm:^3.0.1" "@docusaurus/theme-live-codeblock": "npm:^3.0.1" "@docusaurus/theme-mermaid": "npm:^3.0.1" - "@js-temporal/polyfill": "npm:^0.5.0" "@mdx-js/react": "npm:^3.1.0" "@monaco-editor/react": "npm:^4.8.0-rc.0" "@number-flow/react": "npm:^0.6.0" @@ -24683,6 +24666,7 @@ __metadata: react-json-tree: "npm:0.20.0" react-live: "npm:^4.0.0" serve: "npm:14.2.6" + temporal-polyfill: "npm:^0.3.0" typescript: "npm:6.0.2" uuid: "npm:^13.0.0" webpack: "npm:^5.76.0" @@ -26041,7 +26025,6 @@ __metadata: "@data-client/react": "workspace:*" "@data-client/rest": "workspace:*" "@data-client/test": "workspace:*" - "@js-temporal/polyfill": "npm:^0.5.0" "@react-navigation/native": "npm:^7.0.0" "@react-navigation/native-stack": "npm:^7.0.0" "@testing-library/dom": "npm:^10.4.0" @@ -26075,6 +26058,7 @@ __metadata: react-test-renderer: "npm:19.2.3" rimraf: "npm:^6.0.0" rollup: "npm:4.59.0" + temporal-polyfill: "npm:^0.3.0" typescript: "npm:6.0.2" whatwg-fetch: "npm:3.0.0" languageName: unknown @@ -27921,6 +27905,22 @@ __metadata: languageName: node linkType: hard +"temporal-polyfill@npm:^0.3.0": + version: 0.3.2 + resolution: "temporal-polyfill@npm:0.3.2" + dependencies: + temporal-spec: "npm:0.3.1" + checksum: 10c0/762795c94e1b6cb0574541d0b09f805ff23b0a2c9d0356ab3fc0205e390a3bce73e047de2fdc54c7d149d6e6d781aa1d95aa62afa5de4c83cb79c129b0e502da + languageName: node + linkType: hard + +"temporal-spec@npm:0.3.1": + version: 0.3.1 + resolution: "temporal-spec@npm:0.3.1" + checksum: 10c0/e38eae391bd59ae675f1925a65c8ef302933cf9ce98efedaf2e69269e8c36f2b5d486cd3084367f04a6c1ea0289b925690c0df20a73f0c4629b531775924e850 + languageName: node + linkType: hard + "term-size@npm:^2.1.0": version: 2.2.1 resolution: "term-size@npm:2.2.1"