Skip to content

Commit

Permalink
Add the cached-iterable dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Jul 19, 2018
1 parent aa95b1f commit d849a8f
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 400 deletions.
4 changes: 4 additions & 0 deletions fluent-dom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
iOS Safari 10.3+ and node 8.9+.

- Add the `cached-iterable` runtime dependency.

`CachedAsyncIterable` is now available from its own package rather than from the `fluent` package.

## fluent-dom 0.3.0

- Refactor the overlay sanitization methods into separate functions. (#189)
Expand Down
3 changes: 3 additions & 0 deletions fluent-dom/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PACKAGE := fluent-dom
GLOBAL := FluentDOM
DEPS := cached-iterable:CachedIterable

include ../common.mk

Expand All @@ -11,6 +12,7 @@ $(PACKAGE).js: $(SOURCES)
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
--name $(GLOBAL) \
--globals $(DEPS) \
--output.file $@
@echo -e " $(OK) $@ built"

Expand All @@ -20,6 +22,7 @@ compat.js: $(SOURCES)
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
--name $(GLOBAL) \
--globals $(DEPS) \
--output.file $@
@echo -e " $(OK) $@ built"

Expand Down
3 changes: 3 additions & 0 deletions fluent-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
},
"devDependencies": {
"jsdom": "^11.6.2"
},
"dependencies": {
"cached-iterable": "^0.2.0"
}
}
10 changes: 5 additions & 5 deletions fluent-dom/src/localization.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
/* global console */

import { CachedAsyncIterable } from "../../fluent/src/index";
import { CachedAsyncIterable } from "cached-iterable";

/**
* The `Localization` class is a central high-level API for vanilla
Expand All @@ -20,8 +20,8 @@ export default class Localization {
constructor(resourceIds = [], generateMessages) {
this.resourceIds = resourceIds;
this.generateMessages = generateMessages;
this.ctxs =
new CachedAsyncIterable(this.generateMessages(this.resourceIds));
this.ctxs = CachedAsyncIterable.from(
this.generateMessages(this.resourceIds));
}

addResourceIds(resourceIds) {
Expand Down Expand Up @@ -154,8 +154,8 @@ export default class Localization {
* that language negotiation or available resources changed.
*/
onChange() {
this.ctxs =
new CachedAsyncIterable(this.generateMessages(this.resourceIds));
this.ctxs = CachedAsyncIterable.from(
this.generateMessages(this.resourceIds));
this.ctxs.touchNext(2);
}
}
Expand Down
4 changes: 4 additions & 0 deletions fluent-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
iOS Safari 10.3+ and node 8.9+.

- Add the `cached-iterable` runtime dependency.

`CachedSyncIterable` is now available from its own package rather than from the `fluent` package.

## fluent-react 0.7.0 (May 18, 2018)

- Protect void elements against translated text content. (#174)
Expand Down
12 changes: 10 additions & 2 deletions fluent-react/compat_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ export default {
plugins: [
...babelConfig.plugins,
["babel-plugin-transform-rename-import", {
original: "fluent",
replacement: "fluent/compat",
replacements: [
{
original: "fluent",
replacement: "fluent/compat",
},
{
original: "cached-iterable",
replacement: "cached-iterable/compat",
},
]
}],
]
}),
Expand Down
4 changes: 2 additions & 2 deletions fluent-react/makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE := fluent-react
GLOBAL := FluentReact
DEPS := fluent:Fluent,react:React,prop-types:PropTypes
DEPS := fluent:Fluent,cached-iterable:CachedIterable,react:React,prop-types:PropTypes

include ../common.mk

Expand All @@ -22,7 +22,7 @@ compat.js: $(SOURCES)
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
--name $(GLOBAL) \
--globals fluent/compat:Fluent,$(DEPS) \
--globals fluent/compat:Fluent,cached-iterable/compat:CachedIterable,$(DEPS) \
--output.file $@
@echo -e " $(OK) $@ built"

Expand Down
1 change: 1 addition & 0 deletions fluent-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"node": ">=8.9.0"
},
"dependencies": {
"cached-iterable": "^0.2.0",
"fluent": "^0.4.0 || ^0.6.0",
"prop-types": "^15.6.0"
},
Expand Down
7 changes: 4 additions & 3 deletions fluent-react/src/localization.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CachedIterable, mapContextSync } from "fluent";
import { mapContextSync } from "fluent";
import { CachedSyncIterable } from "cached-iterable";

/*
* `ReactLocalization` handles translation formatting and fallback.
Expand All @@ -17,7 +18,7 @@ import { CachedIterable, mapContextSync } from "fluent";
*/
export default class ReactLocalization {
constructor(messages) {
this.contexts = new CachedIterable(messages);
this.contexts = CachedSyncIterable.from(messages);
this.subs = new Set();
}

Expand All @@ -39,7 +40,7 @@ export default class ReactLocalization {
* Set a new `messages` iterable and trigger the retranslation.
*/
setMessages(messages) {
this.contexts = new CachedIterable(messages);
this.contexts = CachedSyncIterable.from(messages);

// Update all subscribed Localized components.
this.subs.forEach(comp => comp.relocalize());
Expand Down
4 changes: 4 additions & 0 deletions fluent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
iOS Safari 10.3+ and node 8.9+.

- Move CachedSyncIterable and CachedAsyncIterable to an external dependency.

They are now available from the `cached-iterable` package.

## fluent 0.6.4 (April 11, 2018)

- Minor optimization to bidirectionality isolation
Expand Down
1 change: 1 addition & 0 deletions fluent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"node": ">=8.9.0"
},
"devDependencies": {
"cached-iterable": "^0.2.0",
"sinon": "^4.2.2"
}
}
109 changes: 0 additions & 109 deletions fluent/src/cached_iterable.js

This file was deleted.

1 change: 0 additions & 1 deletion fluent/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export {
FluentDateTime as MessageDateTimeArgument,
} from "./types";

export { CachedSyncIterable, CachedAsyncIterable } from "./cached_iterable";
export { mapContextSync, mapContextAsync } from "./fallback";

export { ftl } from "./util";
Loading

0 comments on commit d849a8f

Please sign in to comment.