p-hatan/ mirror

pub repository

mirror.p-hatan.ir

node_preamble

1.4.11

Better node.js preamble for dart2js, use it in your build system.

Download archive

Readme

node_preamble.dart

A simple package for a better dart2js preamble for running on node.js. This package exists for ease of use if incorporating into your build system.

This preamble is suggested for use over d8.js, and provides many improvements and bug fixes, as it uses node.js's timer functions and event loop over the custom one implemented in d8.js.

The JavaScript file can be found at lib/preamble.js.

You can also get the preamble via Dart, like in the following example.

import "package:node_preamble/preamble.dart" as preamble;

main() {
  print(preamble.getPreamble());
}

Credit goes to the Dart team for creating Dart, dart2js, and the original preamble which this is derived from.

Contributing

The only file that we directly modify is preamble.js. After that, to reflect your changes in both preamble.dart and preamble.min.js, run npm install && npm run minify

Changelog

1.4.11

Hotfix again for Electron support, quite embarassing at this point. Verified using the awesome Electron Fiddle tool.

1.4.10

Oops, fix Electron capabilities to be correct. Sorry about this!

1.4.9

  • Change behavior of Node.js detection that now takes into account:
    • Web workers in browser
    • Electron

1.4.8

  • Fixed previous build 1.4.7 when minified file is used.

1.4.7

Thanks! @lexaknyazev

  • Move url module import to Node.js-only block.
  • Fix for when we try to load url on Node.js but are also using Webpack.

1.4.6

  • Make location.href compatible with Node versions earlier than 10.12.0 again.

1.4.5

  • Improve location.href so that Dart's Uri.current works for more paths.

    • Make location.href a getter so Dart's Uri.current changes along with the process's working directory.
  • Fixes for Angular 6+ applications using compiled Dart package w/ preamble:

    • Checks for global if it's not polyfilled, then try for window.
    • Don't assume that since we have CommonJS we have process, __dirname, __filename.

1.4.4

  • Explicitly support Dart 2 stable releases.

1.4.3

  • Add Node detector for Browserify/Webpack-type environments. (thanks to @lexaknyazev for reporting!)
  • Add examples for pub (thanks @bcko!)

1.4.2

  • Keep Uri.base up to date when the current working directory changes.
  • Add .dart_tool to gitignore.

1.4.1

  • Make sure to replace all backslashes for cwd on Windows, not just the first.

1.4.0

  • Add __dirname and __filename to exposed globals. Adds ability of exposing more globals in the preamble by calling getPreamble(additionalGlobals: ["__dirname", ...]).

1.3.0

  • Add minified versions of the preamble accessible as lib/preamble.min.js and by calling getPreamble(minified: true).

1.2.0

  • Prevent encapsulation, global.self = global (old) vs. var self = Object.create(global) (new).

1.1.0

  • Set global.location so that Uri.base() works properly on Windows in most cases.

  • Define global.exports so that it's visible to the compiled JS.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add node_preamble
pubspec.yaml
name: node_preamble
author: Michael Bullington <mikebullingtn@gmail.com>
homepage: https://github.com/mbullington/node_preamble.dart
version: 1.4.11
description: Better node.js preamble for dart2js, use it in your build system.

environment:
  sdk: '>=1.24.0 <3.0.0'

dev_dependencies:
  http: '^0.11.0'

Version history

VersionPublishedArchiveSHA-256
1.0.02015-08-24T03:09:46.852ZDownload1d7c0be1df059b95e11b2c0571cc02e3753a7a114f61ca240d629072d7777b74
1.1.02016-12-02T23:19:32.674ZDownload078cdd99bcd7f020810c2f5e0477ce9438f0ba4e0d80f4af11591244b38e76ef
1.2.02016-12-03T00:09:08.131ZDownload970006d1e5dc58358eeee768c44adacbcaae3c5fb4a8a2be2ce4d7ee4584a0a2
1.3.02017-03-12T00:04:23.667ZDownload5873b9fef32b99c815be4e567172818dd5bc50970fd0b8610fa644e34913f332
1.4.02017-06-30T16:15:07.531732ZDownload480628b8063ea75023203641462c2a24ffa7ecf20960877f5df7740d36ce8698
1.4.12018-04-25T22:58:40.162326ZDownload427980a413a23c85361eb1acbf968973bf145a7633b5ce55c18edbe6605fc89f
1.4.22018-05-25T23:36:58.798725ZDownload3a3be084f2758ebc578bf0547d96cdb0fbda14024ab7ebf40535a60bf7cf0aeb
1.4.32018-07-01T06:29:13.490888ZDownload4ca69f92864e1afdf51785d32fd7edec524f8d11690a140c404f2eeef4c4b6c0
1.4.42018-07-24T17:32:40.272250ZDownloadba9c0e22dd12237f404a7c965951d2c69ae78e529ae9a4fa6aa2a2417163f52f
1.4.52019-07-22T07:03:33.036072ZDownloadc10e8a5aa518d87e16161544c855ada8963ec0f8f90397e8ed026db01df99727
1.4.62019-07-27T23:37:08.146920ZDownload4fecbfadaffde1bf075aeb3d615482e19a58f7b98c94586405e1a368008f979c
1.4.72019-09-04T01:49:39.603846ZDownload767ef8efc9ae106ff2c9f5d07f3bc56ab976a22c43524136c051ec5290aa9f24
1.4.82019-09-10T21:05:02.061256ZDownload2c4565b1d416fc68935b1bb5d5e8fbed843d828ef26244cd14b2ea267b745064
1.4.92020-05-23T22:37:36.388205ZDownload1d0bad4d4fa4e385cecb7c9c8c7fa6e6f7b0ed15029216c9707374eef314f1f9
1.4.102020-06-03T04:15:49.662522ZDownload2c001095d140de1f49ec0a75a3861557f56e39eeea7674ffbc4f5c2b9a803804
1.4.112020-06-10T05:48:15.834539ZDownloadda2cfccc846e5bc61c343faa6bc3c452065ff876cb2cb253f375a0c643ae13d2
1.4.122020-06-10T05:50:31.407053ZDownload19fbcd082b2ca6ca7874571e11120d025134995103e0ff3905666779048ad893
1.4.132021-01-25T03:30:40.194877ZDownload847d2400938dd2594b4617244c4a9d477e939d0e134746ae88d9497e0ecb0a71
2.0.02021-03-03T18:32:55.343147ZDownloadc133f761a6a790d0b000efa4f74eae9700bb6e9e9f5e996f0e8d6fe92703ced6
2.0.12021-06-16T04:02:03.443896ZDownload8ebdbaa3b96d5285d068f80772390d27c21e1fa10fb2df6627b1b9415043608d
2.0.22023-03-01T06:25:31.131415ZDownload6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db

Dependencies

No direct dependencies declared.