2017-07-19 03:29:19 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
2017-05-25 02:19:33 +03:00
|
|
|
import * as zone from './zone/zone';
|
2017-06-29 00:53:19 +03:00
|
|
|
import * as impl from './zone/zone-impl';
|
2017-05-25 02:19:33 +03:00
|
|
|
|
|
|
|
import * as platform from './runtime/platform';
|
|
|
|
|
|
|
|
let binding = require('./binding');
|
|
|
|
|
|
|
|
// This variable is either defined by napa runtime, or not defined (hence node runtime)
|
|
|
|
declare var __in_napa: boolean;
|
|
|
|
|
|
|
|
/// <summary> Creates a new zone. </summary>
|
|
|
|
/// <summary> A unique id to identify the zone. </summary>
|
|
|
|
/// <param name="settings"> The settings of the new zone. </param>
|
2017-06-07 23:20:55 +03:00
|
|
|
export function create(id: string, settings: zone.ZoneSettings = zone.DEFAULT_SETTINGS) : zone.Zone {
|
2017-05-25 02:19:33 +03:00
|
|
|
platform.initialize();
|
2017-06-29 00:53:19 +03:00
|
|
|
return new impl.ZoneImpl(binding.createZone(id, settings));
|
2017-05-25 02:19:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary> Returns the zone associated with the provided id. </summary>
|
|
|
|
export function get(id: string) : zone.Zone {
|
2017-06-05 20:34:45 +03:00
|
|
|
platform.initialize();
|
2017-06-29 00:53:19 +03:00
|
|
|
return new impl.ZoneImpl(binding.getZone(id));
|
2017-05-25 02:19:33 +03:00
|
|
|
}
|
|
|
|
|
2017-06-07 23:20:55 +03:00
|
|
|
/// TODO: add function getOrCreate(id: string, settings: zone.ZoneSettings): Zone.
|
|
|
|
|
2017-06-29 00:53:19 +03:00
|
|
|
/// <summary> Define a getter property 'current' to retrieve the current zone. </summary>
|
2017-05-25 02:19:33 +03:00
|
|
|
export declare let current: zone.Zone;
|
|
|
|
Object.defineProperty(exports, "current", {
|
|
|
|
get: function () : zone.Zone {
|
2017-06-05 20:34:45 +03:00
|
|
|
platform.initialize();
|
2017-06-29 00:53:19 +03:00
|
|
|
return new impl.ZoneImpl(binding.getCurrentZone());
|
|
|
|
}
|
|
|
|
});
|
2017-05-25 02:19:33 +03:00
|
|
|
|
2017-06-29 00:53:19 +03:00
|
|
|
/// <summary> Define a getter property 'node' to retrieve node zone. </summary>
|
|
|
|
export declare let node: zone.Zone;
|
|
|
|
Object.defineProperty(exports, "node", {
|
|
|
|
get: function () : zone.Zone {
|
|
|
|
platform.initialize();
|
|
|
|
return new impl.ZoneImpl(binding.getZone('node'));
|
2017-05-25 02:19:33 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export * from './zone/zone';
|