Skip to content

Commit 3e05317

Browse files
authored
Add the cached-iterable dependency (#260)
1 parent 80fb3f2 commit 3e05317

17 files changed

+50
-401
lines changed

fluent-dom/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
88
iOS Safari 10.3+ and node 8.9+.
99

10+
- Add the `cached-iterable` runtime dependency.
11+
12+
`CachedAsyncIterable` is now available from its own package rather than
13+
from the `fluent` package.
14+
1015
## fluent-dom 0.3.0
1116

1217
- Refactor the overlay sanitization methods into separate functions. (#189)

fluent-dom/makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PACKAGE := fluent-dom
22
GLOBAL := FluentDOM
3+
DEPS := cached-iterable:CachedIterable
34

45
include ../common.mk
56

@@ -11,6 +12,7 @@ $(PACKAGE).js: $(SOURCES)
1112
--banner "/* $(PACKAGE)@$(VERSION) */" \
1213
--amd.id $(PACKAGE) \
1314
--name $(GLOBAL) \
15+
--globals $(DEPS) \
1416
--output.file $@
1517
@echo -e " $(OK) $@ built"
1618

@@ -20,6 +22,7 @@ compat.js: $(SOURCES)
2022
--banner "/* $(PACKAGE)@$(VERSION) */" \
2123
--amd.id $(PACKAGE) \
2224
--name $(GLOBAL) \
25+
--globals $(DEPS) \
2326
--output.file $@
2427
@echo -e " $(OK) $@ built"
2528

fluent-dom/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@
4040
},
4141
"devDependencies": {
4242
"jsdom": "^11.6.2"
43+
},
44+
"dependencies": {
45+
"cached-iterable": "^0.2.1"
4346
}
4447
}

fluent-dom/src/localization.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
22
/* global console */
33

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

66
/**
77
* The `Localization` class is a central high-level API for vanilla
@@ -20,8 +20,8 @@ export default class Localization {
2020
constructor(resourceIds = [], generateMessages) {
2121
this.resourceIds = resourceIds;
2222
this.generateMessages = generateMessages;
23-
this.ctxs =
24-
new CachedAsyncIterable(this.generateMessages(this.resourceIds));
23+
this.ctxs = CachedAsyncIterable.from(
24+
this.generateMessages(this.resourceIds));
2525
}
2626

2727
addResourceIds(resourceIds) {
@@ -154,8 +154,8 @@ export default class Localization {
154154
* that language negotiation or available resources changed.
155155
*/
156156
onChange() {
157-
this.ctxs =
158-
new CachedAsyncIterable(this.generateMessages(this.resourceIds));
157+
this.ctxs = CachedAsyncIterable.from(
158+
this.generateMessages(this.resourceIds));
159159
this.ctxs.touchNext(2);
160160
}
161161
}

fluent-gecko/xpcom_config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import nodeResolve from 'rollup-plugin-node-resolve';
12
import bundleConfig from '../bundle_config';
23

34
const version = require('../fluent-dom/package.json').version;
@@ -24,5 +25,8 @@ export default Object.assign({}, bundleConfig, {
2425
* limitations under the License.
2526
*/\n\n`,
2627
intro: `/* fluent-dom@${version} */`,
27-
}
28+
},
29+
plugins: [
30+
nodeResolve(),
31+
]
2832
});

fluent-react/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
88
iOS Safari 10.3+ and node 8.9+.
99

10+
- Add the `cached-iterable` runtime dependency.
11+
12+
`CachedSyncIterable` is now available from its own package rather than
13+
from the `fluent` package.
14+
1015
## fluent-react 0.7.0 (May 18, 2018)
1116

1217
- Protect void elements against translated text content. (#174)

fluent-react/compat_config.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ export default {
1111
plugins: [
1212
...babelConfig.plugins,
1313
["babel-plugin-transform-rename-import", {
14-
original: "fluent",
15-
replacement: "fluent/compat",
14+
replacements: [
15+
{
16+
original: "fluent",
17+
replacement: "fluent/compat",
18+
},
19+
{
20+
original: "cached-iterable",
21+
replacement: "cached-iterable/compat",
22+
},
23+
]
1624
}],
1725
]
1826
}),

fluent-react/makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PACKAGE := fluent-react
22
GLOBAL := FluentReact
3-
DEPS := fluent:Fluent,react:React,prop-types:PropTypes
3+
DEPS := fluent:Fluent,cached-iterable:CachedIterable,react:React,prop-types:PropTypes
44

55
include ../common.mk
66

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

fluent-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"node": ">=8.9.0"
4747
},
4848
"dependencies": {
49+
"cached-iterable": "^0.2.1",
4950
"fluent": "^0.4.0 || ^0.6.0",
5051
"prop-types": "^15.6.0"
5152
},

fluent-react/src/localization.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { CachedIterable, mapContextSync } from "fluent";
1+
import { mapContextSync } from "fluent";
2+
import { CachedSyncIterable } from "cached-iterable";
23

34
/*
45
* `ReactLocalization` handles translation formatting and fallback.
@@ -17,7 +18,7 @@ import { CachedIterable, mapContextSync } from "fluent";
1718
*/
1819
export default class ReactLocalization {
1920
constructor(messages) {
20-
this.contexts = new CachedIterable(messages);
21+
this.contexts = CachedSyncIterable.from(messages);
2122
this.subs = new Set();
2223
}
2324

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

4445
// Update all subscribed Localized components.
4546
this.subs.forEach(comp => comp.relocalize());

fluent/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
Currently supported are: Firefox 52+, Chrome 55+, Edge 15+, Safari 10.1+,
88
iOS Safari 10.3+ and node 8.9+.
99

10+
- Move CachedSyncIterable and CachedAsyncIterable to an external dependency.
11+
12+
They are now available from the `cached-iterable` package.
13+
1014
## fluent 0.6.4 (April 11, 2018)
1115

1216
- Minor optimization to bidirectionality isolation

fluent/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"node": ">=8.9.0"
4545
},
4646
"devDependencies": {
47+
"cached-iterable": "^0.2.1",
4748
"sinon": "^4.2.2"
4849
}
4950
}

fluent/src/cached_iterable.js

Lines changed: 0 additions & 109 deletions
This file was deleted.

fluent/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export {
1616
FluentDateTime as MessageDateTimeArgument,
1717
} from "./types";
1818

19-
export { CachedSyncIterable, CachedAsyncIterable } from "./cached_iterable";
2019
export { mapContextSync, mapContextAsync } from "./fallback";
2120

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

0 commit comments

Comments
 (0)