Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2026-03-23

### Added
- **Monorepo Migration**: Successfully transitioned to a unified monorepo structure, naming `packages/tempo` and `packages/library` as npm workspaces.
- **Publishing Optimizations**: Integrated `prepublishOnly` build hooks and `files` whitelisting in `package.json` for leaner and more reliable NPM distribution.
- **Enhanced Type Resolution**: Fixed `node` type definition errors in nested test environments by explicitly configuring `typeRoots`.

### Changed
- **Dependency Rationalization**: Consolidated `tslib` and `@js-temporal/polyfill` at the project root while preserving `tslib` as a runtime dependency for published packages.
- **Plugin Loading Refactor**: Refactored `static load` into a unified, single-pass dispatch logic for handling Plugins, TermPlugins, and Discovery configurations robustly.

## [1.1.0] - 2026-03-21

### Added
- **Plugin System (`Tempo.extend`)**: Introduced a formal architecture for extending the `Tempo` class and prototype, allowing for modular feature injection (e.g., `TickerPlugin`).
- **Plugin System (`Tempo.load`)**: Introduced a formal architecture for extending the `Tempo` class and prototype, allowing for modular feature injection (e.g., `TickerPlugin`).
- **Auto-Plugin Discovery**: Plugins can now be automatically loaded via the `plugins` configuration in `Tempo.init()` or through the Global Discovery manifest (`Symbol.for($Tempo)`).
- **Selective Immobility**: Enhanced the `@Immutable` decorator with a "Selective Immute" pattern. Core methods (including Symbols like `Symbol.dispose`) are now write-protected, while the class remains extensible for new plugins.
- **Reactive Clock (Modularized)**: The `Tempo.ticker` logic has been extracted into an optional plugin available at `@magmacomputing/tempo/plugins/ticker`. This reduces core bundle size while offering high-performance Async Generators and countdown support.
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Working with dates in JavaScript has historically been painful. The new `Tempora
- **Flexible Parsing**: Interprets almost any date string, including relative ones like "next Friday".
- **Fluent API**: Chainable methods for adding, subtracting, and setting date-times (similar to Moment.js).
- **Formatting**: Use custom tokens to format date-times in a way that is both intuitive and flexible.
- **Plugins**: Extend core functionality safely with plugins (e.g. `TickerPlugin`).
- **Plugins**: Extend core functionality safely with `Tempo.load()` (e.g. `TickerPlugin`).
- **Terms**: Access complex date ranges (Quarters, Seasons, Fiscal Years) easily.
- **Immutable**: Operations (like `set` and `add`) return a new `Tempo` instance, ensuring thread safety and predictability.

Expand All @@ -35,7 +35,11 @@ npm install @magmacomputing/tempo
```

### 💻 Node.js (Server-Side)
Tempo is a native ESM package. In Node.js (20+), simply import the class:
Tempo is a native ESM package. In Node.js (20+), simply import the class.
> [!NOTE]
> Tempo uses native Node.js subpath imports (e.g. `#tempo/*`). This requires Node.js 14.6+ or 12.19+ in server-side environments.

In Node.js:

```javascript
import { Tempo } from '@magmacomputing/tempo';
Expand Down Expand Up @@ -101,7 +105,7 @@ For detailed technical guides, please refer to:
- [Tempo Class Documentation](./doc/Tempo.md)
- [Data In ~ Parsing Engine](./doc/Tempo.md#parsing)
- [Data Out ~ Formatting Tokens](./doc/Tempo.md#formatting)
- [Plugin System (Extending Tempo)](./doc/Tempo.md#plugin-system)
- [Plugin System (Extending Tempo)](./doc/Tempo.md#plugin-system) (`Tempo.load`)
- [Terms (Calculation Plugins)](./doc/Tempo.md#plugins-terms)
- [Configuration Guide](./doc/tempo.config.md)
- [Commercial Support & Consulting](./doc/commercial.md)
Expand Down
4 changes: 2 additions & 2 deletions doc/Tempo.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ You can extend these patterns a) globally (via `Tempo.init()`) or b) per instanc
`Tempo` also supports **Event** and **Period** aliases. These can be simple strings or functions that return a value to be parsed. When using functions, ensure you use the `function` keyword to maintain proper `this` binding to the `Tempo` instance.

```typescript
Tempo.init({
Tempo.load({
event: {
'birthday': '20 May',
'tomorrow': function () { return this.toPlainDate().add({ days: 1 }) },
Expand Down Expand Up @@ -279,7 +279,7 @@ To add a plugin, use the static `extend()` method.
import { Tempo } from '@magmacomputing/tempo';
import { TickerPlugin } from '@magmacomputing/tempo/plugins/ticker';

Tempo.extend(TickerPlugin);
Tempo.load(TickerPlugin);
```

> [!NOTE]
Expand Down
18 changes: 7 additions & 11 deletions doc/tempo.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ Initializes the global default configuration for all subsequent `Tempo` instance
- **Returns:** `Tempo.Config` (The resolved global config).
- **Note:** Settings are inherited from library defaults, persistent storage, and provided options.

### `Tempo.discover(config: Tempo.Discovery)`
Bootstraps the library with a Global Discovery object and automatically calls `Tempo.init()`.
- **Returns:** `Tempo.Config` (The resolved global config).
- **Note:** This is the recommended way to provide global configuration in ESM environments.

### `Tempo.extend(...plugins: Tempo.Plugin[])`
Extends the `Tempo` class and prototype with new functionality.
- **Example:** `Tempo.extend(TickerPlugin)`
- **Note:** Plugins are only installed once. Existing core members are protected from being overwritten.
### `Tempo.load(arg, options?)`
Unified loader for library extensions. Replaces `discover`, `extend`, and `addTerm`.
- **Plugin:** `Tempo.load(TickerPlugin)` — Adds functional extensions.
- **Term:** `Tempo.load(MyTerm)` — Registers grammar/parsing terms.
- **Discovery:** `Tempo.load(config)` — Bootstraps global configuration.
- **Returns:** `typeof Tempo` (for chaining).
- **Note:** Plugins are only installed once. Existing core members are protected.

### `Tempo.from(tempo?: Tempo.DateTime | Tempo.Options, options?: Tempo.Options)`
Creates a new `Tempo` instance. A static alternative to `new Tempo()`.
Expand All @@ -34,8 +32,6 @@ Creates a new `Tempo` instance. A static alternative to `new Tempo()`.
Compares two `Tempo` instances or date-time values for sorting.
- **Returns:** `-1` (smaller), `0` (equal), or `1` (larger).

### `Tempo.addTerm(...plugins: Tempo.TermPlugin[])`
Registers new term plugins globally.

### `Tempo.now()`
Returns the current Unix epoch in nanoseconds as a `BigInt`.
Expand Down
2 changes: 1 addition & 1 deletion doc/tempo.config.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This is the most secure and ergonomic method to provide configuration, and is co
```javascript
import { Tempo } from '@magmacomputing/tempo';

Tempo.discover({
Tempo.load({
options: { timeZone: 'Europe/Paris' },
timeZones: { 'MYTZ': 'Asia/Dubai' },
formats: { 'myFormat': '{dd}!!{mm}!!{yyyy}' },
Expand Down
214 changes: 0 additions & 214 deletions lib/buffer.library.ts

This file was deleted.

46 changes: 0 additions & 46 deletions lib/proxy.library.ts

This file was deleted.

Loading