@just-web/react-intl 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-8ryhwtmA.mjs +42 -0
- package/dist/index.cjs +185 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +135 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -80
- package/src/react_intl_gizmo.tsx +33 -0
- package/cjs/index.d.ts +0 -3
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -19
- package/cjs/index.js.map +0 -1
- package/cjs/package.json +0 -3
- package/cjs/react-intl.d.ts +0 -2
- package/cjs/react-intl.d.ts.map +0 -1
- package/cjs/react-intl.js +0 -18
- package/cjs/react-intl.js.map +0 -1
- package/cjs/react_intl_gizmo.d.ts +0 -27
- package/cjs/react_intl_gizmo.d.ts.map +0 -1
- package/cjs/react_intl_gizmo.js +0 -31
- package/cjs/react_intl_gizmo.js.map +0 -1
- package/esm/index.d.ts +0 -3
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -3
- package/esm/index.js.map +0 -1
- package/esm/react-intl.d.ts +0 -2
- package/esm/react-intl.d.ts.map +0 -1
- package/esm/react-intl.js +0 -2
- package/esm/react-intl.js.map +0 -1
- package/esm/react_intl_gizmo.d.ts +0 -27
- package/esm/react_intl_gizmo.d.ts.map +0 -1
- package/esm/react_intl_gizmo.js +0 -28
- package/esm/react_intl_gizmo.js.map +0 -1
- package/ts/react_intl_gizmo.tsx +0 -35
- /package/{ts → src}/index.ts +0 -0
- /package/{ts → src}/react-intl.ts +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (all, symbols) => {
|
|
7
|
+
let target = {};
|
|
8
|
+
for (var name in all) {
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (symbols) {
|
|
15
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: ((k) => from[k]).bind(null, key),
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
34
|
+
if (symbols) {
|
|
35
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
36
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
37
|
+
}
|
|
38
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { __reExport as n, __export as t };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (all, symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) {
|
|
11
|
+
__defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (symbols) {
|
|
17
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
24
|
+
key = keys[i];
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: ((k) => from[k]).bind(null, key),
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
36
|
+
if (symbols) {
|
|
37
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
38
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
39
|
+
}
|
|
40
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
41
|
+
};
|
|
42
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
43
|
+
value: mod,
|
|
44
|
+
enumerable: true
|
|
45
|
+
}) : target, mod));
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
let __just_web_formatjs = require("@just-web/formatjs");
|
|
49
|
+
let react = require("react");
|
|
50
|
+
react = __toESM(react);
|
|
51
|
+
let react_intl = require("react-intl");
|
|
52
|
+
|
|
53
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.js
|
|
54
|
+
function define(plugin) {
|
|
55
|
+
return plugin;
|
|
56
|
+
}
|
|
57
|
+
function defineDeps() {
|
|
58
|
+
return {
|
|
59
|
+
require: defineDeps,
|
|
60
|
+
optional: defineDeps
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
define.require = defineDeps;
|
|
64
|
+
define.optional = defineDeps;
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.7/node_modules/type-plus/esm/type-guard/is_type.js
|
|
68
|
+
function isType(subject, validator) {
|
|
69
|
+
return validator ? !!validator(subject) : true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated use `isType<T>()` or `testType.true<T>()` instead
|
|
73
|
+
*/
|
|
74
|
+
isType.t = (subject) => subject === void 0 || subject === true;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated use `isType<T>()` or `testType.false<T>()` instead
|
|
77
|
+
*/
|
|
78
|
+
isType.f = (subject) => subject === void 0 || subject === false;
|
|
79
|
+
function isNever(_subject) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
isType.never = isNever;
|
|
83
|
+
/**
|
|
84
|
+
* Are types A and B equals/not equals.
|
|
85
|
+
* Easier to use than `isType.t<>()` and `isType.f<>()`,
|
|
86
|
+
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
87
|
+
*
|
|
88
|
+
* @deprecated use `testType.equal()` instead
|
|
89
|
+
*/
|
|
90
|
+
isType.equal = () => {};
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/incubate.js
|
|
94
|
+
const closableApps = /* @__PURE__ */ new Map();
|
|
95
|
+
function addCloser(app, closer) {
|
|
96
|
+
if (typeof closer === "function") {
|
|
97
|
+
const closers = closableApps.get(app) ?? [];
|
|
98
|
+
closers.push(closer);
|
|
99
|
+
closableApps.set(app, closers);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function incubate(base) {
|
|
103
|
+
const dependencies = [];
|
|
104
|
+
if (base) dependencies.push({ instance: base });
|
|
105
|
+
let initFn;
|
|
106
|
+
return {
|
|
107
|
+
with(gizmo) {
|
|
108
|
+
dependencies.push({ gizmo });
|
|
109
|
+
return this;
|
|
110
|
+
},
|
|
111
|
+
merge(instance) {
|
|
112
|
+
dependencies.push({ instance });
|
|
113
|
+
return this;
|
|
114
|
+
},
|
|
115
|
+
init(initializer) {
|
|
116
|
+
initFn = initializer;
|
|
117
|
+
return this;
|
|
118
|
+
},
|
|
119
|
+
async create(start) {
|
|
120
|
+
const result = { async load(_identifier) {
|
|
121
|
+
return result;
|
|
122
|
+
} };
|
|
123
|
+
for (const dep of dependencies) if (isType(dep, (d) => !!d.gizmo)) await injectGizmo(result, dep.gizmo);
|
|
124
|
+
else Object.assign(result, dep.instance);
|
|
125
|
+
if (initFn) addCloser(result, await initFn(result));
|
|
126
|
+
if (start) addCloser(result, await start(result));
|
|
127
|
+
delete result["load"];
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Invokes any cleanup functions of the gizmo and its dependents.
|
|
134
|
+
*
|
|
135
|
+
* The gizmo is not destroyed as in other languages,
|
|
136
|
+
* as there is no destructor or ability to tap into the garbage collector of JavaScript.
|
|
137
|
+
*
|
|
138
|
+
* But nonetheless, the cleanup functions are used to close resources such as network connections,
|
|
139
|
+
* strong map, cache, etc.
|
|
140
|
+
*
|
|
141
|
+
* The gizmo should not be used after cleanup.
|
|
142
|
+
*/
|
|
143
|
+
incubate.cleanup = (app) => {
|
|
144
|
+
const closers = closableApps.get(app);
|
|
145
|
+
if (closers) closers.forEach((c) => void c());
|
|
146
|
+
};
|
|
147
|
+
async function injectGizmo(result, gizmo) {
|
|
148
|
+
const gizmoResult = await gizmo.create(result);
|
|
149
|
+
if (Array.isArray(gizmoResult)) {
|
|
150
|
+
const [value, start] = gizmoResult;
|
|
151
|
+
if (start) addCloser(result, await start());
|
|
152
|
+
Object.assign(result, value);
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
Object.assign(result, gizmoResult);
|
|
156
|
+
return gizmoResult;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/react_intl_gizmo.tsx
|
|
161
|
+
const reactIntlGizmoFn = define((options) => ({
|
|
162
|
+
static: define.require().optional(),
|
|
163
|
+
async create(ctx) {
|
|
164
|
+
const formatjs = await getFormatjs(ctx, options);
|
|
165
|
+
return [{ react_intl: { intl: formatjs.intl } }, () => ctx.react.providers.register(({ children }) => /* @__PURE__ */ react.default.createElement(react_intl.RawIntlProvider, { value: formatjs.intl }, children))];
|
|
166
|
+
}
|
|
167
|
+
}));
|
|
168
|
+
async function getFormatjs(ctx, options) {
|
|
169
|
+
if (ctx.formatjs) return ctx.formatjs;
|
|
170
|
+
if (!options) throw new Error("options is required when there is no formatjs gizmo");
|
|
171
|
+
return (await incubate().with((0, __just_web_formatjs.formatJSGizmoFn)(options)).create()).formatjs;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/index.ts
|
|
176
|
+
var src_exports = /* @__PURE__ */ __export({ reactIntlGizmoFn: () => reactIntlGizmoFn });
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
exports.reactIntlGizmoFn = reactIntlGizmoFn;
|
|
180
|
+
Object.keys(react_intl).forEach(function (k) {
|
|
181
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function () { return react_intl[k]; }
|
|
184
|
+
});
|
|
185
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _just_web_formatjs0 from "@just-web/formatjs";
|
|
2
|
+
import { FormatJSGizmoOptions } from "@just-web/formatjs";
|
|
3
|
+
import * as _just_web_app0 from "@just-web/app";
|
|
4
|
+
import { define } from "@just-web/app";
|
|
5
|
+
import { IntlShape } from "react-intl";
|
|
6
|
+
export * from "react-intl";
|
|
7
|
+
|
|
8
|
+
//#region rolldown:runtime
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/react_intl_gizmo.d.ts
|
|
11
|
+
type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
12
|
+
declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => _just_web_app0.GizmoStatic<_just_web_app0.DepBuilder<ReactGizmo, {
|
|
13
|
+
formatjs: {
|
|
14
|
+
intl: _just_web_formatjs0.IntlShape<unknown>;
|
|
15
|
+
};
|
|
16
|
+
}>, [{
|
|
17
|
+
react_intl: {
|
|
18
|
+
intl: IntlShape;
|
|
19
|
+
};
|
|
20
|
+
}, () => any]>;
|
|
21
|
+
type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
22
|
+
declare namespace index_d_exports {
|
|
23
|
+
export { ReactIntlGizmo, ReactIntlGizmoOptions, reactIntlGizmoFn };
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ReactIntlGizmo, ReactIntlGizmoOptions, reactIntlGizmoFn };
|
|
27
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/react_intl_gizmo.tsx","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAMY,oCAAoC,qBAAqB;cAExD,yCAA4B,sBAAA,mBAOJ,cAAA,CAPI,2BAAA,WAAA;;UAAA,mBAAA,CAAA;;;;UAOb;;;KAWhB,cAAA,GAAiB,MAAA,CAAO,aAAa"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { n as __reExport, t as __export } from "./chunk-8ryhwtmA.mjs";
|
|
2
|
+
import * as _just_web_formatjs0 from "@just-web/formatjs";
|
|
3
|
+
import { FormatJSGizmoOptions } from "@just-web/formatjs";
|
|
4
|
+
import { IntlShape } from "react-intl";
|
|
5
|
+
import * as _just_web_app0 from "@just-web/app";
|
|
6
|
+
import { define } from "@just-web/app";
|
|
7
|
+
export * from "react-intl";
|
|
8
|
+
|
|
9
|
+
//#region src/react_intl_gizmo.d.ts
|
|
10
|
+
type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
11
|
+
declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => _just_web_app0.GizmoStatic<_just_web_app0.DepBuilder<ReactGizmo, {
|
|
12
|
+
formatjs: {
|
|
13
|
+
intl: _just_web_formatjs0.IntlShape<unknown>;
|
|
14
|
+
};
|
|
15
|
+
}>, [{
|
|
16
|
+
react_intl: {
|
|
17
|
+
intl: IntlShape;
|
|
18
|
+
};
|
|
19
|
+
}, () => any]>;
|
|
20
|
+
type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
21
|
+
declare namespace index_d_exports {
|
|
22
|
+
export { ReactIntlGizmo, ReactIntlGizmoOptions, reactIntlGizmoFn };
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ReactIntlGizmo, ReactIntlGizmoOptions, reactIntlGizmoFn };
|
|
26
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/react_intl_gizmo.tsx","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAMY,oCAAoC,qBAAqB;cAExD,yCAA4B,sBAAA,mBAOJ,cAAA,CAPI,2BAAA,WAAA;;UAAA,mBAAA,CAAA;;;;IAF7B,IAAA,EASgB,SAThB;EAEC,CAAA;CAA4B,EAAA,GAAA,GAAA,GAAA,CAAA,CAAA;AAAA,KAkB7B,cAAA,GAAiB,MAAA,CAAO,KAlBK,CAAA,OAkBQ,gBAlBR,CAAA;AAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { n as __reExport, t as __export } from "./chunk-8ryhwtmA.mjs";
|
|
2
|
+
import { formatJSGizmoFn } from "@just-web/formatjs";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { RawIntlProvider } from "react-intl";
|
|
5
|
+
|
|
6
|
+
export * from "react-intl"
|
|
7
|
+
|
|
8
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.js
|
|
9
|
+
function define(plugin) {
|
|
10
|
+
return plugin;
|
|
11
|
+
}
|
|
12
|
+
function defineDeps() {
|
|
13
|
+
return {
|
|
14
|
+
require: defineDeps,
|
|
15
|
+
optional: defineDeps
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
define.require = defineDeps;
|
|
19
|
+
define.optional = defineDeps;
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.7/node_modules/type-plus/esm/type-guard/is_type.js
|
|
23
|
+
function isType(subject, validator) {
|
|
24
|
+
return validator ? !!validator(subject) : true;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use `isType<T>()` or `testType.true<T>()` instead
|
|
28
|
+
*/
|
|
29
|
+
isType.t = (subject) => subject === void 0 || subject === true;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use `isType<T>()` or `testType.false<T>()` instead
|
|
32
|
+
*/
|
|
33
|
+
isType.f = (subject) => subject === void 0 || subject === false;
|
|
34
|
+
function isNever(_subject) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
isType.never = isNever;
|
|
38
|
+
/**
|
|
39
|
+
* Are types A and B equals/not equals.
|
|
40
|
+
* Easier to use than `isType.t<>()` and `isType.f<>()`,
|
|
41
|
+
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
42
|
+
*
|
|
43
|
+
* @deprecated use `testType.equal()` instead
|
|
44
|
+
*/
|
|
45
|
+
isType.equal = () => {};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/incubate.js
|
|
49
|
+
const closableApps = /* @__PURE__ */ new Map();
|
|
50
|
+
function addCloser(app, closer) {
|
|
51
|
+
if (typeof closer === "function") {
|
|
52
|
+
const closers = closableApps.get(app) ?? [];
|
|
53
|
+
closers.push(closer);
|
|
54
|
+
closableApps.set(app, closers);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function incubate(base) {
|
|
58
|
+
const dependencies = [];
|
|
59
|
+
if (base) dependencies.push({ instance: base });
|
|
60
|
+
let initFn;
|
|
61
|
+
return {
|
|
62
|
+
with(gizmo) {
|
|
63
|
+
dependencies.push({ gizmo });
|
|
64
|
+
return this;
|
|
65
|
+
},
|
|
66
|
+
merge(instance) {
|
|
67
|
+
dependencies.push({ instance });
|
|
68
|
+
return this;
|
|
69
|
+
},
|
|
70
|
+
init(initializer) {
|
|
71
|
+
initFn = initializer;
|
|
72
|
+
return this;
|
|
73
|
+
},
|
|
74
|
+
async create(start) {
|
|
75
|
+
const result = { async load(_identifier) {
|
|
76
|
+
return result;
|
|
77
|
+
} };
|
|
78
|
+
for (const dep of dependencies) if (isType(dep, (d) => !!d.gizmo)) await injectGizmo(result, dep.gizmo);
|
|
79
|
+
else Object.assign(result, dep.instance);
|
|
80
|
+
if (initFn) addCloser(result, await initFn(result));
|
|
81
|
+
if (start) addCloser(result, await start(result));
|
|
82
|
+
delete result["load"];
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Invokes any cleanup functions of the gizmo and its dependents.
|
|
89
|
+
*
|
|
90
|
+
* The gizmo is not destroyed as in other languages,
|
|
91
|
+
* as there is no destructor or ability to tap into the garbage collector of JavaScript.
|
|
92
|
+
*
|
|
93
|
+
* But nonetheless, the cleanup functions are used to close resources such as network connections,
|
|
94
|
+
* strong map, cache, etc.
|
|
95
|
+
*
|
|
96
|
+
* The gizmo should not be used after cleanup.
|
|
97
|
+
*/
|
|
98
|
+
incubate.cleanup = (app) => {
|
|
99
|
+
const closers = closableApps.get(app);
|
|
100
|
+
if (closers) closers.forEach((c) => void c());
|
|
101
|
+
};
|
|
102
|
+
async function injectGizmo(result, gizmo) {
|
|
103
|
+
const gizmoResult = await gizmo.create(result);
|
|
104
|
+
if (Array.isArray(gizmoResult)) {
|
|
105
|
+
const [value, start] = gizmoResult;
|
|
106
|
+
if (start) addCloser(result, await start());
|
|
107
|
+
Object.assign(result, value);
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
Object.assign(result, gizmoResult);
|
|
111
|
+
return gizmoResult;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/react_intl_gizmo.tsx
|
|
116
|
+
const reactIntlGizmoFn = define((options) => ({
|
|
117
|
+
static: define.require().optional(),
|
|
118
|
+
async create(ctx) {
|
|
119
|
+
const formatjs = await getFormatjs(ctx, options);
|
|
120
|
+
return [{ react_intl: { intl: formatjs.intl } }, () => ctx.react.providers.register(({ children }) => /* @__PURE__ */ React.createElement(RawIntlProvider, { value: formatjs.intl }, children))];
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
async function getFormatjs(ctx, options) {
|
|
124
|
+
if (ctx.formatjs) return ctx.formatjs;
|
|
125
|
+
if (!options) throw new Error("options is required when there is no formatjs gizmo");
|
|
126
|
+
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/index.ts
|
|
131
|
+
var src_exports = /* @__PURE__ */ __export({ reactIntlGizmoFn: () => reactIntlGizmoFn });
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
export { reactIntlGizmoFn };
|
|
135
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.js","../../../node_modules/.pnpm/type-plus@8.0.0-beta.7/node_modules/type-plus/esm/type-guard/is_type.js","../../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/incubate.js","../src/react_intl_gizmo.tsx","../src/index.ts"],"sourcesContent":["export function define(plugin) {\n return plugin;\n}\nfunction defineDeps() {\n return {\n require: defineDeps,\n optional: defineDeps,\n };\n}\ndefine.require = defineDeps;\ndefine.optional = defineDeps;\n//# sourceMappingURL=define.js.map","export function isType(subject, validator) {\n return validator ? !!validator(subject) : true;\n}\n/**\n * @deprecated use `isType<T>()` or `testType.true<T>()` instead\n */\nisType.t = (subject) => subject === undefined || subject === true;\n/**\n * @deprecated use `isType<T>()` or `testType.false<T>()` instead\n */\nisType.f = (subject) => subject === undefined || subject === false;\nfunction isNever(_subject) {\n return true;\n}\nisType.never = isNever;\n/**\n * Are types A and B equals/not equals.\n * Easier to use than `isType.t<>()` and `isType.f<>()`,\n * when doing type level only equality comparison as you don't have to import `Equal<>`.\n *\n * @deprecated use `testType.equal()` instead\n */\nisType.equal = () => { };\n//# sourceMappingURL=is_type.js.map","import { isType } from 'type-plus';\nconst closableApps = new Map();\nfunction addCloser(app, closer) {\n if (typeof closer === 'function') {\n const closers = closableApps.get(app) ?? [];\n closers.push(closer);\n closableApps.set(app, closers);\n }\n}\nexport function incubate(base) {\n const dependencies = [];\n if (base)\n dependencies.push({ instance: base });\n let initFn;\n return {\n with(gizmo) {\n dependencies.push({ gizmo });\n return this;\n },\n merge(instance) {\n dependencies.push({ instance });\n return this;\n },\n init(initializer) {\n initFn = initializer;\n return this;\n },\n async create(start) {\n const result = {\n async load(_identifier) {\n return result;\n },\n };\n for (const dep of dependencies) {\n if (isType(dep, (d) => !!d.gizmo)) {\n await injectGizmo(result, dep.gizmo);\n }\n else {\n Object.assign(result, dep.instance);\n }\n }\n if (initFn) {\n addCloser(result, await initFn(result));\n }\n if (start) {\n addCloser(result, await start(result));\n }\n // biome-ignore lint/performance/noDelete: specific implementation\n delete result['load'];\n return result;\n },\n };\n}\n/**\n * Invokes any cleanup functions of the gizmo and its dependents.\n *\n * The gizmo is not destroyed as in other languages,\n * as there is no destructor or ability to tap into the garbage collector of JavaScript.\n *\n * But nonetheless, the cleanup functions are used to close resources such as network connections,\n * strong map, cache, etc.\n *\n * The gizmo should not be used after cleanup.\n */\nincubate.cleanup = (app) => {\n const closers = closableApps.get(app);\n if (closers) {\n closers.forEach((c) => void c());\n }\n};\nasync function injectGizmo(result, gizmo) {\n const gizmoResult = await gizmo.create(result);\n if (Array.isArray(gizmoResult)) {\n const [value, start] = gizmoResult;\n if (start) {\n addCloser(result, await start());\n }\n Object.assign(result, value);\n return value;\n }\n Object.assign(result, gizmoResult);\n return gizmoResult;\n}\n//# sourceMappingURL=incubate.js.map","import { define, incubate } from '@just-web/app'\nimport { type FormatJSGizmo, type FormatJSGizmoOptions, formatJSGizmoFn } from '@just-web/formatjs'\nimport React from 'react'\nimport { type IntlShape, RawIntlProvider } from 'react-intl'\nimport type { ReactGizmo } from '../../react/dist/hooks/store'\n\nexport type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>\n\nexport const reactIntlGizmoFn = define(<T = string>(options?: ReactIntlGizmoOptions<T>) => ({\n\tstatic: define.require<ReactGizmo>().optional<FormatJSGizmo>(),\n\tasync create(ctx: ReactGizmo & Partial<FormatJSGizmo>) {\n\t\tconst formatjs = await getFormatjs(ctx, options)\n\t\treturn [\n\t\t\t{\n\t\t\t\treact_intl: {\n\t\t\t\t\tintl: formatjs.intl as IntlShape\n\t\t\t\t}\n\t\t\t},\n\t\t\t() =>\n\t\t\t\tctx.react.providers.register(({ children }) => (\n\t\t\t\t\t<RawIntlProvider value={formatjs.intl as IntlShape}>{children}</RawIntlProvider>\n\t\t\t\t))\n\t\t]\n\t}\n}))\n\nexport type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>\n\nasync function getFormatjs(ctx: Partial<FormatJSGizmo>, options: ReactIntlGizmoOptions<any> | undefined) {\n\tif (ctx.formatjs) return ctx.formatjs\n\tif (!options) throw new Error('options is required when there is no formatjs gizmo')\n\treturn (await incubate().with(formatJSGizmoFn(options)).create()).formatjs\n}\n","export * from './react_intl_gizmo.js'\nexport * from './react-intl.js'\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;;AAAA,SAAgB,OAAO,QAAQ;AAC3B,QAAO;;AAEX,SAAS,aAAa;AAClB,QAAO;EACH,SAAS;EACT,UAAU;EACb;;AAEL,OAAO,UAAU;AACjB,OAAO,WAAW;;;;ACVlB,SAAgB,OAAO,SAAS,WAAW;AACvC,QAAO,YAAY,CAAC,CAAC,UAAU,QAAQ,GAAG;;;;;AAK9C,OAAO,KAAK,YAAY,YAAY,UAAa,YAAY;;;;AAI7D,OAAO,KAAK,YAAY,YAAY,UAAa,YAAY;AAC7D,SAAS,QAAQ,UAAU;AACvB,QAAO;;AAEX,OAAO,QAAQ;;;;;;;;AAQf,OAAO,cAAc;;;;ACrBrB,MAAM,+BAAe,IAAI,KAAK;AAC9B,SAAS,UAAU,KAAK,QAAQ;AAC5B,KAAI,OAAO,WAAW,YAAY;EAC9B,MAAM,UAAU,aAAa,IAAI,IAAI,IAAI,EAAE;AAC3C,UAAQ,KAAK,OAAO;AACpB,eAAa,IAAI,KAAK,QAAQ;;;AAGtC,SAAgB,SAAS,MAAM;CAC3B,MAAM,eAAe,EAAE;AACvB,KAAI,KACA,cAAa,KAAK,EAAE,UAAU,MAAM,CAAC;CACzC,IAAI;AACJ,QAAO;EACH,KAAK,OAAO;AACR,gBAAa,KAAK,EAAE,OAAO,CAAC;AAC5B,UAAO;;EAEX,MAAM,UAAU;AACZ,gBAAa,KAAK,EAAE,UAAU,CAAC;AAC/B,UAAO;;EAEX,KAAK,aAAa;AACd,YAAS;AACT,UAAO;;EAEX,MAAM,OAAO,OAAO;GAChB,MAAM,SAAS,EACX,MAAM,KAAK,aAAa;AACpB,WAAO;MAEd;AACD,QAAK,MAAM,OAAO,aACd,KAAI,OAAO,MAAM,MAAM,CAAC,CAAC,EAAE,MAAM,CAC7B,OAAM,YAAY,QAAQ,IAAI,MAAM;OAGpC,QAAO,OAAO,QAAQ,IAAI,SAAS;AAG3C,OAAI,OACA,WAAU,QAAQ,MAAM,OAAO,OAAO,CAAC;AAE3C,OAAI,MACA,WAAU,QAAQ,MAAM,MAAM,OAAO,CAAC;AAG1C,UAAO,OAAO;AACd,UAAO;;EAEd;;;;;;;;;;;;;AAaL,SAAS,WAAW,QAAQ;CACxB,MAAM,UAAU,aAAa,IAAI,IAAI;AACrC,KAAI,QACA,SAAQ,SAAS,MAAM,KAAK,GAAG,CAAC;;AAGxC,eAAe,YAAY,QAAQ,OAAO;CACtC,MAAM,cAAc,MAAM,MAAM,OAAO,OAAO;AAC9C,KAAI,MAAM,QAAQ,YAAY,EAAE;EAC5B,MAAM,CAAC,OAAO,SAAS;AACvB,MAAI,MACA,WAAU,QAAQ,MAAM,OAAO,CAAC;AAEpC,SAAO,OAAO,QAAQ,MAAM;AAC5B,SAAO;;AAEX,QAAO,OAAO,QAAQ,YAAY;AAClC,QAAO;;;;;ACzEX,MAAa,mBAAmB,QAAoB,aAAwC;CAC3F,QAAQ,OAAO,SAAqB,CAAC,UAAyB;CAC9D,MAAM,OAAO,KAA0C;EACtD,MAAM,WAAW,MAAM,YAAY,KAAK,QAAQ;AAChD,SAAO,CACN,EACC,YAAY,EACX,MAAM,SAAS,MACf,EACD,QAEA,IAAI,MAAM,UAAU,UAAU,EAAE,eAC/B,oCAAC,mBAAgB,OAAO,SAAS,QAAoB,SAA2B,CAC/E,CACH;;CAEF,EAAE;AAIH,eAAe,YAAY,KAA6B,SAAiD;AACxG,KAAI,IAAI,SAAU,QAAO,IAAI;AAC7B,KAAI,CAAC,QAAS,OAAM,IAAI,MAAM,sDAAsD;AACpF,SAAQ,MAAM,UAAU,CAAC,KAAK,gBAAgB,QAAQ,CAAC,CAAC,QAAQ,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@just-web/react-intl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "react-intl gizmo for just-web applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"just-web",
|
|
@@ -26,115 +26,71 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"import": {
|
|
29
|
-
"types": "./
|
|
30
|
-
"default": "./
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
31
|
},
|
|
32
32
|
"require": {
|
|
33
|
-
"types": "./
|
|
34
|
-
"default": "./
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
35
|
},
|
|
36
|
-
"default": "./
|
|
37
|
-
},
|
|
38
|
-
"./testing": {
|
|
39
|
-
"import": {
|
|
40
|
-
"types": "./esm/testing/index.d.ts",
|
|
41
|
-
"default": "./esm/testing/index.js"
|
|
42
|
-
},
|
|
43
|
-
"require": {
|
|
44
|
-
"types": "./cjs/testing/index.d.ts",
|
|
45
|
-
"require": "./cjs/testing/index.js"
|
|
46
|
-
},
|
|
47
|
-
"default": "./esm/testing/index.js"
|
|
36
|
+
"default": "./dist/index.mjs"
|
|
48
37
|
}
|
|
49
38
|
},
|
|
50
|
-
"main": "./
|
|
51
|
-
"module": "./
|
|
52
|
-
"types": "./
|
|
39
|
+
"main": "./dist/index.cjs",
|
|
40
|
+
"module": "./dist/index.mjs",
|
|
41
|
+
"types": "./dist/index.d.mts",
|
|
53
42
|
"files": [
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"testing",
|
|
57
|
-
"ts",
|
|
43
|
+
"dist",
|
|
44
|
+
"src",
|
|
58
45
|
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*",
|
|
59
46
|
"!**/*.stories.*"
|
|
60
47
|
],
|
|
61
48
|
"dependencies": {
|
|
62
|
-
"@just-web/formatjs": "^1.
|
|
49
|
+
"@just-web/formatjs": "^1.1.2",
|
|
63
50
|
"react-intl": "^6.4.2"
|
|
64
51
|
},
|
|
65
52
|
"devDependencies": {
|
|
66
|
-
"@just-web/app": "^7.
|
|
67
|
-
"@repobuddy/
|
|
68
|
-
"@repobuddy/typescript": "^1.2.0",
|
|
53
|
+
"@just-web/app": "^7.3.2",
|
|
54
|
+
"@repobuddy/typescript": "^2.1.0",
|
|
69
55
|
"@size-limit/preset-small-lib": "~8.2.0",
|
|
70
|
-
"@storybook/
|
|
71
|
-
"@storybook/addon-
|
|
72
|
-
"@storybook/addon-
|
|
73
|
-
"@storybook/
|
|
74
|
-
"@storybook/addon-essentials": "^7.0.6",
|
|
75
|
-
"@storybook/addon-interactions": "^7.0.6",
|
|
76
|
-
"@storybook/addon-links": "^7.0.6",
|
|
77
|
-
"@storybook/addon-measure": "^7.0.6",
|
|
78
|
-
"@storybook/addon-outline": "^7.0.6",
|
|
79
|
-
"@storybook/addon-storysource": "^7.0.6",
|
|
80
|
-
"@storybook/addon-styling": "^1.0.1",
|
|
81
|
-
"@storybook/addons": "^7.0.6",
|
|
82
|
-
"@storybook/channel-postmessage": "^7.0.6",
|
|
83
|
-
"@storybook/channel-websocket": "^7.0.6",
|
|
84
|
-
"@storybook/client-api": "^7.0.6",
|
|
85
|
-
"@storybook/preview-web": "^7.0.6",
|
|
86
|
-
"@storybook/react": "^7.0.6",
|
|
87
|
-
"@storybook/react-vite": "7.1.0",
|
|
88
|
-
"@storybook/test-runner": "^0.11.0",
|
|
89
|
-
"@storybook/testing-library": "^0.2.0",
|
|
90
|
-
"@types/jest": "^29.5.1",
|
|
56
|
+
"@storybook-community/storybook-dark-mode": "^7.1.0",
|
|
57
|
+
"@storybook/addon-docs": "^10.1.11",
|
|
58
|
+
"@storybook/addon-links": "^10.1.11",
|
|
59
|
+
"@storybook/react-vite": "^10.1.11",
|
|
91
60
|
"@types/react": "^18.0.0",
|
|
92
61
|
"@types/react-dom": "^18.0.9",
|
|
93
|
-
"@
|
|
94
|
-
"@
|
|
95
|
-
"@
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"jest": "^29.5.0",
|
|
100
|
-
"jest-watch-suspend": "^1.1.2",
|
|
101
|
-
"jest-watch-toggle-config-2": "^2.1.0",
|
|
102
|
-
"jest-watch-typeahead": "^2.2.2",
|
|
103
|
-
"npm-run-all": "^4.1.5",
|
|
62
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
63
|
+
"@vitest/browser": "^4.0.17",
|
|
64
|
+
"@vitest/browser-playwright": "^4.0.17",
|
|
65
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
66
|
+
"assertron": "^11.5.2",
|
|
67
|
+
"npm-run-all2": "^5.0.0",
|
|
104
68
|
"react": "^18.0.0",
|
|
105
69
|
"react-dom": "^18.0.0",
|
|
106
|
-
"repobuddy": "^1.0.1",
|
|
107
70
|
"rimraf": "~5.0.0",
|
|
108
|
-
"rollup-plugin-node-externals": "^6.0.0",
|
|
109
71
|
"size-limit": "~8.2.0",
|
|
110
|
-
"storybook": "
|
|
111
|
-
"
|
|
112
|
-
"ts-jest": "^29.1.0",
|
|
113
|
-
"tslib": "^2.5.0",
|
|
72
|
+
"storybook": "^10.1.11",
|
|
73
|
+
"tsdown": "^0.17.4",
|
|
114
74
|
"type-plus": "^7.0.1",
|
|
115
75
|
"typescript": "^5.0.4",
|
|
116
|
-
"vite": "^
|
|
117
|
-
"
|
|
76
|
+
"vite": "^7.2.7",
|
|
77
|
+
"vitest": "^4.0.17",
|
|
78
|
+
"@just-web/react": "^9.1.0"
|
|
118
79
|
},
|
|
119
80
|
"peerDependencies": {
|
|
120
81
|
"@just-web/react": "^9.0.0",
|
|
121
82
|
"react": "^16 || ^17 || ^18"
|
|
122
83
|
},
|
|
123
84
|
"scripts": {
|
|
124
|
-
"build": "
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"clean": "rimraf cjs esm coverage tslib --glob *.tsbuildinfo",
|
|
129
|
-
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --coverage",
|
|
130
|
-
"depcheck": "depcheck",
|
|
131
|
-
"lint": "cross-env TIMING=1 eslint --ext=ts,tsx,js,yaml,yml .",
|
|
85
|
+
"build": "tsdown",
|
|
86
|
+
"check": "biome check",
|
|
87
|
+
"clean": "rimraf coverage dist --glob *.tsbuildinfo",
|
|
88
|
+
"coverage": "vitest run --coverage",
|
|
132
89
|
"nuke": "rimraf node_modules",
|
|
133
90
|
"sb": "storybook dev -p 6008",
|
|
134
|
-
"
|
|
135
|
-
"test": "
|
|
136
|
-
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --watch",
|
|
91
|
+
"test": "vitest run",
|
|
92
|
+
"test:watch": "vitest",
|
|
137
93
|
"w": "pnpm test:watch",
|
|
138
|
-
"verify": "npm-run-all -p build
|
|
94
|
+
"verify": "npm-run-all -p check build coverage -p size"
|
|
139
95
|
}
|
|
140
96
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { define, incubate } from '@just-web/app'
|
|
2
|
+
import { type FormatJSGizmo, type FormatJSGizmoOptions, formatJSGizmoFn } from '@just-web/formatjs'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { type IntlShape, RawIntlProvider } from 'react-intl'
|
|
5
|
+
import type { ReactGizmo } from '../../react/dist/hooks/store'
|
|
6
|
+
|
|
7
|
+
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>
|
|
8
|
+
|
|
9
|
+
export const reactIntlGizmoFn = define(<T = string>(options?: ReactIntlGizmoOptions<T>) => ({
|
|
10
|
+
static: define.require<ReactGizmo>().optional<FormatJSGizmo>(),
|
|
11
|
+
async create(ctx: ReactGizmo & Partial<FormatJSGizmo>) {
|
|
12
|
+
const formatjs = await getFormatjs(ctx, options)
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
react_intl: {
|
|
16
|
+
intl: formatjs.intl as IntlShape
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
() =>
|
|
20
|
+
ctx.react.providers.register(({ children }) => (
|
|
21
|
+
<RawIntlProvider value={formatjs.intl as IntlShape}>{children}</RawIntlProvider>
|
|
22
|
+
))
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}))
|
|
26
|
+
|
|
27
|
+
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>
|
|
28
|
+
|
|
29
|
+
async function getFormatjs(ctx: Partial<FormatJSGizmo>, options: ReactIntlGizmoOptions<any> | undefined) {
|
|
30
|
+
if (ctx.formatjs) return ctx.formatjs
|
|
31
|
+
if (!options) throw new Error('options is required when there is no formatjs gizmo')
|
|
32
|
+
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs
|
|
33
|
+
}
|
package/cjs/index.d.ts
DELETED
package/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
package/cjs/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./react_intl_gizmo.js"), exports);
|
|
18
|
-
__exportStar(require("./react-intl.js"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,kDAA+B"}
|
package/cjs/package.json
DELETED
package/cjs/react-intl.d.ts
DELETED
package/cjs/react-intl.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-intl.d.ts","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
package/cjs/react-intl.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("react-intl"), exports);
|
|
18
|
-
//# sourceMappingURL=react-intl.js.map
|
package/cjs/react-intl.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-intl.js","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { define } from '@just-web/app';
|
|
3
|
-
import { type FormatJSGizmoOptions } from '@just-web/formatjs';
|
|
4
|
-
import { type IntlShape } from 'react-intl';
|
|
5
|
-
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
6
|
-
export declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => import("@just-web/app").GizmoStatic<import("@just-web/app").DepBuilder<{
|
|
7
|
-
react: {
|
|
8
|
-
providers: {
|
|
9
|
-
register(Component: React.JSXElementConstructor<{
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
}>): void;
|
|
12
|
-
values(): IterableIterator<React.JSXElementConstructor<{
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}>>;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
}, {
|
|
18
|
-
formatjs: {
|
|
19
|
-
intl: import("@just-web/formatjs").IntlShape<unknown>;
|
|
20
|
-
};
|
|
21
|
-
}>, [{
|
|
22
|
-
react_intl: {
|
|
23
|
-
intl: IntlShape;
|
|
24
|
-
};
|
|
25
|
-
}, () => void]>;
|
|
26
|
-
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
27
|
-
//# sourceMappingURL=react_intl_gizmo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AAChD,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEnG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAEvE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;eAkB3B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
package/cjs/react_intl_gizmo.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reactIntlGizmoFn = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const app_1 = require("@just-web/app");
|
|
6
|
-
const formatjs_1 = require("@just-web/formatjs");
|
|
7
|
-
const react_intl_1 = require("react-intl");
|
|
8
|
-
exports.reactIntlGizmoFn = (0, app_1.define)(function (options) {
|
|
9
|
-
return {
|
|
10
|
-
static: app_1.define.require().optional(),
|
|
11
|
-
async create(ctx) {
|
|
12
|
-
const formatjs = await getFormatjs(ctx, options);
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
react_intl: {
|
|
16
|
-
intl: formatjs.intl
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
() => ctx.react.providers.register(({ children }) => (react_1.default.createElement(react_intl_1.RawIntlProvider, { value: formatjs.intl }, children)))
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
async function getFormatjs(ctx, options) {
|
|
25
|
-
if (ctx.formatjs)
|
|
26
|
-
return ctx.formatjs;
|
|
27
|
-
if (!options)
|
|
28
|
-
throw new Error('options is required when there is no formatjs gizmo');
|
|
29
|
-
return (await (0, app_1.incubate)().with((0, formatjs_1.formatJSGizmoFn)(options)).create()).formatjs;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=react_intl_gizmo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":";;;AAAA,iCAAyB;AACzB,uCAAgD;AAChD,iDAAmG;AAEnG,2CAA4D;AAI/C,QAAA,gBAAgB,GAAG,IAAA,YAAM,EAAC,UAAsB,OAAkC;IAC9F,OAAO;QACN,MAAM,EAAE,YAAM,CAAC,OAAO,EAAc,CAAC,QAAQ,EAAiB;QAC9D,KAAK,CAAC,MAAM,CAAC,GAAwC;YACpD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAChD,OAAO;gBACN;oBACC,UAAU,EAAE;wBACX,IAAI,EAAE,QAAQ,CAAC,IAAiB;qBAChC;iBACD;gBACD,GAAG,EAAE,CACJ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC9C,8BAAC,4BAAe,IAAC,KAAK,EAAE,QAAQ,CAAC,IAAiB,IAAG,QAAQ,CAAmB,CAChF,CAAC;aACH,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA;AAIF,KAAK,UAAU,WAAW,CAAC,GAA2B,EAAE,OAA+C;IACtG,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAA;IACrC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACpF,OAAO,CAAC,MAAM,IAAA,cAAQ,GAAE,CAAC,IAAI,CAAC,IAAA,0BAAe,EAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAA;AAC3E,CAAC"}
|
package/esm/index.d.ts
DELETED
package/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
package/esm/index.js
DELETED
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
package/esm/react-intl.d.ts
DELETED
package/esm/react-intl.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-intl.d.ts","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
package/esm/react-intl.js
DELETED
package/esm/react-intl.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-intl.js","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { define } from '@just-web/app';
|
|
3
|
-
import { type FormatJSGizmoOptions } from '@just-web/formatjs';
|
|
4
|
-
import { type IntlShape } from 'react-intl';
|
|
5
|
-
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
6
|
-
export declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => import("@just-web/app").GizmoStatic<import("@just-web/app").DepBuilder<{
|
|
7
|
-
react: {
|
|
8
|
-
providers: {
|
|
9
|
-
register(Component: React.JSXElementConstructor<{
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
}>): void;
|
|
12
|
-
values(): IterableIterator<React.JSXElementConstructor<{
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}>>;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
}, {
|
|
18
|
-
formatjs: {
|
|
19
|
-
intl: import("@just-web/formatjs").IntlShape<unknown>;
|
|
20
|
-
};
|
|
21
|
-
}>, [{
|
|
22
|
-
react_intl: {
|
|
23
|
-
intl: IntlShape;
|
|
24
|
-
};
|
|
25
|
-
}, () => void]>;
|
|
26
|
-
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
27
|
-
//# sourceMappingURL=react_intl_gizmo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AAChD,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEnG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAEvE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;eAkB3B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
package/esm/react_intl_gizmo.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { define, incubate } from '@just-web/app';
|
|
3
|
-
import { formatJSGizmoFn } from '@just-web/formatjs';
|
|
4
|
-
import { RawIntlProvider } from 'react-intl';
|
|
5
|
-
export const reactIntlGizmoFn = define(function (options) {
|
|
6
|
-
return {
|
|
7
|
-
static: define.require().optional(),
|
|
8
|
-
async create(ctx) {
|
|
9
|
-
const formatjs = await getFormatjs(ctx, options);
|
|
10
|
-
return [
|
|
11
|
-
{
|
|
12
|
-
react_intl: {
|
|
13
|
-
intl: formatjs.intl
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
() => ctx.react.providers.register(({ children }) => (React.createElement(RawIntlProvider, { value: formatjs.intl }, children)))
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
async function getFormatjs(ctx, options) {
|
|
22
|
-
if (ctx.formatjs)
|
|
23
|
-
return ctx.formatjs;
|
|
24
|
-
if (!options)
|
|
25
|
-
throw new Error('options is required when there is no formatjs gizmo');
|
|
26
|
-
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=react_intl_gizmo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,eAAe,EAAiD,MAAM,oBAAoB,CAAA;AAEnG,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAA;AAI5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAsB,OAAkC;IAC9F,OAAO;QACN,MAAM,EAAE,MAAM,CAAC,OAAO,EAAc,CAAC,QAAQ,EAAiB;QAC9D,KAAK,CAAC,MAAM,CAAC,GAAwC;YACpD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAChD,OAAO;gBACN;oBACC,UAAU,EAAE;wBACX,IAAI,EAAE,QAAQ,CAAC,IAAiB;qBAChC;iBACD;gBACD,GAAG,EAAE,CACJ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC9C,oBAAC,eAAe,IAAC,KAAK,EAAE,QAAQ,CAAC,IAAiB,IAAG,QAAQ,CAAmB,CAChF,CAAC;aACH,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA;AAIF,KAAK,UAAU,WAAW,CAAC,GAA2B,EAAE,OAA+C;IACtG,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAA;IACrC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACpF,OAAO,CAAC,MAAM,QAAQ,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAA;AAC3E,CAAC"}
|
package/ts/react_intl_gizmo.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { define, incubate } from '@just-web/app'
|
|
3
|
-
import { formatJSGizmoFn, type FormatJSGizmo, type FormatJSGizmoOptions } from '@just-web/formatjs'
|
|
4
|
-
import type { ReactGizmo } from '@just-web/react'
|
|
5
|
-
import { RawIntlProvider, type IntlShape } from 'react-intl'
|
|
6
|
-
|
|
7
|
-
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>
|
|
8
|
-
|
|
9
|
-
export const reactIntlGizmoFn = define(function <T = string>(options?: ReactIntlGizmoOptions<T>) {
|
|
10
|
-
return {
|
|
11
|
-
static: define.require<ReactGizmo>().optional<FormatJSGizmo>(),
|
|
12
|
-
async create(ctx: ReactGizmo & Partial<FormatJSGizmo>) {
|
|
13
|
-
const formatjs = await getFormatjs(ctx, options)
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
react_intl: {
|
|
17
|
-
intl: formatjs.intl as IntlShape
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
() =>
|
|
21
|
-
ctx.react.providers.register(({ children }) => (
|
|
22
|
-
<RawIntlProvider value={formatjs.intl as IntlShape}>{children}</RawIntlProvider>
|
|
23
|
-
))
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>
|
|
30
|
-
|
|
31
|
-
async function getFormatjs(ctx: Partial<FormatJSGizmo>, options: ReactIntlGizmoOptions<any> | undefined) {
|
|
32
|
-
if (ctx.formatjs) return ctx.formatjs
|
|
33
|
-
if (!options) throw new Error('options is required when there is no formatjs gizmo')
|
|
34
|
-
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs
|
|
35
|
-
}
|
/package/{ts → src}/index.ts
RENAMED
|
File without changes
|
|
File without changes
|