@just-web/react-intl 1.1.1 → 1.2.2
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/index.cjs +176 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +218 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +130 -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
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) {
|
|
12
|
+
__defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (!no_symbols) {
|
|
18
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
+
key = keys[i];
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
+
__defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
38
|
+
value: mod,
|
|
39
|
+
enumerable: true
|
|
40
|
+
}) : target, mod));
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
let _just_web_formatjs = require("@just-web/formatjs");
|
|
44
|
+
let react = require("react");
|
|
45
|
+
react = __toESM(react, 1);
|
|
46
|
+
let react_intl = require("react-intl");
|
|
47
|
+
|
|
48
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.js
|
|
49
|
+
function define(plugin) {
|
|
50
|
+
return plugin;
|
|
51
|
+
}
|
|
52
|
+
function defineDeps() {
|
|
53
|
+
return {
|
|
54
|
+
require: defineDeps,
|
|
55
|
+
optional: defineDeps
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
define.require = defineDeps;
|
|
59
|
+
define.optional = defineDeps;
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.7/node_modules/type-plus/esm/type-guard/is_type.js
|
|
63
|
+
function isType(subject, validator) {
|
|
64
|
+
return validator ? !!validator(subject) : true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated use `isType<T>()` or `testType.true<T>()` instead
|
|
68
|
+
*/
|
|
69
|
+
isType.t = (subject) => subject === void 0 || subject === true;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated use `isType<T>()` or `testType.false<T>()` instead
|
|
72
|
+
*/
|
|
73
|
+
isType.f = (subject) => subject === void 0 || subject === false;
|
|
74
|
+
function isNever(_subject) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
isType.never = isNever;
|
|
78
|
+
/**
|
|
79
|
+
* Are types A and B equals/not equals.
|
|
80
|
+
* Easier to use than `isType.t<>()` and `isType.f<>()`,
|
|
81
|
+
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated use `testType.equal()` instead
|
|
84
|
+
*/
|
|
85
|
+
isType.equal = () => {};
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/incubate.js
|
|
89
|
+
const closableApps = /* @__PURE__ */ new Map();
|
|
90
|
+
function addCloser(app, closer) {
|
|
91
|
+
if (typeof closer === "function") {
|
|
92
|
+
const closers = closableApps.get(app) ?? [];
|
|
93
|
+
closers.push(closer);
|
|
94
|
+
closableApps.set(app, closers);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function incubate(base) {
|
|
98
|
+
const dependencies = [];
|
|
99
|
+
if (base) dependencies.push({ instance: base });
|
|
100
|
+
let initFn;
|
|
101
|
+
return {
|
|
102
|
+
with(gizmo) {
|
|
103
|
+
dependencies.push({ gizmo });
|
|
104
|
+
return this;
|
|
105
|
+
},
|
|
106
|
+
merge(instance) {
|
|
107
|
+
dependencies.push({ instance });
|
|
108
|
+
return this;
|
|
109
|
+
},
|
|
110
|
+
init(initializer) {
|
|
111
|
+
initFn = initializer;
|
|
112
|
+
return this;
|
|
113
|
+
},
|
|
114
|
+
async create(start) {
|
|
115
|
+
const result = { async load(_identifier) {
|
|
116
|
+
return result;
|
|
117
|
+
} };
|
|
118
|
+
for (const dep of dependencies) if (isType(dep, (d) => !!d.gizmo)) await injectGizmo(result, dep.gizmo);
|
|
119
|
+
else Object.assign(result, dep.instance);
|
|
120
|
+
if (initFn) addCloser(result, await initFn(result));
|
|
121
|
+
if (start) addCloser(result, await start(result));
|
|
122
|
+
delete result["load"];
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Invokes any cleanup functions of the gizmo and its dependents.
|
|
129
|
+
*
|
|
130
|
+
* The gizmo is not destroyed as in other languages,
|
|
131
|
+
* as there is no destructor or ability to tap into the garbage collector of JavaScript.
|
|
132
|
+
*
|
|
133
|
+
* But nonetheless, the cleanup functions are used to close resources such as network connections,
|
|
134
|
+
* strong map, cache, etc.
|
|
135
|
+
*
|
|
136
|
+
* The gizmo should not be used after cleanup.
|
|
137
|
+
*/
|
|
138
|
+
incubate.cleanup = (app) => {
|
|
139
|
+
const closers = closableApps.get(app);
|
|
140
|
+
if (closers) closers.forEach((c) => void c());
|
|
141
|
+
};
|
|
142
|
+
async function injectGizmo(result, gizmo) {
|
|
143
|
+
const gizmoResult = await gizmo.create(result);
|
|
144
|
+
if (Array.isArray(gizmoResult)) {
|
|
145
|
+
const [value, start] = gizmoResult;
|
|
146
|
+
if (start) addCloser(result, await start());
|
|
147
|
+
Object.assign(result, value);
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
Object.assign(result, gizmoResult);
|
|
151
|
+
return gizmoResult;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/react_intl_gizmo.tsx
|
|
156
|
+
const reactIntlGizmoFn = define((options) => ({
|
|
157
|
+
static: define.require().optional(),
|
|
158
|
+
async create(ctx) {
|
|
159
|
+
const formatjs = await getFormatjs(ctx, options);
|
|
160
|
+
return [{ react_intl: { intl: formatjs.intl } }, () => ctx.react.providers.register(({ children }) => /* @__PURE__ */ react.default.createElement(react_intl.RawIntlProvider, { value: formatjs.intl }, children))];
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
async function getFormatjs(ctx, options) {
|
|
164
|
+
if (ctx.formatjs) return ctx.formatjs;
|
|
165
|
+
if (!options) throw new Error("options is required when there is no formatjs gizmo");
|
|
166
|
+
return (await incubate().with((0, _just_web_formatjs.formatJSGizmoFn)(options)).create()).formatjs;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
exports.reactIntlGizmoFn = reactIntlGizmoFn;
|
|
171
|
+
Object.keys(react_intl).forEach(function (k) {
|
|
172
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function () { return react_intl[k]; }
|
|
175
|
+
});
|
|
176
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { FormatJSGizmoOptions } from "@just-web/formatjs";
|
|
2
|
+
import { IntlShape } from "react-intl";
|
|
3
|
+
export * from "react-intl";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/types.d.ts
|
|
5
|
+
declare const _type: unique symbol;
|
|
6
|
+
type Gizmo<Static extends DepBuilder<unknown, unknown> | unknown = unknown, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = GizmoBase<Result> | GizmoStatic<Static, Result> | GizmoDynamic<Dynamic, Result> | GizmoBoth<Static, Dynamic, Result>;
|
|
7
|
+
type GizmoBase<Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
8
|
+
create(): Result | Promise<Result>;
|
|
9
|
+
};
|
|
10
|
+
type GizmoStatic<Static extends DepBuilder<unknown, unknown> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
11
|
+
readonly static: Static;
|
|
12
|
+
create(ctx: DefineContext<Static, unknown>): Result | Promise<Result>;
|
|
13
|
+
};
|
|
14
|
+
type GizmoDynamic<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
15
|
+
readonly dynamic: Dynamic;
|
|
16
|
+
create(ctx: DefineContext<unknown, Dynamic>): Result | Promise<Result>;
|
|
17
|
+
};
|
|
18
|
+
type GizmoBoth<Static extends DepBuilder<unknown, unknown> | unknown = unknown, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
19
|
+
readonly static: Static;
|
|
20
|
+
readonly dynamic: Dynamic;
|
|
21
|
+
create(ctx: DefineContext<Static, Dynamic>): Result | Promise<Result>;
|
|
22
|
+
};
|
|
23
|
+
type InferAllGizmo<D extends Gizmo | ((...args: any[]) => Gizmo)> = D extends ((...args: any[]) => Gizmo) ? InferGizmo<ReturnType<D>> : D extends Gizmo ? InferGizmo<D> : never;
|
|
24
|
+
type InferGizmo<D extends Gizmo> = D extends Gizmo ? ReturnType<D['create']> extends (infer R) ? R extends Promise<[infer X extends Record<string | symbol, unknown>, unknown]> ? Awaited<X> : R extends Promise<[infer X extends Record<string | symbol, unknown>]> ? Awaited<X> : R extends [infer X extends Record<string | symbol, unknown>, unknown] ? X : R extends [infer X extends Record<string | symbol, unknown>] ? X : R extends Record<string | symbol, any> ? Awaited<R> : never : never : unknown;
|
|
25
|
+
type DefineContext<Static extends DepBuilder<unknown, unknown> | unknown, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown> = Dynamic extends Record<string, DepBuilder<unknown, unknown>> ? ExtractDep<Static> & DynamicLoader<Dynamic> : ExtractDep<Static>;
|
|
26
|
+
/**
|
|
27
|
+
* Define the `ctx.load` function.
|
|
28
|
+
*/
|
|
29
|
+
type DynamicLoader<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown> = {
|
|
30
|
+
load<I extends keyof Dynamic>(identifier: I): Promise<ExtractDep<Dynamic[I]>>;
|
|
31
|
+
};
|
|
32
|
+
type DepBuilder<R, O> = {
|
|
33
|
+
[_type]: {
|
|
34
|
+
require: R;
|
|
35
|
+
optional: O;
|
|
36
|
+
};
|
|
37
|
+
require: {
|
|
38
|
+
/**
|
|
39
|
+
* Define a gizmo as a require dependency by specifying the type.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const gizmo = define({
|
|
43
|
+
* static: define.require<SomeGizmo>()
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
<Require extends Record<string | symbol, unknown>>(): DepBuilder<R & Require, O>;
|
|
48
|
+
/**
|
|
49
|
+
* Define a gizmo as a require dependency by passing in the gizmo directly.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const gizmo = define({
|
|
53
|
+
* static: define.require(someGizmo)
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<R & InferAllGizmo<G>, O>;
|
|
58
|
+
};
|
|
59
|
+
optional: {
|
|
60
|
+
/**
|
|
61
|
+
* Define a gizmo as an optional dependency by specifying the type.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* const gizmo = define({
|
|
65
|
+
* static: define.optional<SomeGizmo>()
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
<Optional extends Record<string | symbol, unknown>>(): DepBuilder<R, O & Optional>;
|
|
70
|
+
/**
|
|
71
|
+
* Define a gizmo as an optional dependency by passing in the gizmo directly.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* const gizmo = define({
|
|
75
|
+
* static: define.optional(someGizmo)
|
|
76
|
+
* })
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<R, O & InferAllGizmo<G>>;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Extract the dependencies from a dep builder.
|
|
84
|
+
*/
|
|
85
|
+
type ExtractDep<D extends DepBuilder<unknown, unknown> | unknown> = D extends DepBuilder<unknown, unknown> ? unknown extends D[typeof _type]['require'] ? unknown extends D[typeof _type]['optional'] ? unknown : Partial<D[typeof _type]['optional']> : unknown extends D[typeof _type]['optional'] ? D[typeof _type]['require'] : D[typeof _type]['require'] & Partial<D[typeof _type]['optional']> : unknown;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.d.ts
|
|
88
|
+
/**
|
|
89
|
+
* Define a gizmo with both static and dynamic dependencies.
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const gizmo = define({
|
|
93
|
+
* static: define.require(...),
|
|
94
|
+
* dynamic: {
|
|
95
|
+
* foo: define.optional(...)
|
|
96
|
+
* },
|
|
97
|
+
* async create(ctx) { ... }
|
|
98
|
+
* })
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoBoth<Static, Dynamic, Result>): typeof gizmo;
|
|
102
|
+
/**
|
|
103
|
+
* Define a gizmo with static dependencies.
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* const gizmo = define({
|
|
107
|
+
* static: define.require(fooGizmo).optional(booGizmo),
|
|
108
|
+
* async create({ foo, boo }) { ... }
|
|
109
|
+
* })
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoStatic<Static, Result>): typeof gizmo;
|
|
113
|
+
/**
|
|
114
|
+
* Define a gizmo with dynamic dependencies.
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* const gizmo = define({
|
|
118
|
+
* dynamic: {
|
|
119
|
+
* foo: define.optional(...)
|
|
120
|
+
* },
|
|
121
|
+
* async create(ctx) {
|
|
122
|
+
* const d = await ctx.load('foo')
|
|
123
|
+
* return { ... }
|
|
124
|
+
* }
|
|
125
|
+
* })
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function define<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoDynamic<Dynamic, Result>): typeof gizmo;
|
|
129
|
+
/**
|
|
130
|
+
* Define a gizmo with no dependencies.
|
|
131
|
+
*
|
|
132
|
+
* ```ts
|
|
133
|
+
* const gizmo = define({
|
|
134
|
+
* async create() { ... }
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
declare function define<Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoBase<Result>): typeof gizmo;
|
|
139
|
+
/**
|
|
140
|
+
* Define a gizmo function with both static and dynamic dependencies.
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* const gizmo = define((params) => ({
|
|
144
|
+
* static: define.require(...),
|
|
145
|
+
* dynamic: {
|
|
146
|
+
* foo: define.optional(...)
|
|
147
|
+
* },
|
|
148
|
+
* async create(ctx) { ... }
|
|
149
|
+
* }))
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoBoth<Static, Dynamic, Result>): typeof gizmoFn;
|
|
153
|
+
/**
|
|
154
|
+
* Define a gizmo function with static dependencies.
|
|
155
|
+
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* const gizmo = define((params) => ({
|
|
158
|
+
* static: define.require(fooGizmo).optional(booGizmo),
|
|
159
|
+
* async create({ foo, boo }) { ... }
|
|
160
|
+
* }))
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoStatic<Static, Result>): typeof gizmoFn;
|
|
164
|
+
/**
|
|
165
|
+
* Define a gizmo function with dynamic dependencies.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* const gizmo = define((params) => ({
|
|
169
|
+
* dynamic: {
|
|
170
|
+
* foo: define.optional(...)
|
|
171
|
+
* },
|
|
172
|
+
* async create(ctx) {
|
|
173
|
+
* const d = await ctx.load('foo')
|
|
174
|
+
* return { ... }
|
|
175
|
+
* }
|
|
176
|
+
* }))
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare function define<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoDynamic<Dynamic, Result>): typeof gizmoFn;
|
|
180
|
+
/**
|
|
181
|
+
* Define a gizmo function with no dependencies.
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* const gizmo = define((params) => ({
|
|
185
|
+
* async create() { ... }
|
|
186
|
+
* }))
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare function define<Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoBase<Result>): typeof gizmoFn;
|
|
190
|
+
declare namespace define {
|
|
191
|
+
var require: {
|
|
192
|
+
<Require extends Record<string | symbol, unknown>>(): DepBuilder<Require, unknown>;
|
|
193
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<InferAllGizmo<G>, unknown>;
|
|
194
|
+
};
|
|
195
|
+
var optional: {
|
|
196
|
+
<Optional extends Record<string | symbol, unknown>>(): DepBuilder<unknown, Optional>;
|
|
197
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<unknown, InferAllGizmo<G>>;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
declare namespace define {
|
|
201
|
+
type Infer<D extends Gizmo | ((...args: any[]) => Gizmo)> = InferAllGizmo<D>;
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/react_intl_gizmo.d.ts
|
|
205
|
+
type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
206
|
+
declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => GizmoStatic<DepBuilder<ReactGizmo, {
|
|
207
|
+
formatjs: {
|
|
208
|
+
intl: import("@just-web/formatjs").IntlShape<unknown>;
|
|
209
|
+
};
|
|
210
|
+
}>, [{
|
|
211
|
+
react_intl: {
|
|
212
|
+
intl: IntlShape;
|
|
213
|
+
};
|
|
214
|
+
}, () => any]>;
|
|
215
|
+
type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
216
|
+
//#endregion
|
|
217
|
+
export { ReactIntlGizmo, ReactIntlGizmoOptions, reactIntlGizmoFn };
|
|
218
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/types.d.ts","../../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.d.ts","../src/react_intl_gizmo.tsx"],"x_google_ignoreList":[0,1],"mappings":";;;;cAAc;KACF,MAAM,eAAe,kDAAkD,gBAAgB,eAAe,mDAAmD,gBAAgB,QAAQ,kCAAkC,yBAAyB,0CAA0C,uCAAuC,UAAU,UAAU,YAAY,QAAQ,UAAU,aAAa,SAAS,UAAU,UAAU,QAAQ,SAAS;KAC1a,UAAU,gBAAgB,QAAQ,kCAAkC,yBAAyB,0CAA0C;EAC/I,UAAU,SAAS,QAAQ;;KAEnB,YAAY,eAAe,kDAAkD,gBAAgB,QAAQ,kCAAkC,yBAAyB,0CAA0C;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AAc;;MAEpF;KACC,iBAAiB,qCAAqC,oBAAoB;KAC1E,UAAU,aAAa,gBAAgB,QAAQ,OAAO,IAAI,oBAAoB,cAAc;;;kBAG5E;OAChB,MAAM,UAAU,aAAa,gBAAgB,UAAU,cAAc;;;;KC5GlE,sBAAsB,cAAc,qBAAqB;cAExD,mBAA2B,YAAC,UAAA,sBAAA,mBAOb,YAPa,WAAA;;;;;;IAOb,MAAA;;;KAWhB,iBAAiB,OAAO,aAAa"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { FormatJSGizmoOptions } from "@just-web/formatjs";
|
|
2
|
+
import { IntlShape } from "react-intl";
|
|
3
|
+
export * from "react-intl";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/types.d.ts
|
|
5
|
+
declare const _type: unique symbol;
|
|
6
|
+
type Gizmo<Static extends DepBuilder<unknown, unknown> | unknown = unknown, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = GizmoBase<Result> | GizmoStatic<Static, Result> | GizmoDynamic<Dynamic, Result> | GizmoBoth<Static, Dynamic, Result>;
|
|
7
|
+
type GizmoBase<Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
8
|
+
create(): Result | Promise<Result>;
|
|
9
|
+
};
|
|
10
|
+
type GizmoStatic<Static extends DepBuilder<unknown, unknown> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
11
|
+
readonly static: Static;
|
|
12
|
+
create(ctx: DefineContext<Static, unknown>): Result | Promise<Result>;
|
|
13
|
+
};
|
|
14
|
+
type GizmoDynamic<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
15
|
+
readonly dynamic: Dynamic;
|
|
16
|
+
create(ctx: DefineContext<unknown, Dynamic>): Result | Promise<Result>;
|
|
17
|
+
};
|
|
18
|
+
type GizmoBoth<Static extends DepBuilder<unknown, unknown> | unknown = unknown, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown = unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, unknown> | void = Record<string | symbol, any> | void> = {
|
|
19
|
+
readonly static: Static;
|
|
20
|
+
readonly dynamic: Dynamic;
|
|
21
|
+
create(ctx: DefineContext<Static, Dynamic>): Result | Promise<Result>;
|
|
22
|
+
};
|
|
23
|
+
type InferAllGizmo<D extends Gizmo | ((...args: any[]) => Gizmo)> = D extends ((...args: any[]) => Gizmo) ? InferGizmo<ReturnType<D>> : D extends Gizmo ? InferGizmo<D> : never;
|
|
24
|
+
type InferGizmo<D extends Gizmo> = D extends Gizmo ? ReturnType<D['create']> extends (infer R) ? R extends Promise<[infer X extends Record<string | symbol, unknown>, unknown]> ? Awaited<X> : R extends Promise<[infer X extends Record<string | symbol, unknown>]> ? Awaited<X> : R extends [infer X extends Record<string | symbol, unknown>, unknown] ? X : R extends [infer X extends Record<string | symbol, unknown>] ? X : R extends Record<string | symbol, any> ? Awaited<R> : never : never : unknown;
|
|
25
|
+
type DefineContext<Static extends DepBuilder<unknown, unknown> | unknown, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown> = Dynamic extends Record<string, DepBuilder<unknown, unknown>> ? ExtractDep<Static> & DynamicLoader<Dynamic> : ExtractDep<Static>;
|
|
26
|
+
/**
|
|
27
|
+
* Define the `ctx.load` function.
|
|
28
|
+
*/
|
|
29
|
+
type DynamicLoader<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown> = {
|
|
30
|
+
load<I extends keyof Dynamic>(identifier: I): Promise<ExtractDep<Dynamic[I]>>;
|
|
31
|
+
};
|
|
32
|
+
type DepBuilder<R, O> = {
|
|
33
|
+
[_type]: {
|
|
34
|
+
require: R;
|
|
35
|
+
optional: O;
|
|
36
|
+
};
|
|
37
|
+
require: {
|
|
38
|
+
/**
|
|
39
|
+
* Define a gizmo as a require dependency by specifying the type.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const gizmo = define({
|
|
43
|
+
* static: define.require<SomeGizmo>()
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
<Require extends Record<string | symbol, unknown>>(): DepBuilder<R & Require, O>;
|
|
48
|
+
/**
|
|
49
|
+
* Define a gizmo as a require dependency by passing in the gizmo directly.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const gizmo = define({
|
|
53
|
+
* static: define.require(someGizmo)
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<R & InferAllGizmo<G>, O>;
|
|
58
|
+
};
|
|
59
|
+
optional: {
|
|
60
|
+
/**
|
|
61
|
+
* Define a gizmo as an optional dependency by specifying the type.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* const gizmo = define({
|
|
65
|
+
* static: define.optional<SomeGizmo>()
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
<Optional extends Record<string | symbol, unknown>>(): DepBuilder<R, O & Optional>;
|
|
70
|
+
/**
|
|
71
|
+
* Define a gizmo as an optional dependency by passing in the gizmo directly.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* const gizmo = define({
|
|
75
|
+
* static: define.optional(someGizmo)
|
|
76
|
+
* })
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<R, O & InferAllGizmo<G>>;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Extract the dependencies from a dep builder.
|
|
84
|
+
*/
|
|
85
|
+
type ExtractDep<D extends DepBuilder<unknown, unknown> | unknown> = D extends DepBuilder<unknown, unknown> ? unknown extends D[typeof _type]['require'] ? unknown extends D[typeof _type]['optional'] ? unknown : Partial<D[typeof _type]['optional']> : unknown extends D[typeof _type]['optional'] ? D[typeof _type]['require'] : D[typeof _type]['require'] & Partial<D[typeof _type]['optional']> : unknown;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.d.ts
|
|
88
|
+
/**
|
|
89
|
+
* Define a gizmo with both static and dynamic dependencies.
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const gizmo = define({
|
|
93
|
+
* static: define.require(...),
|
|
94
|
+
* dynamic: {
|
|
95
|
+
* foo: define.optional(...)
|
|
96
|
+
* },
|
|
97
|
+
* async create(ctx) { ... }
|
|
98
|
+
* })
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoBoth<Static, Dynamic, Result>): typeof gizmo;
|
|
102
|
+
/**
|
|
103
|
+
* Define a gizmo with static dependencies.
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* const gizmo = define({
|
|
107
|
+
* static: define.require(fooGizmo).optional(booGizmo),
|
|
108
|
+
* async create({ foo, boo }) { ... }
|
|
109
|
+
* })
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoStatic<Static, Result>): typeof gizmo;
|
|
113
|
+
/**
|
|
114
|
+
* Define a gizmo with dynamic dependencies.
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* const gizmo = define({
|
|
118
|
+
* dynamic: {
|
|
119
|
+
* foo: define.optional(...)
|
|
120
|
+
* },
|
|
121
|
+
* async create(ctx) {
|
|
122
|
+
* const d = await ctx.load('foo')
|
|
123
|
+
* return { ... }
|
|
124
|
+
* }
|
|
125
|
+
* })
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function define<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoDynamic<Dynamic, Result>): typeof gizmo;
|
|
129
|
+
/**
|
|
130
|
+
* Define a gizmo with no dependencies.
|
|
131
|
+
*
|
|
132
|
+
* ```ts
|
|
133
|
+
* const gizmo = define({
|
|
134
|
+
* async create() { ... }
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
declare function define<Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmo: GizmoBase<Result>): typeof gizmo;
|
|
139
|
+
/**
|
|
140
|
+
* Define a gizmo function with both static and dynamic dependencies.
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* const gizmo = define((params) => ({
|
|
144
|
+
* static: define.require(...),
|
|
145
|
+
* dynamic: {
|
|
146
|
+
* foo: define.optional(...)
|
|
147
|
+
* },
|
|
148
|
+
* async create(ctx) { ... }
|
|
149
|
+
* }))
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoBoth<Static, Dynamic, Result>): typeof gizmoFn;
|
|
153
|
+
/**
|
|
154
|
+
* Define a gizmo function with static dependencies.
|
|
155
|
+
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* const gizmo = define((params) => ({
|
|
158
|
+
* static: define.require(fooGizmo).optional(booGizmo),
|
|
159
|
+
* async create({ foo, boo }) { ... }
|
|
160
|
+
* }))
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
declare function define<Static extends DepBuilder<unknown, unknown>, Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoStatic<Static, Result>): typeof gizmoFn;
|
|
164
|
+
/**
|
|
165
|
+
* Define a gizmo function with dynamic dependencies.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* const gizmo = define((params) => ({
|
|
169
|
+
* dynamic: {
|
|
170
|
+
* foo: define.optional(...)
|
|
171
|
+
* },
|
|
172
|
+
* async create(ctx) {
|
|
173
|
+
* const d = await ctx.load('foo')
|
|
174
|
+
* return { ... }
|
|
175
|
+
* }
|
|
176
|
+
* }))
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare function define<Dynamic extends Record<string, DepBuilder<unknown, unknown>> | unknown, Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoDynamic<Dynamic, Result>): typeof gizmoFn;
|
|
180
|
+
/**
|
|
181
|
+
* Define a gizmo function with no dependencies.
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* const gizmo = define((params) => ({
|
|
185
|
+
* async create() { ... }
|
|
186
|
+
* }))
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare function define<Params extends unknown[], Result extends [result: Record<string | symbol, unknown>, start?: () => unknown] | Record<string | symbol, any> | void>(gizmoFn: (...args: Params) => GizmoBase<Result>): typeof gizmoFn;
|
|
190
|
+
declare namespace define {
|
|
191
|
+
var require: {
|
|
192
|
+
<Require extends Record<string | symbol, unknown>>(): DepBuilder<Require, unknown>;
|
|
193
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<InferAllGizmo<G>, unknown>;
|
|
194
|
+
};
|
|
195
|
+
var optional: {
|
|
196
|
+
<Optional extends Record<string | symbol, unknown>>(): DepBuilder<unknown, Optional>;
|
|
197
|
+
<G extends Gizmo | ((...args: any[]) => Gizmo)>(gizmo: G): DepBuilder<unknown, InferAllGizmo<G>>;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
declare namespace define {
|
|
201
|
+
type Infer<D extends Gizmo | ((...args: any[]) => Gizmo)> = InferAllGizmo<D>;
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/react_intl_gizmo.d.ts
|
|
205
|
+
type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
206
|
+
declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => GizmoStatic<DepBuilder<ReactGizmo, {
|
|
207
|
+
formatjs: {
|
|
208
|
+
intl: import("@just-web/formatjs").IntlShape<unknown>;
|
|
209
|
+
};
|
|
210
|
+
}>, [{
|
|
211
|
+
react_intl: {
|
|
212
|
+
intl: IntlShape;
|
|
213
|
+
};
|
|
214
|
+
}, () => any]>;
|
|
215
|
+
type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
216
|
+
//#endregion
|
|
217
|
+
export { ReactIntlGizmo, ReactIntlGizmoOptions, reactIntlGizmoFn };
|
|
218
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/types.d.ts","../../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.d.ts","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WAAW,YAAY,QAAQ,iBAAiB;;;;;;;;;;;;;;;;iBAgBzQ,OAAO,gBAAgB,eAAe,yCAAyC,0BAA0B,gBAAgB,QAAQ,kCAAkC,yBAAyB,qCAAqC,aAAa,MAAM,WAAW,aAAa,SAAS,iBAAiB;;;;;;;;;;iBAUtS,OAAO,0BAA0B,gBAAgB,QAAQ,kCAAkC,yBAAyB,qCAAqC,aAAa,MAAM,WAAW,UAAU,iBAAiB;kBACjN;MACjB;KACC,gBAAgB,qCAAqC,WAAW;KAChE,UAAU,aAAa,gBAAgB,QAAQ,OAAO,IAAI,WAAW,cAAc;;MAEpF;KACC,iBAAiB,qCAAqC,oBAAoB;KAC1E,UAAU,aAAa,gBAAgB,QAAQ,OAAO,IAAI,oBAAoB,cAAc;;;kBAG5E;OAChB,MAAM,UAAU,aAAa,gBAAgB,UAAU,cAAc;;;;KC5GlE,sBAAsB,cAAc,qBAAqB;cAExD,mBAA2B,YAAC,UAAA,sBAAA,mBAOb,YAPa,WAAA;;;;;;IAOb,MAAA;;;KAWhB,iBAAiB,OAAO,aAAa"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { formatJSGizmoFn } from "@just-web/formatjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { RawIntlProvider } from "react-intl";
|
|
4
|
+
|
|
5
|
+
export * from "react-intl"
|
|
6
|
+
|
|
7
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/define.js
|
|
8
|
+
function define(plugin) {
|
|
9
|
+
return plugin;
|
|
10
|
+
}
|
|
11
|
+
function defineDeps() {
|
|
12
|
+
return {
|
|
13
|
+
require: defineDeps,
|
|
14
|
+
optional: defineDeps
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
define.require = defineDeps;
|
|
18
|
+
define.optional = defineDeps;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.7/node_modules/type-plus/esm/type-guard/is_type.js
|
|
22
|
+
function isType(subject, validator) {
|
|
23
|
+
return validator ? !!validator(subject) : true;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use `isType<T>()` or `testType.true<T>()` instead
|
|
27
|
+
*/
|
|
28
|
+
isType.t = (subject) => subject === void 0 || subject === true;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated use `isType<T>()` or `testType.false<T>()` instead
|
|
31
|
+
*/
|
|
32
|
+
isType.f = (subject) => subject === void 0 || subject === false;
|
|
33
|
+
function isNever(_subject) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
isType.never = isNever;
|
|
37
|
+
/**
|
|
38
|
+
* Are types A and B equals/not equals.
|
|
39
|
+
* Easier to use than `isType.t<>()` and `isType.f<>()`,
|
|
40
|
+
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated use `testType.equal()` instead
|
|
43
|
+
*/
|
|
44
|
+
isType.equal = () => {};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region ../../node_modules/.pnpm/@unional+gizmo@2.3.0/node_modules/@unional/gizmo/esm/incubate.js
|
|
48
|
+
const closableApps = /* @__PURE__ */ new Map();
|
|
49
|
+
function addCloser(app, closer) {
|
|
50
|
+
if (typeof closer === "function") {
|
|
51
|
+
const closers = closableApps.get(app) ?? [];
|
|
52
|
+
closers.push(closer);
|
|
53
|
+
closableApps.set(app, closers);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function incubate(base) {
|
|
57
|
+
const dependencies = [];
|
|
58
|
+
if (base) dependencies.push({ instance: base });
|
|
59
|
+
let initFn;
|
|
60
|
+
return {
|
|
61
|
+
with(gizmo) {
|
|
62
|
+
dependencies.push({ gizmo });
|
|
63
|
+
return this;
|
|
64
|
+
},
|
|
65
|
+
merge(instance) {
|
|
66
|
+
dependencies.push({ instance });
|
|
67
|
+
return this;
|
|
68
|
+
},
|
|
69
|
+
init(initializer) {
|
|
70
|
+
initFn = initializer;
|
|
71
|
+
return this;
|
|
72
|
+
},
|
|
73
|
+
async create(start) {
|
|
74
|
+
const result = { async load(_identifier) {
|
|
75
|
+
return result;
|
|
76
|
+
} };
|
|
77
|
+
for (const dep of dependencies) if (isType(dep, (d) => !!d.gizmo)) await injectGizmo(result, dep.gizmo);
|
|
78
|
+
else Object.assign(result, dep.instance);
|
|
79
|
+
if (initFn) addCloser(result, await initFn(result));
|
|
80
|
+
if (start) addCloser(result, await start(result));
|
|
81
|
+
delete result["load"];
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Invokes any cleanup functions of the gizmo and its dependents.
|
|
88
|
+
*
|
|
89
|
+
* The gizmo is not destroyed as in other languages,
|
|
90
|
+
* as there is no destructor or ability to tap into the garbage collector of JavaScript.
|
|
91
|
+
*
|
|
92
|
+
* But nonetheless, the cleanup functions are used to close resources such as network connections,
|
|
93
|
+
* strong map, cache, etc.
|
|
94
|
+
*
|
|
95
|
+
* The gizmo should not be used after cleanup.
|
|
96
|
+
*/
|
|
97
|
+
incubate.cleanup = (app) => {
|
|
98
|
+
const closers = closableApps.get(app);
|
|
99
|
+
if (closers) closers.forEach((c) => void c());
|
|
100
|
+
};
|
|
101
|
+
async function injectGizmo(result, gizmo) {
|
|
102
|
+
const gizmoResult = await gizmo.create(result);
|
|
103
|
+
if (Array.isArray(gizmoResult)) {
|
|
104
|
+
const [value, start] = gizmoResult;
|
|
105
|
+
if (start) addCloser(result, await start());
|
|
106
|
+
Object.assign(result, value);
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
Object.assign(result, gizmoResult);
|
|
110
|
+
return gizmoResult;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/react_intl_gizmo.tsx
|
|
115
|
+
const reactIntlGizmoFn = define((options) => ({
|
|
116
|
+
static: define.require().optional(),
|
|
117
|
+
async create(ctx) {
|
|
118
|
+
const formatjs = await getFormatjs(ctx, options);
|
|
119
|
+
return [{ react_intl: { intl: formatjs.intl } }, () => ctx.react.providers.register(({ children }) => /* @__PURE__ */ React.createElement(RawIntlProvider, { value: formatjs.intl }, children))];
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
async function getFormatjs(ctx, options) {
|
|
123
|
+
if (ctx.formatjs) return ctx.formatjs;
|
|
124
|
+
if (!options) throw new Error("options is required when there is no formatjs gizmo");
|
|
125
|
+
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { reactIntlGizmoFn };
|
|
130
|
+
//# 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"],"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"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;AAAA,SAAgB,OAAO,QAAQ;CAC3B,OAAO;AACX;AACA,SAAS,aAAa;CAClB,OAAO;EACH,SAAS;EACT,UAAU;CACd;AACJ;AACA,OAAO,UAAU;AACjB,OAAO,WAAW;;;;ACVlB,SAAgB,OAAO,SAAS,WAAW;CACvC,OAAO,YAAY,CAAC,CAAC,UAAU,OAAO,IAAI;AAC9C;;;;AAIA,OAAO,KAAK,YAAY,YAAY,UAAa,YAAY;;;;AAI7D,OAAO,KAAK,YAAY,YAAY,UAAa,YAAY;AAC7D,SAAS,QAAQ,UAAU;CACvB,OAAO;AACX;AACA,OAAO,QAAQ;;;;;;;;AAQf,OAAO,cAAc,CAAE;;;;ACrBvB,MAAM,+BA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EAEnC,OAAO,OAAO,QAAQ,KAAK;EAC3B,OAAO;CACX;CACA,OAAO,OAAO,QAAQ,WAAW;CACjC,OAAO;AACX;;;;AC1EA,MAAa,mBAAmB,QAAoB,aAAwC;CAC3F,QAAQ,OAAO,QAAoB,CAAC,CAAC,SAAwB;CAC7D,MAAM,OAAO,KAA0C;EACtD,MAAM,WAAW,MAAM,YAAY,KAAK,OAAO;EAC/C,OAAO,CACN,EACC,YAAY,EACX,MAAM,SAAS,KAChB,EACD,SAEC,IAAI,MAAM,UAAU,UAAU,EAAE,eAC/B,oCAAC,iBAAD,EAAiB,OAAO,SAAS,KAA8C,GAA1B,QAA0B,CAC/E,CACH;CACD;AACD,EAAE;AAIF,eAAe,YAAY,KAA6B,SAAiD;CACxG,IAAI,IAAI,UAAU,OAAO,IAAI;CAC7B,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,qDAAqD;CACnF,QAAQ,MAAM,SAAS,CAAC,CAAC,KAAK,gBAAgB,OAAO,CAAC,CAAC,CAAC,OAAO,EAAC,CAAE;AACnE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@just-web/react-intl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
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.3",
|
|
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.22.14",
|
|
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.1"
|
|
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
|
-
//#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AAM,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
|