@embedpdf/react 3.0.0-next.14 → 3.0.0-next.16
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/AnnotationList-DcyhF2kU-CiBFOq1z.d.cts +878 -0
- package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.ts +878 -0
- package/dist/actions.cjs +25 -5
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +18 -5
- package/dist/actions.d.ts +18 -5
- package/dist/actions.js +22 -6
- package/dist/actions.js.map +1 -1
- package/dist/anchored-DeX95xSd.d.ts +85 -0
- package/dist/anchored-DzN3JywS.d.cts +85 -0
- package/dist/anchored.cjs +71 -28
- package/dist/anchored.cjs.map +1 -1
- package/dist/anchored.d.cts +2 -45
- package/dist/anchored.d.ts +2 -45
- package/dist/anchored.js +56 -19
- package/dist/anchored.js.map +1 -1
- package/dist/annotation-3UvABfJm.d.cts +305 -0
- package/dist/annotation-BNHQpMKv.cjs +806 -0
- package/dist/annotation-BNHQpMKv.cjs.map +1 -0
- package/dist/annotation-CDI8CFb3.js +684 -0
- package/dist/annotation-CDI8CFb3.js.map +1 -0
- package/dist/annotation-DhEfs0pH.d.ts +305 -0
- package/dist/annotation.cjs +20 -784
- package/dist/annotation.d.cts +2 -2
- package/dist/annotation.d.ts +2 -2
- package/dist/annotation.js +2 -769
- package/dist/attachment.cjs +39 -0
- package/dist/attachment.cjs.map +1 -0
- package/dist/attachment.d.cts +29 -0
- package/dist/attachment.d.ts +29 -0
- package/dist/attachment.js +28 -0
- package/dist/attachment.js.map +1 -0
- package/dist/commands.cjs +68 -28
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +37 -10
- package/dist/commands.d.ts +37 -10
- package/dist/commands.js +68 -31
- package/dist/commands.js.map +1 -1
- package/dist/form-BSGvjA5D.js +511 -0
- package/dist/form-BSGvjA5D.js.map +1 -0
- package/dist/form-BgztZyOK.cjs +548 -0
- package/dist/form-BgztZyOK.cjs.map +1 -0
- package/dist/form.cjs +5 -5
- package/dist/form.d.cts +41 -2
- package/dist/form.d.ts +41 -2
- package/dist/form.js +2 -3
- package/dist/history.cjs +38 -0
- package/dist/history.cjs.map +1 -0
- package/dist/history.d.cts +27 -0
- package/dist/history.d.ts +27 -0
- package/dist/history.js +27 -0
- package/dist/history.js.map +1 -0
- package/dist/i18n.cjs +26 -30
- package/dist/i18n.cjs.map +1 -1
- package/dist/i18n.d.cts +24 -21
- package/dist/i18n.d.ts +24 -21
- package/dist/i18n.js +24 -31
- package/dist/i18n.js.map +1 -1
- package/dist/index.cjs +227 -57
- package/dist/index.d.cts +35 -32
- package/dist/index.d.ts +35 -32
- package/dist/index.js +36 -30
- package/dist/inert-CmBEbKCn.cjs +19 -0
- package/dist/inert-CmBEbKCn.cjs.map +1 -0
- package/dist/inert-D8fkennb.js +14 -0
- package/dist/inert-D8fkennb.js.map +1 -0
- package/dist/interaction.cjs +48 -102
- package/dist/interaction.cjs.map +1 -1
- package/dist/interaction.d.cts +23 -32
- package/dist/interaction.d.ts +23 -32
- package/dist/interaction.js +33 -102
- package/dist/interaction.js.map +1 -1
- package/dist/link.cjs +65 -104
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +21 -16
- package/dist/link.d.ts +22 -17
- package/dist/link.js +67 -107
- package/dist/link.js.map +1 -1
- package/dist/measurement.cjs +36 -11
- package/dist/measurement.cjs.map +1 -1
- package/dist/measurement.d.cts +33 -7
- package/dist/measurement.d.ts +33 -7
- package/dist/measurement.js +35 -14
- package/dist/measurement.js.map +1 -1
- package/dist/metadata.cjs +20 -7
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +22 -7
- package/dist/metadata.d.ts +22 -7
- package/dist/metadata.js +20 -10
- package/dist/metadata.js.map +1 -1
- package/dist/outline.cjs +39 -0
- package/dist/outline.cjs.map +1 -0
- package/dist/outline.d.cts +31 -0
- package/dist/outline.d.ts +31 -0
- package/dist/outline.js +28 -0
- package/dist/outline.js.map +1 -0
- package/dist/page-edit.cjs +15 -3
- package/dist/page-edit.cjs.map +1 -1
- package/dist/page-edit.d.cts +17 -2
- package/dist/page-edit.d.ts +17 -2
- package/dist/page-edit.js +15 -5
- package/dist/page-edit.js.map +1 -1
- package/dist/page-layers-Bkaaz8Zf.js +26 -0
- package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
- package/dist/page-layers-BloZDoOV.cjs +37 -0
- package/dist/page-layers-BloZDoOV.cjs.map +1 -0
- package/dist/page-view.cjs +89 -82
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.d.cts +14 -7
- package/dist/page-view.d.ts +18 -11
- package/dist/page-view.js +86 -81
- package/dist/page-view.js.map +1 -1
- package/dist/redaction.cjs +30 -15
- package/dist/redaction.cjs.map +1 -1
- package/dist/redaction.d.cts +27 -9
- package/dist/redaction.d.ts +27 -9
- package/dist/redaction.js +29 -18
- package/dist/redaction.js.map +1 -1
- package/dist/render.cjs +71 -46
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +17 -5
- package/dist/render.d.ts +17 -5
- package/dist/render.js +70 -49
- package/dist/render.js.map +1 -1
- package/dist/runtime-BfnpyfY0.cjs +556 -0
- package/dist/runtime-BfnpyfY0.cjs.map +1 -0
- package/dist/runtime-DBEBlpQV.d.cts +237 -0
- package/dist/runtime-V3MVMb91.d.ts +237 -0
- package/dist/runtime-tD5iJU83.js +399 -0
- package/dist/runtime-tD5iJU83.js.map +1 -0
- package/dist/runtime.cjs +45 -324
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +2 -306
- package/dist/search.cjs +81 -50
- package/dist/search.cjs.map +1 -1
- package/dist/search.d.cts +37 -24
- package/dist/search.d.ts +37 -24
- package/dist/search.js +81 -53
- package/dist/search.js.map +1 -1
- package/dist/selection.cjs +105 -108
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +54 -26
- package/dist/selection.d.ts +56 -28
- package/dist/selection.js +103 -110
- package/dist/selection.js.map +1 -1
- package/dist/shell.cjs +36 -21
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +32 -17
- package/dist/shell.d.ts +32 -17
- package/dist/shell.js +36 -24
- package/dist/shell.js.map +1 -1
- package/dist/signature.cjs +29 -48
- package/dist/signature.cjs.map +1 -1
- package/dist/signature.d.cts +26 -26
- package/dist/signature.d.ts +26 -26
- package/dist/signature.js +30 -48
- package/dist/signature.js.map +1 -1
- package/dist/stage-B7BG2e8Q.cjs +369 -0
- package/dist/stage-B7BG2e8Q.cjs.map +1 -0
- package/dist/stage-BqfBjDu6.js +302 -0
- package/dist/stage-BqfBjDu6.js.map +1 -0
- package/dist/stage-ByFPD-Fv.d.cts +117 -0
- package/dist/stage-DaboaheR.d.ts +117 -0
- package/dist/stage-scope-CQgCuf1w.cjs +46 -0
- package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
- package/dist/stage-scope-D7ZeNduT.js +23 -0
- package/dist/stage-scope-D7ZeNduT.js.map +1 -0
- package/dist/stage.cjs +12 -235
- package/dist/stage.d.cts +2 -116
- package/dist/stage.d.ts +2 -116
- package/dist/stage.js +3 -228
- package/dist/stamp.cjs +41 -35
- package/dist/stamp.cjs.map +1 -1
- package/dist/stamp.d.cts +25 -18
- package/dist/stamp.d.ts +25 -18
- package/dist/stamp.js +40 -37
- package/dist/stamp.js.map +1 -1
- package/dist/state-0K1I5cM4.d.cts +29 -0
- package/dist/state-0K1I5cM4.d.ts +29 -0
- package/dist/state-CzI2KlZb.js +62 -0
- package/dist/state-CzI2KlZb.js.map +1 -0
- package/dist/state-Dtf8HAue.cjs +73 -0
- package/dist/state-Dtf8HAue.cjs.map +1 -0
- package/dist/svg-shapes-Dm1yTR1b.js +40 -0
- package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
- package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
- package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
- package/dist/toolbar.cjs +297 -295
- package/dist/toolbar.cjs.map +1 -1
- package/dist/toolbar.d.cts +58 -68
- package/dist/toolbar.d.ts +67 -77
- package/dist/toolbar.js +271 -293
- package/dist/toolbar.js.map +1 -1
- package/dist/view-manager.cjs +34 -0
- package/dist/view-manager.cjs.map +1 -0
- package/dist/view-manager.d.cts +21 -0
- package/dist/view-manager.d.ts +21 -0
- package/dist/view-manager.js +23 -0
- package/dist/view-manager.js.map +1 -0
- package/package.json +47 -39
- package/dist/annotation-BCED_p9H.d.cts +0 -160
- package/dist/annotation-anchors-CetwM1g7.js +0 -15
- package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
- package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
- package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
- package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
- package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
- package/dist/annotation-hooks-Df8EmzDO.js +0 -11
- package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
- package/dist/annotation-k38KDlIZ.d.ts +0 -160
- package/dist/annotation-menu.cjs +0 -64
- package/dist/annotation-menu.cjs.map +0 -1
- package/dist/annotation-menu.d.cts +0 -33
- package/dist/annotation-menu.d.ts +0 -33
- package/dist/annotation-menu.js +0 -48
- package/dist/annotation-menu.js.map +0 -1
- package/dist/annotation.cjs.map +0 -1
- package/dist/annotation.js.map +0 -1
- package/dist/form-BVumS7up.cjs +0 -926
- package/dist/form-BVumS7up.cjs.map +0 -1
- package/dist/form-Bdjk0Z3T.d.cts +0 -537
- package/dist/form-CK3mp99m.js +0 -895
- package/dist/form-CK3mp99m.js.map +0 -1
- package/dist/form-CYRYgthn.d.ts +0 -537
- package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
- package/dist/runtime-DE76hlnl.d.ts +0 -216
- package/dist/runtime-umHA_xHt.d.cts +0 -216
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/scrollbar.cjs +0 -241
- package/dist/scrollbar.cjs.map +0 -1
- package/dist/scrollbar.d.cts +0 -42
- package/dist/scrollbar.d.ts +0 -42
- package/dist/scrollbar.js +0 -213
- package/dist/scrollbar.js.map +0 -1
- package/dist/stage.cjs.map +0 -1
- package/dist/stage.js.map +0 -1
- package/dist/views.cjs +0 -35
- package/dist/views.cjs.map +0 -1
- package/dist/views.d.cts +0 -21
- package/dist/views.d.ts +0 -21
- package/dist/views.js +0 -27
- package/dist/views.js.map +0 -1
package/dist/form.d.cts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.cjs";
|
|
2
|
+
import { i as FormKind, n as FormFieldDTO } from "./AnnotationList-DcyhF2kU-CiBFOq1z.cjs";
|
|
3
|
+
import { EventHook } from "@embedpdf/core";
|
|
4
|
+
import { FormCapability, FormFieldRef, FormFieldValue } from "@embedpdf/plugin-form";
|
|
2
5
|
export * from "@embedpdf/plugin-form";
|
|
3
|
-
|
|
6
|
+
//#region src/form.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The form's fields on one page: their pictures, and the controls people fill
|
|
9
|
+
* them in with. Put it above the page's picture (`<RenderLayer>`, and
|
|
10
|
+
* `<AnnotationLayer>` when the annotation plugin is registered); while it's
|
|
11
|
+
* there, the render layer leaves the fields out of the page's picture. The
|
|
12
|
+
* controls show while the active tool fills forms (the `pointer` and `pan`
|
|
13
|
+
* tools do), and stand down in design mode, where fields are boxes you
|
|
14
|
+
* select and move.
|
|
15
|
+
*/
|
|
16
|
+
declare function FormLayer(): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/** The form API for the surrounding document: reading, filling, form data and building. */
|
|
18
|
+
declare function useForm(): FormCapability;
|
|
19
|
+
/** Subscribe to one form event while mounted: `useFormEvent((form) => form.onValueChanged, handler)`. */
|
|
20
|
+
declare function useFormEvent<T>(select: (form: FormCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
21
|
+
/**
|
|
22
|
+
* The form's state: every field, whether it's read, what kind of form the
|
|
23
|
+
* document has, and the field of the selected widget (the page's State
|
|
24
|
+
* table, declared once in `formState`). Takes a selector, and re-renders only
|
|
25
|
+
* when what it returns changes.
|
|
26
|
+
*/
|
|
27
|
+
declare const useFormState: StateHook<{
|
|
28
|
+
fields: readonly FormFieldDTO[];
|
|
29
|
+
status: import("@embedpdf/core").ResourceStatus;
|
|
30
|
+
formKind: FormKind;
|
|
31
|
+
selectedField: FormFieldDTO | null;
|
|
32
|
+
}>;
|
|
33
|
+
/** The form settings (`validation`, `focus`, `fields`), with or without a document. Takes a selector. */
|
|
34
|
+
declare const useFormSettings: SettingsHook<import("@embedpdf/plugin-form").FormSettings>;
|
|
35
|
+
/**
|
|
36
|
+
* One field's value, in the shape `setValue()` takes, or `null`: re-renders
|
|
37
|
+
* only when that field's value changes. Empty without a document.
|
|
38
|
+
*/
|
|
39
|
+
declare function useFormValue(ref: FormFieldRef): FormFieldValue | null;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { FormLayer, useForm, useFormEvent, useFormSettings, useFormState, useFormValue };
|
|
42
|
+
//# sourceMappingURL=form.d.cts.map
|
package/dist/form.d.ts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.js";
|
|
2
|
+
import { i as FormKind, n as FormFieldDTO } from "./AnnotationList-DcyhF2kU-CiBFOq1z.js";
|
|
3
|
+
import { EventHook } from "@embedpdf/core";
|
|
4
|
+
import { FormCapability, FormFieldRef, FormFieldValue } from "@embedpdf/plugin-form";
|
|
2
5
|
export * from "@embedpdf/plugin-form";
|
|
3
|
-
|
|
6
|
+
//#region src/form.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The form's fields on one page: their pictures, and the controls people fill
|
|
9
|
+
* them in with. Put it above the page's picture (`<RenderLayer>`, and
|
|
10
|
+
* `<AnnotationLayer>` when the annotation plugin is registered); while it's
|
|
11
|
+
* there, the render layer leaves the fields out of the page's picture. The
|
|
12
|
+
* controls show while the active tool fills forms (the `pointer` and `pan`
|
|
13
|
+
* tools do), and stand down in design mode, where fields are boxes you
|
|
14
|
+
* select and move.
|
|
15
|
+
*/
|
|
16
|
+
declare function FormLayer(): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/** The form API for the surrounding document: reading, filling, form data and building. */
|
|
18
|
+
declare function useForm(): FormCapability;
|
|
19
|
+
/** Subscribe to one form event while mounted: `useFormEvent((form) => form.onValueChanged, handler)`. */
|
|
20
|
+
declare function useFormEvent<T>(select: (form: FormCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
21
|
+
/**
|
|
22
|
+
* The form's state: every field, whether it's read, what kind of form the
|
|
23
|
+
* document has, and the field of the selected widget (the page's State
|
|
24
|
+
* table, declared once in `formState`). Takes a selector, and re-renders only
|
|
25
|
+
* when what it returns changes.
|
|
26
|
+
*/
|
|
27
|
+
declare const useFormState: StateHook<{
|
|
28
|
+
fields: readonly FormFieldDTO[];
|
|
29
|
+
status: import("@embedpdf/core").ResourceStatus;
|
|
30
|
+
formKind: FormKind;
|
|
31
|
+
selectedField: FormFieldDTO | null;
|
|
32
|
+
}>;
|
|
33
|
+
/** The form settings (`validation`, `focus`, `fields`), with or without a document. Takes a selector. */
|
|
34
|
+
declare const useFormSettings: SettingsHook<import("@embedpdf/plugin-form").FormSettings>;
|
|
35
|
+
/**
|
|
36
|
+
* One field's value, in the shape `setValue()` takes, or `null`: re-renders
|
|
37
|
+
* only when that field's value changes. Empty without a document.
|
|
38
|
+
*/
|
|
39
|
+
declare function useFormValue(ref: FormFieldRef): FormFieldValue | null;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { FormLayer, useForm, useFormEvent, useFormSettings, useFormState, useFormValue };
|
|
42
|
+
//# sourceMappingURL=form.d.ts.map
|
package/dist/form.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { a as useFormSnapshot, i as useFormField, n as formWidgetRenderer, r as useForm, t as FormLayer } from "./form-CK3mp99m.js";
|
|
1
|
+
import { a as useFormState, i as useFormSettings, n as useForm, o as useFormValue, r as useFormEvent, t as FormLayer } from "./form-BSGvjA5D.js";
|
|
3
2
|
export * from "@embedpdf/plugin-form";
|
|
4
|
-
export { FormLayer,
|
|
3
|
+
export { FormLayer, useForm, useFormEvent, useFormSettings, useFormState, useFormValue };
|
package/dist/history.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./rolldown-runtime-DDXJien1.cjs");
|
|
3
|
+
const require_runtime = require("./runtime-BfnpyfY0.cjs");
|
|
4
|
+
const require_state = require("./state-Dtf8HAue.cjs");
|
|
5
|
+
let _embedpdf_plugin_history = require("@embedpdf/plugin-history");
|
|
6
|
+
//#region src/history.ts
|
|
7
|
+
/**
|
|
8
|
+
* The history (undo, redo, canUndo, canRedo, the labels, clear) of the
|
|
9
|
+
* surrounding `<DocumentScope>`'s document, else the active one. Outside a
|
|
10
|
+
* document, every method throws `not-ready`.
|
|
11
|
+
*/
|
|
12
|
+
function useHistory() {
|
|
13
|
+
return require_runtime.useCapability(_embedpdf_plugin_history.HistoryToken);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether undo and redo can run, and what they would undo and redo (the
|
|
17
|
+
* page's State table, declared once in `historyState`). Takes a selector, and
|
|
18
|
+
* re-renders only when what it returns changes.
|
|
19
|
+
*/
|
|
20
|
+
const useHistoryState = require_state.stateHook(_embedpdf_plugin_history.historyState);
|
|
21
|
+
/** Subscribe to one history event for the mounted lifetime: `useHistoryEvent((history) => history.onUndone, handler)`. */
|
|
22
|
+
function useHistoryEvent(select, handler) {
|
|
23
|
+
require_runtime.useCapabilityEvent(_embedpdf_plugin_history.HistoryToken, select, handler);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.useHistory = useHistory;
|
|
27
|
+
exports.useHistoryEvent = useHistoryEvent;
|
|
28
|
+
exports.useHistoryState = useHistoryState;
|
|
29
|
+
Object.keys(_embedpdf_plugin_history).forEach(function(k) {
|
|
30
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return _embedpdf_plugin_history[k];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=history.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.cjs","names":["useCapability","HistoryToken","stateHook","historyState"],"sources":["../src/history.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-history: undo and redo of what you\n * change through the viewer, one history per open document. An action shows\n * undone at once, even while it is still on its way to the engine.\n *\n * const history = useHistory();\n * const { canUndo, undoLabel } = useHistoryState();\n * <button disabled={!canUndo} onClick={() => history.undo()}>Undo</button>\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-history';\nimport type { EventHook } from '@embedpdf/core';\nimport { HistoryToken, historyState, type HistoryCapability } from '@embedpdf/plugin-history';\n\nimport { useCapability, useCapabilityEvent } from './runtime';\nimport { stateHook } from './state';\n\n/**\n * The history (undo, redo, canUndo, canRedo, the labels, clear) of the\n * surrounding `<DocumentScope>`'s document, else the active one. Outside a\n * document, every method throws `not-ready`.\n */\nexport function useHistory(): HistoryCapability {\n return useCapability(HistoryToken);\n}\n\n/**\n * Whether undo and redo can run, and what they would undo and redo (the\n * page's State table, declared once in `historyState`). Takes a selector, and\n * re-renders only when what it returns changes.\n */\nexport const useHistoryState = stateHook(historyState);\n\n/** Subscribe to one history event for the mounted lifetime: `useHistoryEvent((history) => history.onUndone, handler)`. */\nexport function useHistoryEvent<T>(\n select: (history: HistoryCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(HistoryToken, select, handler);\n}\n"],"mappings":";;;;;;;;;;;AAuBA,SAAgB,aAAgC;CAC9C,OAAOA,gBAAAA,cAAcC,yBAAAA,YAAY;AACnC;;;;;;AAOA,MAAa,kBAAkBC,cAAAA,UAAUC,yBAAAA,YAAY;;AAGrD,SAAgB,gBACd,QACA,SACM;CACN,gBAAA,mBAAmBF,yBAAAA,cAAc,QAAQ,OAAO;AAClD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { n as StateHook } from "./state-0K1I5cM4.cjs";
|
|
2
|
+
import { EventHook } from "@embedpdf/core";
|
|
3
|
+
import { HistoryCapability } from "@embedpdf/plugin-history";
|
|
4
|
+
export * from "@embedpdf/plugin-history";
|
|
5
|
+
//#region src/history.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The history (undo, redo, canUndo, canRedo, the labels, clear) of the
|
|
8
|
+
* surrounding `<DocumentScope>`'s document, else the active one. Outside a
|
|
9
|
+
* document, every method throws `not-ready`.
|
|
10
|
+
*/
|
|
11
|
+
declare function useHistory(): HistoryCapability;
|
|
12
|
+
/**
|
|
13
|
+
* Whether undo and redo can run, and what they would undo and redo (the
|
|
14
|
+
* page's State table, declared once in `historyState`). Takes a selector, and
|
|
15
|
+
* re-renders only when what it returns changes.
|
|
16
|
+
*/
|
|
17
|
+
declare const useHistoryState: StateHook<{
|
|
18
|
+
canUndo: boolean;
|
|
19
|
+
canRedo: boolean;
|
|
20
|
+
undoLabel: import("@embedpdf/core").ChangeLabel | null;
|
|
21
|
+
redoLabel: import("@embedpdf/core").ChangeLabel | null;
|
|
22
|
+
}>;
|
|
23
|
+
/** Subscribe to one history event for the mounted lifetime: `useHistoryEvent((history) => history.onUndone, handler)`. */
|
|
24
|
+
declare function useHistoryEvent<T>(select: (history: HistoryCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { useHistory, useHistoryEvent, useHistoryState };
|
|
27
|
+
//# sourceMappingURL=history.d.cts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { n as StateHook } from "./state-0K1I5cM4.js";
|
|
2
|
+
import { EventHook } from "@embedpdf/core";
|
|
3
|
+
import { HistoryCapability } from "@embedpdf/plugin-history";
|
|
4
|
+
export * from "@embedpdf/plugin-history";
|
|
5
|
+
//#region src/history.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The history (undo, redo, canUndo, canRedo, the labels, clear) of the
|
|
8
|
+
* surrounding `<DocumentScope>`'s document, else the active one. Outside a
|
|
9
|
+
* document, every method throws `not-ready`.
|
|
10
|
+
*/
|
|
11
|
+
declare function useHistory(): HistoryCapability;
|
|
12
|
+
/**
|
|
13
|
+
* Whether undo and redo can run, and what they would undo and redo (the
|
|
14
|
+
* page's State table, declared once in `historyState`). Takes a selector, and
|
|
15
|
+
* re-renders only when what it returns changes.
|
|
16
|
+
*/
|
|
17
|
+
declare const useHistoryState: StateHook<{
|
|
18
|
+
canUndo: boolean;
|
|
19
|
+
canRedo: boolean;
|
|
20
|
+
undoLabel: import("@embedpdf/core").ChangeLabel | null;
|
|
21
|
+
redoLabel: import("@embedpdf/core").ChangeLabel | null;
|
|
22
|
+
}>;
|
|
23
|
+
/** Subscribe to one history event for the mounted lifetime: `useHistoryEvent((history) => history.onUndone, handler)`. */
|
|
24
|
+
declare function useHistoryEvent<T>(select: (history: HistoryCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { useHistory, useHistoryEvent, useHistoryState };
|
|
27
|
+
//# sourceMappingURL=history.d.ts.map
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { f as useCapability, p as useCapabilityEvent } from "./runtime-tD5iJU83.js";
|
|
2
|
+
import { n as stateHook } from "./state-CzI2KlZb.js";
|
|
3
|
+
import { HistoryToken, historyState } from "@embedpdf/plugin-history";
|
|
4
|
+
export * from "@embedpdf/plugin-history";
|
|
5
|
+
//#region src/history.ts
|
|
6
|
+
/**
|
|
7
|
+
* The history (undo, redo, canUndo, canRedo, the labels, clear) of the
|
|
8
|
+
* surrounding `<DocumentScope>`'s document, else the active one. Outside a
|
|
9
|
+
* document, every method throws `not-ready`.
|
|
10
|
+
*/
|
|
11
|
+
function useHistory() {
|
|
12
|
+
return useCapability(HistoryToken);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether undo and redo can run, and what they would undo and redo (the
|
|
16
|
+
* page's State table, declared once in `historyState`). Takes a selector, and
|
|
17
|
+
* re-renders only when what it returns changes.
|
|
18
|
+
*/
|
|
19
|
+
const useHistoryState = stateHook(historyState);
|
|
20
|
+
/** Subscribe to one history event for the mounted lifetime: `useHistoryEvent((history) => history.onUndone, handler)`. */
|
|
21
|
+
function useHistoryEvent(select, handler) {
|
|
22
|
+
useCapabilityEvent(HistoryToken, select, handler);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useHistory, useHistoryEvent, useHistoryState };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","names":[],"sources":["../src/history.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-history: undo and redo of what you\n * change through the viewer, one history per open document. An action shows\n * undone at once, even while it is still on its way to the engine.\n *\n * const history = useHistory();\n * const { canUndo, undoLabel } = useHistoryState();\n * <button disabled={!canUndo} onClick={() => history.undo()}>Undo</button>\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-history';\nimport type { EventHook } from '@embedpdf/core';\nimport { HistoryToken, historyState, type HistoryCapability } from '@embedpdf/plugin-history';\n\nimport { useCapability, useCapabilityEvent } from './runtime';\nimport { stateHook } from './state';\n\n/**\n * The history (undo, redo, canUndo, canRedo, the labels, clear) of the\n * surrounding `<DocumentScope>`'s document, else the active one. Outside a\n * document, every method throws `not-ready`.\n */\nexport function useHistory(): HistoryCapability {\n return useCapability(HistoryToken);\n}\n\n/**\n * Whether undo and redo can run, and what they would undo and redo (the\n * page's State table, declared once in `historyState`). Takes a selector, and\n * re-renders only when what it returns changes.\n */\nexport const useHistoryState = stateHook(historyState);\n\n/** Subscribe to one history event for the mounted lifetime: `useHistoryEvent((history) => history.onUndone, handler)`. */\nexport function useHistoryEvent<T>(\n select: (history: HistoryCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(HistoryToken, select, handler);\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,aAAgC;CAC9C,OAAO,cAAc,YAAY;AACnC;;;;;;AAOA,MAAa,kBAAkB,UAAU,YAAY;;AAGrD,SAAgB,gBACd,QACA,SACM;CACN,mBAAmB,cAAc,QAAQ,OAAO;AAClD"}
|
package/dist/i18n.cjs
CHANGED
|
@@ -1,44 +1,40 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
require("./rolldown-runtime-DDXJien1.cjs");
|
|
3
|
+
const require_runtime = require("./runtime-BfnpyfY0.cjs");
|
|
4
|
+
const require_state = require("./state-Dtf8HAue.cjs");
|
|
4
5
|
let _embedpdf_plugin_i18n = require("@embedpdf/plugin-i18n");
|
|
5
6
|
//#region src/i18n.ts
|
|
6
|
-
/** The
|
|
7
|
-
|
|
7
|
+
/** The i18n capability: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */
|
|
8
|
+
function useI18n() {
|
|
9
|
+
return require_runtime.useCapability(_embedpdf_plugin_i18n.I18nToken);
|
|
10
|
+
}
|
|
11
|
+
/** Subscribe to one i18n event for the mounted lifetime: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */
|
|
12
|
+
function useI18nEvent(select, handler) {
|
|
13
|
+
require_runtime.useCapabilityEvent(_embedpdf_plugin_i18n.I18nToken, select, handler);
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* const t = useT();
|
|
13
|
-
* <button title={t('commands.zoom.in')}>+</button>
|
|
14
|
-
* <span>{t('pages', { params: { count } })}</span>
|
|
16
|
+
* The current language, how it reads, every language you can switch to, and the one loading (the
|
|
17
|
+
* translations page's State table, declared once in `i18nState`). Takes a selector, and
|
|
18
|
+
* re-renders only when what it returns changes.
|
|
15
19
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const localeListEqual = (a, b) => a.length === b.length && a.every((x, i) => x.code === b[i].code && x.name === b[i].name && x.loaded === b[i].loaded);
|
|
20
|
+
const useI18nState = require_state.stateHook(_embedpdf_plugin_i18n.i18nState);
|
|
21
|
+
/** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */
|
|
22
|
+
const useI18nSettings = require_state.settingsHook(_embedpdf_plugin_i18n.I18nToken);
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* A translate function that re-renders the component when the language or the strings change,
|
|
25
|
+
* and keeps its identity otherwise, so memoized children holding it re-render too.
|
|
23
26
|
*
|
|
24
|
-
* const
|
|
27
|
+
* const t = useT();
|
|
28
|
+
* <span>{t('search.results', { params: { count } })}</span>
|
|
25
29
|
*/
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
const locale = require_runtime.useSelector(_embedpdf_plugin_i18n.I18nToken, (c) => c.locale());
|
|
29
|
-
const dir = require_runtime.useSelector(_embedpdf_plugin_i18n.I18nToken, (c) => c.dir());
|
|
30
|
-
const loading = require_runtime.useSelector(_embedpdf_plugin_i18n.I18nToken, (c) => c.loading());
|
|
31
|
-
return {
|
|
32
|
-
locale,
|
|
33
|
-
dir,
|
|
34
|
-
locales: require_runtime.useSelector(_embedpdf_plugin_i18n.I18nToken, (c) => c.locales(), localeListEqual),
|
|
35
|
-
loading,
|
|
36
|
-
setLocale: i18n.setLocale
|
|
37
|
-
};
|
|
30
|
+
function useT() {
|
|
31
|
+
return require_runtime.useSelector(_embedpdf_plugin_i18n.I18nToken, (i18n) => i18n.getTranslator());
|
|
38
32
|
}
|
|
39
33
|
//#endregion
|
|
40
34
|
exports.useI18n = useI18n;
|
|
41
|
-
exports.
|
|
35
|
+
exports.useI18nEvent = useI18nEvent;
|
|
36
|
+
exports.useI18nSettings = useI18nSettings;
|
|
37
|
+
exports.useI18nState = useI18nState;
|
|
42
38
|
exports.useT = useT;
|
|
43
39
|
Object.keys(_embedpdf_plugin_i18n).forEach(function(k) {
|
|
44
40
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
package/dist/i18n.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.cjs","names":["useCapability","I18nToken","
|
|
1
|
+
{"version":3,"file":"i18n.cjs","names":["useCapability","I18nToken","stateHook","i18nState","settingsHook","useSelector"],"sources":["../src/i18n.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-i18n. The plugin is workspace-scoped\n * and needs no engine, so these hooks work from the first frame, before a\n * document opens: a loading screen and a password prompt translate too.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-i18n';\nimport { I18nToken, i18nState } from '@embedpdf/plugin-i18n';\nimport type { I18nCapability, TranslateOptions } from '@embedpdf/plugin-i18n';\nimport type { EventHook } from '@embedpdf/core';\nimport { useCapability, useCapabilityEvent, useSelector } from './runtime';\nimport { settingsHook, stateHook } from './state';\n\n/** The i18n capability: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */\nexport function useI18n(): I18nCapability {\n return useCapability(I18nToken);\n}\n\n/** Subscribe to one i18n event for the mounted lifetime: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */\nexport function useI18nEvent<T>(\n select: (i18n: I18nCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(I18nToken, select, handler);\n}\n\n/**\n * The current language, how it reads, every language you can switch to, and the one loading (the\n * translations page's State table, declared once in `i18nState`). Takes a selector, and\n * re-renders only when what it returns changes.\n */\nexport const useI18nState = stateHook(i18nState);\n\n/** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */\nexport const useI18nSettings = settingsHook(I18nToken);\n\n/**\n * A translate function that re-renders the component when the language or the strings change,\n * and keeps its identity otherwise, so memoized children holding it re-render too.\n *\n * const t = useT();\n * <span>{t('search.results', { params: { count } })}</span>\n */\nexport function useT(): (key: string, options?: TranslateOptions) => string {\n return useSelector(I18nToken, (i18n) => i18n.getTranslator());\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,UAA0B;CACxC,OAAOA,gBAAAA,cAAcC,sBAAAA,SAAS;AAChC;;AAGA,SAAgB,aACd,QACA,SACM;CACN,gBAAA,mBAAmBA,sBAAAA,WAAW,QAAQ,OAAO;AAC/C;;;;;;AAOA,MAAa,eAAeC,cAAAA,UAAUC,sBAAAA,SAAS;;AAG/C,MAAa,kBAAkBC,cAAAA,aAAaH,sBAAAA,SAAS;;;;;;;;AASrD,SAAgB,OAA4D;CAC1E,OAAOI,gBAAAA,YAAYJ,sBAAAA,YAAY,SAAS,KAAK,cAAc,CAAC;AAC9D"}
|
package/dist/i18n.d.cts
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.cjs";
|
|
2
|
+
import { EventHook } from "@embedpdf/core";
|
|
3
|
+
import { I18nCapability, TranslateOptions } from "@embedpdf/plugin-i18n";
|
|
2
4
|
export * from "@embedpdf/plugin-i18n";
|
|
3
5
|
//#region src/i18n.d.ts
|
|
4
|
-
/** The
|
|
5
|
-
declare
|
|
6
|
+
/** The i18n capability: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */
|
|
7
|
+
declare function useI18n(): I18nCapability;
|
|
8
|
+
/** Subscribe to one i18n event for the mounted lifetime: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */
|
|
9
|
+
declare function useI18nEvent<T>(select: (i18n: I18nCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* const t = useT();
|
|
11
|
-
* <button title={t('commands.zoom.in')}>+</button>
|
|
12
|
-
* <span>{t('pages', { params: { count } })}</span>
|
|
11
|
+
* The current language, how it reads, every language you can switch to, and the one loading (the
|
|
12
|
+
* translations page's State table, declared once in `i18nState`). Takes a selector, and
|
|
13
|
+
* re-renders only when what it returns changes.
|
|
13
14
|
*/
|
|
14
|
-
declare
|
|
15
|
+
declare const useI18nState: StateHook<{
|
|
16
|
+
locale: string;
|
|
17
|
+
direction: import("@embedpdf/plugin-i18n").TextDirection;
|
|
18
|
+
locales: readonly import("@embedpdf/plugin-i18n").LocaleInfo[];
|
|
19
|
+
loading: string | null;
|
|
20
|
+
}>;
|
|
21
|
+
/** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */
|
|
22
|
+
declare const useI18nSettings: SettingsHook<import("@embedpdf/plugin-i18n").I18nSettings>;
|
|
15
23
|
/**
|
|
16
|
-
*
|
|
24
|
+
* A translate function that re-renders the component when the language or the strings change,
|
|
25
|
+
* and keeps its identity otherwise, so memoized children holding it re-render too.
|
|
17
26
|
*
|
|
18
|
-
* const
|
|
27
|
+
* const t = useT();
|
|
28
|
+
* <span>{t('search.results', { params: { count } })}</span>
|
|
19
29
|
*/
|
|
20
|
-
declare function
|
|
21
|
-
locale: string;
|
|
22
|
-
dir: 'ltr' | 'rtl';
|
|
23
|
-
locales: LocaleInfo[];
|
|
24
|
-
/** Code of a lazy pack being fetched, if any — show a spinner on it. */
|
|
25
|
-
loading: string | null;
|
|
26
|
-
setLocale: (code: string) => void;
|
|
27
|
-
};
|
|
30
|
+
declare function useT(): (key: string, options?: TranslateOptions) => string;
|
|
28
31
|
//#endregion
|
|
29
|
-
export { useI18n,
|
|
32
|
+
export { useI18n, useI18nEvent, useI18nSettings, useI18nState, useT };
|
|
30
33
|
//# sourceMappingURL=i18n.d.cts.map
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.js";
|
|
2
|
+
import { EventHook } from "@embedpdf/core";
|
|
3
|
+
import { I18nCapability, TranslateOptions } from "@embedpdf/plugin-i18n";
|
|
2
4
|
export * from "@embedpdf/plugin-i18n";
|
|
3
5
|
//#region src/i18n.d.ts
|
|
4
|
-
/** The
|
|
5
|
-
declare
|
|
6
|
+
/** The i18n capability: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */
|
|
7
|
+
declare function useI18n(): I18nCapability;
|
|
8
|
+
/** Subscribe to one i18n event for the mounted lifetime: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */
|
|
9
|
+
declare function useI18nEvent<T>(select: (i18n: I18nCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* const t = useT();
|
|
11
|
-
* <button title={t('commands.zoom.in')}>+</button>
|
|
12
|
-
* <span>{t('pages', { params: { count } })}</span>
|
|
11
|
+
* The current language, how it reads, every language you can switch to, and the one loading (the
|
|
12
|
+
* translations page's State table, declared once in `i18nState`). Takes a selector, and
|
|
13
|
+
* re-renders only when what it returns changes.
|
|
13
14
|
*/
|
|
14
|
-
declare
|
|
15
|
+
declare const useI18nState: StateHook<{
|
|
16
|
+
locale: string;
|
|
17
|
+
direction: import("@embedpdf/plugin-i18n").TextDirection;
|
|
18
|
+
locales: readonly import("@embedpdf/plugin-i18n").LocaleInfo[];
|
|
19
|
+
loading: string | null;
|
|
20
|
+
}>;
|
|
21
|
+
/** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */
|
|
22
|
+
declare const useI18nSettings: SettingsHook<import("@embedpdf/plugin-i18n").I18nSettings>;
|
|
15
23
|
/**
|
|
16
|
-
*
|
|
24
|
+
* A translate function that re-renders the component when the language or the strings change,
|
|
25
|
+
* and keeps its identity otherwise, so memoized children holding it re-render too.
|
|
17
26
|
*
|
|
18
|
-
* const
|
|
27
|
+
* const t = useT();
|
|
28
|
+
* <span>{t('search.results', { params: { count } })}</span>
|
|
19
29
|
*/
|
|
20
|
-
declare function
|
|
21
|
-
locale: string;
|
|
22
|
-
dir: 'ltr' | 'rtl';
|
|
23
|
-
locales: LocaleInfo[];
|
|
24
|
-
/** Code of a lazy pack being fetched, if any — show a spinner on it. */
|
|
25
|
-
loading: string | null;
|
|
26
|
-
setLocale: (code: string) => void;
|
|
27
|
-
};
|
|
30
|
+
declare function useT(): (key: string, options?: TranslateOptions) => string;
|
|
28
31
|
//#endregion
|
|
29
|
-
export { useI18n,
|
|
32
|
+
export { useI18n, useI18nEvent, useI18nSettings, useI18nState, useT };
|
|
30
33
|
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/i18n.js
CHANGED
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { I18nToken } from "@embedpdf/plugin-i18n";
|
|
1
|
+
import { E as useSelector, f as useCapability, p as useCapabilityEvent } from "./runtime-tD5iJU83.js";
|
|
2
|
+
import { n as stateHook, t as settingsHook } from "./state-CzI2KlZb.js";
|
|
3
|
+
import { I18nToken, i18nState } from "@embedpdf/plugin-i18n";
|
|
4
4
|
export * from "@embedpdf/plugin-i18n";
|
|
5
5
|
//#region src/i18n.ts
|
|
6
|
-
/** The
|
|
7
|
-
|
|
6
|
+
/** The i18n capability: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */
|
|
7
|
+
function useI18n() {
|
|
8
|
+
return useCapability(I18nToken);
|
|
9
|
+
}
|
|
10
|
+
/** Subscribe to one i18n event for the mounted lifetime: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */
|
|
11
|
+
function useI18nEvent(select, handler) {
|
|
12
|
+
useCapabilityEvent(I18nToken, select, handler);
|
|
13
|
+
}
|
|
8
14
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* const t = useT();
|
|
13
|
-
* <button title={t('commands.zoom.in')}>+</button>
|
|
14
|
-
* <span>{t('pages', { params: { count } })}</span>
|
|
15
|
+
* The current language, how it reads, every language you can switch to, and the one loading (the
|
|
16
|
+
* translations page's State table, declared once in `i18nState`). Takes a selector, and
|
|
17
|
+
* re-renders only when what it returns changes.
|
|
15
18
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const localeListEqual = (a, b) => a.length === b.length && a.every((x, i) => x.code === b[i].code && x.name === b[i].name && x.loaded === b[i].loaded);
|
|
19
|
+
const useI18nState = stateHook(i18nState);
|
|
20
|
+
/** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */
|
|
21
|
+
const useI18nSettings = settingsHook(I18nToken);
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* A translate function that re-renders the component when the language or the strings change,
|
|
24
|
+
* and keeps its identity otherwise, so memoized children holding it re-render too.
|
|
23
25
|
*
|
|
24
|
-
* const
|
|
26
|
+
* const t = useT();
|
|
27
|
+
* <span>{t('search.results', { params: { count } })}</span>
|
|
25
28
|
*/
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
const locale = useSelector(I18nToken, (c) => c.locale());
|
|
29
|
-
const dir = useSelector(I18nToken, (c) => c.dir());
|
|
30
|
-
const loading = useSelector(I18nToken, (c) => c.loading());
|
|
31
|
-
return {
|
|
32
|
-
locale,
|
|
33
|
-
dir,
|
|
34
|
-
locales: useSelector(I18nToken, (c) => c.locales(), localeListEqual),
|
|
35
|
-
loading,
|
|
36
|
-
setLocale: i18n.setLocale
|
|
37
|
-
};
|
|
29
|
+
function useT() {
|
|
30
|
+
return useSelector(I18nToken, (i18n) => i18n.getTranslator());
|
|
38
31
|
}
|
|
39
32
|
//#endregion
|
|
40
|
-
export { useI18n,
|
|
33
|
+
export { useI18n, useI18nEvent, useI18nSettings, useI18nState, useT };
|
|
41
34
|
|
|
42
35
|
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":[],"sources":["../src/i18n.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-i18n
|
|
1
|
+
{"version":3,"file":"i18n.js","names":[],"sources":["../src/i18n.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-i18n. The plugin is workspace-scoped\n * and needs no engine, so these hooks work from the first frame, before a\n * document opens: a loading screen and a password prompt translate too.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-i18n';\nimport { I18nToken, i18nState } from '@embedpdf/plugin-i18n';\nimport type { I18nCapability, TranslateOptions } from '@embedpdf/plugin-i18n';\nimport type { EventHook } from '@embedpdf/core';\nimport { useCapability, useCapabilityEvent, useSelector } from './runtime';\nimport { settingsHook, stateHook } from './state';\n\n/** The i18n capability: `t`, `setLocale`, `addTranslations`, `registerLocale`, the settings calls. */\nexport function useI18n(): I18nCapability {\n return useCapability(I18nToken);\n}\n\n/** Subscribe to one i18n event for the mounted lifetime: `useI18nEvent((i18n) => i18n.onLocaleChanged, handler)`. */\nexport function useI18nEvent<T>(\n select: (i18n: I18nCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(I18nToken, select, handler);\n}\n\n/**\n * The current language, how it reads, every language you can switch to, and the one loading (the\n * translations page's State table, declared once in `i18nState`). Takes a selector, and\n * re-renders only when what it returns changes.\n */\nexport const useI18nState = stateHook(i18nState);\n\n/** The i18n settings (`locale`, `fallbackLocale`, `locales`, `loaders`). Takes a selector. */\nexport const useI18nSettings = settingsHook(I18nToken);\n\n/**\n * A translate function that re-renders the component when the language or the strings change,\n * and keeps its identity otherwise, so memoized children holding it re-render too.\n *\n * const t = useT();\n * <span>{t('search.results', { params: { count } })}</span>\n */\nexport function useT(): (key: string, options?: TranslateOptions) => string {\n return useSelector(I18nToken, (i18n) => i18n.getTranslator());\n}\n"],"mappings":";;;;;;AAeA,SAAgB,UAA0B;CACxC,OAAO,cAAc,SAAS;AAChC;;AAGA,SAAgB,aACd,QACA,SACM;CACN,mBAAmB,WAAW,QAAQ,OAAO;AAC/C;;;;;;AAOA,MAAa,eAAe,UAAU,SAAS;;AAG/C,MAAa,kBAAkB,aAAa,SAAS;;;;;;;;AASrD,SAAgB,OAA4D;CAC1E,OAAO,YAAY,YAAY,SAAS,KAAK,cAAc,CAAC;AAC9D"}
|