temporal_js_polyfill 0.0.2 copy "temporal_js_polyfill: ^0.0.2" to clipboard
temporal_js_polyfill: ^0.0.2 copied to clipboard

Loads the TC39 Temporal polyfill for Dart web apps that need to support browsers without native Temporal. Injects temporal-polyfill into the page and resolves once the global Temporal object is availa [...]

temporal_js_polyfill #

Loads the TC39 Temporal polyfill for Dart web apps that need to support browsers without native Temporal. Pairs with temporal or temporal_js.

Features #

  • loadTemporalPolyfill() — injects temporal-polyfill into the page as a <script> tag and resolves once the global Temporal object is available
  • Cross-platform safe — on native / VM platforms every symbol is a no-op or a trivially-true constant, so the same main.dart compiles on every target without conditional imports
  • Self-hostable — pass a custom src URL to pin a specific polyfill version or serve it from your own CDN

Getting started #

dependencies:
  temporal: ^0.0.1
  temporal_js_polyfill: ^0.0.1

Usage #

Call loadTemporalPolyfill() once at app startup, before any Temporal types are used:

import 'package:temporal/temporal.dart';
import 'package:temporal_js_polyfill/temporal_js_polyfill.dart';

void main() async {
  await loadTemporalPolyfill(); // no-op on native and modern browsers
  runApp(MyApp());
}

To use a self-hosted or pinned polyfill bundle:

await loadTemporalPolyfill(
  src: 'https://cdn.example.com/temporal-polyfill@1.0.0/index.umd.js',
);

Browser support #

The polyfill targets browsers that implement modern JS but lack the native Temporal API (e.g. Firefox, Safari prior to their respective Temporal shipping dates). On browsers with native Temporal, loadTemporalPolyfill() returns immediately without injecting any script.

Additional information #

0
likes
130
points
25
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Loads the TC39 Temporal polyfill for Dart web apps that need to support browsers without native Temporal. Injects temporal-polyfill into the page and resolves once the global Temporal object is available. Pairs with package:temporal or package:temporal_js.

Repository (GitHub)
View/report issues

Topics

#date #time #temporal #web #polyfill

License

unknown (license)

Dependencies

web

More

Packages that depend on temporal_js_polyfill