@gjsify/node-gi 0.13.0 → 0.20.0

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/cairo.js ADDED
@@ -0,0 +1,570 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // @gjsify/node-gi/cairo — the GJS built-in `cairo` module on Node.
3
+ //
4
+ // GJS exposes a native cairo binding as `cairo` (`import cairo from 'cairo'` /
5
+ // `gi://cairo` / `imports.cairo`): the drawing constructors (Context, Surface,
6
+ // ImageSurface, Pattern, SolidPattern, …) plus the plain-object enums (Format,
7
+ // Operator, Content, …). Crucially, cairo's types are FOREIGN structs in
8
+ // GObject-Introspection, so a GI function taking/returning a cairo pointer (e.g. a
9
+ // Gtk.DrawingArea draw-func's cairo_t) marshals through this module — which is why
10
+ // an npm cairo package can't stand in.
11
+ //
12
+ // This module mirrors that surface on Node: the enums are ported verbatim from
13
+ // GJS, the constructors wrap the native cairo binding (`src/cairo.cc`, exposed as
14
+ // `native.__cairo`), and it registers its wrapper factories so the engine's
15
+ // foreign-struct seam can hand a cairo pointer back as a real cairo.Context /
16
+ // .Surface / .Pattern instance.
17
+ //
18
+ // The gjsify `--app node` build aliases the bare `cairo` specifier to this module
19
+ // (kept external — `ALIASES_GJS_FOR_NODE`); `imports.cairo` (globals.js) reuses it.
20
+ //
21
+ // Reference: GJS's cairo module — refs/gjs/modules/core/_cairo.js (enums) +
22
+ // refs/gjs/modules/cairo-*.cpp (constructors/methods) + refs/gjs/modules/esm/cairo.js
23
+ // (the `Object.assign({}, imports._cairo, cairoNative)` merge shape).
24
+ // Copyright (c) 2010 litl, LLC / GJS contributors. MIT OR LGPL-2.0-or-later.
25
+
26
+ import native from './index.js';
27
+
28
+ const c = native.__cairo;
29
+ if (c === undefined) {
30
+ throw new Error(
31
+ '@gjsify/node-gi/cairo: the native cairo binding is missing from the addon. ' +
32
+ 'Rebuild @gjsify/node-gi (node-gyp rebuild) — the addon must link libcairo.',
33
+ );
34
+ }
35
+
36
+ // ---- enums (ported verbatim from refs/gjs/modules/core/_cairo.js) -----------
37
+
38
+ export const Antialias = { DEFAULT: 0, NONE: 1, GRAY: 2, SUBPIXEL: 3 };
39
+
40
+ export const Content = { COLOR: 0x1000, ALPHA: 0x2000, COLOR_ALPHA: 0x3000 };
41
+
42
+ export const Extend = { NONE: 0, REPEAT: 1, REFLECT: 2, PAD: 3 };
43
+
44
+ export const FillRule = { WINDING: 0, EVEN_ODD: 1 };
45
+
46
+ export const Filter = { FAST: 0, GOOD: 1, BEST: 2, NEAREST: 3, BILINEAR: 4, GAUSSIAN: 5 };
47
+
48
+ export const FontSlant = { NORMAL: 0, ITALIC: 1, OBLIQUE: 2 };
49
+
50
+ export const FontWeight = { NORMAL: 0, BOLD: 1 };
51
+
52
+ export const Format = { ARGB32: 0, RGB24: 1, A8: 2, A1: 3, RGB16_565: 4 };
53
+
54
+ export const LineCap = {
55
+ BUTT: 0,
56
+ ROUND: 1,
57
+ SQUARE: 2,
58
+ /** @deprecated Historical typo of {@link LineCap.SQUARE}, kept for compatibility. */
59
+ SQUASH: 2,
60
+ };
61
+
62
+ export const LineJoin = { MITER: 0, ROUND: 1, BEVEL: 2 };
63
+
64
+ export const Operator = {
65
+ CLEAR: 0,
66
+ SOURCE: 1,
67
+ OVER: 2,
68
+ IN: 3,
69
+ OUT: 4,
70
+ ATOP: 5,
71
+ DEST: 6,
72
+ DEST_OVER: 7,
73
+ DEST_IN: 8,
74
+ DEST_OUT: 9,
75
+ DEST_ATOP: 10,
76
+ XOR: 11,
77
+ ADD: 12,
78
+ SATURATE: 13,
79
+ MULTIPLY: 14,
80
+ SCREEN: 15,
81
+ OVERLAY: 16,
82
+ DARKEN: 17,
83
+ LIGHTEN: 18,
84
+ COLOR_DODGE: 19,
85
+ COLOR_BURN: 20,
86
+ HARD_LIGHT: 21,
87
+ SOFT_LIGHT: 22,
88
+ DIFFERENCE: 23,
89
+ EXCLUSION: 24,
90
+ HSL_HUE: 25,
91
+ HSL_SATURATION: 26,
92
+ HSL_COLOR: 27,
93
+ HSL_LUMINOSITY: 28,
94
+ };
95
+
96
+ export const PatternType = { SOLID: 0, SURFACE: 1, LINEAR: 2, RADIAL: 3 };
97
+
98
+ export const SurfaceType = {
99
+ IMAGE: 0,
100
+ PDF: 1,
101
+ PS: 2,
102
+ XLIB: 3,
103
+ XCB: 4,
104
+ GLITZ: 5,
105
+ QUARTZ: 6,
106
+ WIN32: 7,
107
+ BEOS: 8,
108
+ DIRECTFB: 9,
109
+ SVG: 10,
110
+ OS2: 11,
111
+ WIN32_PRINTING: 12,
112
+ QUARTZ_IMAGE: 13,
113
+ };
114
+
115
+ // ---- wrappers ---------------------------------------------------------------
116
+ //
117
+ // Each JS wrapper holds its native cairo handle (a type-tagged External) under a
118
+ // non-enumerable `_ptr` property — kept in sync with kCairoPtrProp in src/cairo.cc
119
+ // (the foreign to_func reads it; the native methods take `this._ptr` directly).
120
+
121
+ const H = '_ptr';
122
+
123
+ function setHandle(obj, handle) {
124
+ Object.defineProperty(obj, H, { value: handle, writable: true, configurable: true });
125
+ return obj;
126
+ }
127
+
128
+ // Build a wrapper for an existing native handle WITHOUT running the class
129
+ // constructor (which would allocate a fresh cairo object) — used by the static
130
+ // `create*` factories + the foreign from_func factories.
131
+ function wrapRaw(Klass, handle) {
132
+ return setHandle(Object.create(Klass.prototype), handle);
133
+ }
134
+
135
+ function handleOf(x, what) {
136
+ const h = x != null ? x[H] : undefined;
137
+ if (h === undefined) throw new TypeError(`expected a ${what}`);
138
+ return h;
139
+ }
140
+
141
+ /** cairo drawing context. `new cairo.Context(surface)` wraps `cairo_create`. */
142
+ export class Context {
143
+ constructor(surface) {
144
+ setHandle(this, c.contextCreate(handleOf(surface, 'cairo.Surface')));
145
+ }
146
+
147
+ save() {
148
+ c.save(this[H]);
149
+ }
150
+ restore() {
151
+ c.restore(this[H]);
152
+ }
153
+ newPath() {
154
+ c.newPath(this[H]);
155
+ }
156
+ closePath() {
157
+ c.closePath(this[H]);
158
+ }
159
+
160
+ moveTo(x, y) {
161
+ c.moveTo(this[H], x, y);
162
+ }
163
+ lineTo(x, y) {
164
+ c.lineTo(this[H], x, y);
165
+ }
166
+ relMoveTo(dx, dy) {
167
+ c.relMoveTo(this[H], dx, dy);
168
+ }
169
+ relLineTo(dx, dy) {
170
+ c.relLineTo(this[H], dx, dy);
171
+ }
172
+ rectangle(x, y, width, height) {
173
+ c.rectangle(this[H], x, y, width, height);
174
+ }
175
+ arc(xc, yc, radius, angle1, angle2) {
176
+ c.arc(this[H], xc, yc, radius, angle1, angle2);
177
+ }
178
+ arcNegative(xc, yc, radius, angle1, angle2) {
179
+ c.arcNegative(this[H], xc, yc, radius, angle1, angle2);
180
+ }
181
+ curveTo(x1, y1, x2, y2, x3, y3) {
182
+ c.curveTo(this[H], x1, y1, x2, y2, x3, y3);
183
+ }
184
+
185
+ fill() {
186
+ c.fill(this[H]);
187
+ }
188
+ fillPreserve() {
189
+ c.fillPreserve(this[H]);
190
+ }
191
+ stroke() {
192
+ c.stroke(this[H]);
193
+ }
194
+ strokePreserve() {
195
+ c.strokePreserve(this[H]);
196
+ }
197
+ paint() {
198
+ c.paint(this[H]);
199
+ }
200
+ paintWithAlpha(alpha) {
201
+ c.paintWithAlpha(this[H], alpha);
202
+ }
203
+ clip() {
204
+ c.clip(this[H]);
205
+ }
206
+ clipPreserve() {
207
+ c.clipPreserve(this[H]);
208
+ }
209
+
210
+ translate(tx, ty) {
211
+ c.translate(this[H], tx, ty);
212
+ }
213
+ scale(sx, sy) {
214
+ c.scale(this[H], sx, sy);
215
+ }
216
+ rotate(angle) {
217
+ c.rotate(this[H], angle);
218
+ }
219
+ identityMatrix() {
220
+ c.identityMatrix(this[H]);
221
+ }
222
+ newSubPath() {
223
+ c.newSubPath(this[H]);
224
+ }
225
+ /** User → device coordinates as `[x, y]` (GJS return shape). */
226
+ userToDevice(x, y) {
227
+ return c.userToDevice(this[H], x, y);
228
+ }
229
+ /** User → device distance (ignores translation) as `[dx, dy]`. */
230
+ userToDeviceDistance(dx, dy) {
231
+ return c.userToDeviceDistance(this[H], dx, dy);
232
+ }
233
+ /** Device → user coordinates as `[x, y]`. */
234
+ deviceToUser(x, y) {
235
+ return c.deviceToUser(this[H], x, y);
236
+ }
237
+ /** Device → user distance (ignores translation) as `[dx, dy]`. */
238
+ deviceToUserDistance(dx, dy) {
239
+ return c.deviceToUserDistance(this[H], dx, dy);
240
+ }
241
+ /** Copy the current path into an owned {@link Path} handle. */
242
+ copyPath() {
243
+ return wrapRaw(Path, c.copyPath(this[H]));
244
+ }
245
+ /** Like {@link copyPath} but with curves flattened to line segments. */
246
+ copyPathFlat() {
247
+ return wrapRaw(Path, c.copyPathFlat(this[H]));
248
+ }
249
+ appendPath(path) {
250
+ c.appendPath(this[H], handleOf(path, 'cairo.Path'));
251
+ }
252
+ /**
253
+ * Set the stroke dash pattern. GJS semantics: holes/undefined entries are
254
+ * skipped, a non-positive value throws, an empty array disables dashing.
255
+ */
256
+ setDash(dashes, offset) {
257
+ c.setDash(this[H], dashes, offset);
258
+ }
259
+ getDashCount() {
260
+ return c.getDashCount(this[H]);
261
+ }
262
+ /**
263
+ * The current dash pattern as `[dashes, offset]`.
264
+ * Note: GJS ships only `getDashCount`; this is a node-gi convenience.
265
+ */
266
+ getDash() {
267
+ return c.getDash(this[H]);
268
+ }
269
+ inFill(x, y) {
270
+ return c.inFill(this[H], x, y);
271
+ }
272
+ inStroke(x, y) {
273
+ return c.inStroke(this[H], x, y);
274
+ }
275
+
276
+ setSourceRGB(red, green, blue) {
277
+ c.setSourceRGB(this[H], red, green, blue);
278
+ }
279
+ setSourceRGBA(red, green, blue, alpha) {
280
+ c.setSourceRGBA(this[H], red, green, blue, alpha);
281
+ }
282
+ setSource(pattern) {
283
+ c.setSource(this[H], handleOf(pattern, 'cairo.Pattern'));
284
+ }
285
+ setSourceSurface(surface, x, y) {
286
+ c.setSourceSurface(this[H], handleOf(surface, 'cairo.Surface'), x, y);
287
+ }
288
+ /** The context's current source pattern (a ref of its own — safe to keep). */
289
+ getSource() {
290
+ return wrapPatternHandle(c.getSource(this[H]));
291
+ }
292
+
293
+ setLineWidth(width) {
294
+ c.setLineWidth(this[H], width);
295
+ }
296
+ getLineWidth() {
297
+ return c.getLineWidth(this[H]);
298
+ }
299
+ getOperator() {
300
+ return c.getOperator(this[H]);
301
+ }
302
+ getLineCap() {
303
+ return c.getLineCap(this[H]);
304
+ }
305
+ getLineJoin() {
306
+ return c.getLineJoin(this[H]);
307
+ }
308
+ getFillRule() {
309
+ return c.getFillRule(this[H]);
310
+ }
311
+ getAntialias() {
312
+ return c.getAntialias(this[H]);
313
+ }
314
+ getMiterLimit() {
315
+ return c.getMiterLimit(this[H]);
316
+ }
317
+ getTolerance() {
318
+ return c.getTolerance(this[H]);
319
+ }
320
+ hasCurrentPoint() {
321
+ return c.hasCurrentPoint(this[H]);
322
+ }
323
+ /** The current path point as `[x, y]`. */
324
+ getCurrentPoint() {
325
+ return c.getCurrentPoint(this[H]);
326
+ }
327
+ /** Current-path bounding box as `[x1, y1, x2, y2]`. */
328
+ pathExtents() {
329
+ return c.pathExtents(this[H]);
330
+ }
331
+ /** Fill bounding box as `[x1, y1, x2, y2]`. */
332
+ fillExtents() {
333
+ return c.fillExtents(this[H]);
334
+ }
335
+ /** Stroke bounding box as `[x1, y1, x2, y2]`. */
336
+ strokeExtents() {
337
+ return c.strokeExtents(this[H]);
338
+ }
339
+ /** Clip bounding box as `[x1, y1, x2, y2]`. */
340
+ clipExtents() {
341
+ return c.clipExtents(this[H]);
342
+ }
343
+ setLineCap(lineCap) {
344
+ c.setLineCap(this[H], lineCap);
345
+ }
346
+ setLineJoin(lineJoin) {
347
+ c.setLineJoin(this[H], lineJoin);
348
+ }
349
+ setFillRule(fillRule) {
350
+ c.setFillRule(this[H], fillRule);
351
+ }
352
+ setAntialias(antialias) {
353
+ c.setAntialias(this[H], antialias);
354
+ }
355
+ setOperator(op) {
356
+ c.setOperator(this[H], op);
357
+ }
358
+ setMiterLimit(limit) {
359
+ c.setMiterLimit(this[H], limit);
360
+ }
361
+ setTolerance(tolerance) {
362
+ c.setTolerance(this[H], tolerance);
363
+ }
364
+
365
+ status() {
366
+ return c.status(this[H]);
367
+ }
368
+
369
+ /** Eagerly destroy the underlying `cairo_t` (GJS `$dispose`). */
370
+ $dispose() {
371
+ c.dispose(this[H]);
372
+ }
373
+ }
374
+
375
+ /** cairo surface base class — the shared Surface API (flush/finish/writeToPNG/…). */
376
+ export class Surface {
377
+ getType() {
378
+ return c.surfaceGetType(this[H]);
379
+ }
380
+ status() {
381
+ return c.surfaceStatus(this[H]);
382
+ }
383
+ flush() {
384
+ c.surfaceFlush(this[H]);
385
+ }
386
+ finish() {
387
+ c.surfaceFinish(this[H]);
388
+ }
389
+ writeToPNG(filename) {
390
+ c.surfaceWriteToPNG(this[H], filename);
391
+ }
392
+ /** Eagerly destroy the underlying `cairo_surface_t` (GJS `$dispose`). */
393
+ $dispose() {
394
+ c.dispose(this[H]);
395
+ }
396
+ }
397
+
398
+ /** An in-memory image surface (`cairo_image_surface_*`). */
399
+ export class ImageSurface extends Surface {
400
+ constructor(format, width, height) {
401
+ super();
402
+ setHandle(this, c.imageSurfaceCreate(format, width, height));
403
+ }
404
+
405
+ static create(format, width, height) {
406
+ return new ImageSurface(format, width, height);
407
+ }
408
+ static createFromPNG(filename) {
409
+ return wrapRaw(ImageSurface, c.imageSurfaceCreateFromPNG(filename));
410
+ }
411
+
412
+ getWidth() {
413
+ return c.imageSurfaceGetWidth(this[H]);
414
+ }
415
+ getHeight() {
416
+ return c.imageSurfaceGetHeight(this[H]);
417
+ }
418
+ getStride() {
419
+ return c.imageSurfaceGetStride(this[H]);
420
+ }
421
+ getFormat() {
422
+ return c.imageSurfaceGetFormat(this[H]);
423
+ }
424
+ /**
425
+ * The raw pixel buffer as a fresh Uint8Array copy (length = stride * height).
426
+ * Note: GJS ships no `getData`; this is a node-gi convenience for headless pixel
427
+ * assertions. The buffer is flushed first + copied (independent of the surface).
428
+ */
429
+ getData() {
430
+ return c.imageSurfaceGetData(this[H]);
431
+ }
432
+ }
433
+
434
+ /** cairo pattern base class. */
435
+ export class Pattern {
436
+ getType() {
437
+ return c.patternGetType(this[H]);
438
+ }
439
+ status() {
440
+ return c.patternStatus(this[H]);
441
+ }
442
+ /** Eagerly destroy the underlying `cairo_pattern_t` (GJS `$dispose`). */
443
+ $dispose() {
444
+ c.dispose(this[H]);
445
+ }
446
+ }
447
+
448
+ /** A solid-color pattern (`cairo_pattern_create_rgb[a]`). */
449
+ export class SolidPattern extends Pattern {
450
+ static createRGB(red, green, blue) {
451
+ return wrapRaw(SolidPattern, c.solidPatternCreateRGB(red, green, blue));
452
+ }
453
+ static createRGBA(red, green, blue, alpha) {
454
+ return wrapRaw(SolidPattern, c.solidPatternCreateRGBA(red, green, blue, alpha));
455
+ }
456
+ }
457
+
458
+ /** Gradient base class — the shared color-stop API (GJS `CairoGradient`). */
459
+ export class Gradient extends Pattern {
460
+ addColorStopRGB(offset, red, green, blue) {
461
+ c.patternAddColorStopRGB(this[H], offset, red, green, blue);
462
+ }
463
+ addColorStopRGBA(offset, red, green, blue, alpha) {
464
+ c.patternAddColorStopRGBA(this[H], offset, red, green, blue, alpha);
465
+ }
466
+ }
467
+
468
+ /** A linear gradient (`cairo_pattern_create_linear`). */
469
+ export class LinearGradient extends Gradient {
470
+ constructor(x0, y0, x1, y1) {
471
+ super();
472
+ setHandle(this, c.linearGradientCreate(x0, y0, x1, y1));
473
+ }
474
+ }
475
+
476
+ /** A radial gradient (`cairo_pattern_create_radial`). */
477
+ export class RadialGradient extends Gradient {
478
+ constructor(cx0, cy0, radius0, cx1, cy1, radius1) {
479
+ super();
480
+ setHandle(this, c.radialGradientCreate(cx0, cy0, radius0, cx1, cy1, radius1));
481
+ }
482
+ }
483
+
484
+ /** A surface-backed pattern (`cairo_pattern_create_for_surface`). */
485
+ export class SurfacePattern extends Pattern {
486
+ constructor(surface) {
487
+ super();
488
+ setHandle(this, c.surfacePatternCreate(handleOf(surface, 'cairo.Surface')));
489
+ }
490
+
491
+ setExtend(extend) {
492
+ c.patternSetExtend(this[H], extend);
493
+ }
494
+ getExtend() {
495
+ return c.patternGetExtend(this[H]);
496
+ }
497
+ setFilter(filter) {
498
+ c.patternSetFilter(this[H], filter);
499
+ }
500
+ getFilter() {
501
+ return c.patternGetFilter(this[H]);
502
+ }
503
+ }
504
+
505
+ /**
506
+ * An opaque copied path (`cairo_path_t`, from `Context.copyPath[Flat]()`).
507
+ * Method-less in GJS too — it only round-trips through `appendPath` / GI calls.
508
+ * The underlying path is destroyed on GC (`cairo_path_destroy`).
509
+ */
510
+ export class Path {}
511
+
512
+ // Fan a pattern handle out to the concrete subclass by cairo runtime type —
513
+ // mirrors gjs_cairo_pattern_from_pattern (MESH/RASTER_SOURCE fall back to the
514
+ // base Pattern; gjs throws for those, but they are unreachable from this module).
515
+ function wrapPatternHandle(handle) {
516
+ const t = c.patternGetType(handle);
517
+ const Klass =
518
+ t === PatternType.SOLID
519
+ ? SolidPattern
520
+ : t === PatternType.SURFACE
521
+ ? SurfacePattern
522
+ : t === PatternType.LINEAR
523
+ ? LinearGradient
524
+ : t === PatternType.RADIAL
525
+ ? RadialGradient
526
+ : Pattern;
527
+ return wrapRaw(Klass, handle);
528
+ }
529
+
530
+ // Register the wrapper factories so the engine's foreign-struct from_func can turn
531
+ // a returned/callback cairo pointer into the right JS instance. Surface + Pattern
532
+ // fan out to the concrete subclass by cairo runtime type (mirrors
533
+ // CairoSurface::from_c_ptr / gjs_cairo_pattern_from_pattern).
534
+ c.setup({
535
+ context: (handle) => wrapRaw(Context, handle),
536
+ surface: (handle) =>
537
+ wrapRaw(c.surfaceGetType(handle) === SurfaceType.IMAGE ? ImageSurface : Surface, handle),
538
+ pattern: (handle) => wrapPatternHandle(handle),
539
+ path: (handle) => wrapRaw(Path, handle),
540
+ });
541
+
542
+ // The default export mirrors GJS's ESM `cairo` object (enums + constructors), the
543
+ // shape `import cairo from 'cairo'` returns.
544
+ const cairo = {
545
+ Antialias,
546
+ Content,
547
+ Extend,
548
+ FillRule,
549
+ Filter,
550
+ FontSlant,
551
+ FontWeight,
552
+ Format,
553
+ LineCap,
554
+ LineJoin,
555
+ Operator,
556
+ PatternType,
557
+ SurfaceType,
558
+ Context,
559
+ Surface,
560
+ ImageSurface,
561
+ Pattern,
562
+ SolidPattern,
563
+ Gradient,
564
+ LinearGradient,
565
+ RadialGradient,
566
+ SurfacePattern,
567
+ Path,
568
+ };
569
+
570
+ export default cairo;
package/gettext.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // @gjsify/node-gi/gettext — types for the GJS `Gettext` module on Node.
3
+
4
+ /** Look up `msgid` in the default domain (passthrough). */
5
+ export function gettext(msgid: string): string;
6
+ /** Look up `msgid` in `domain` (passthrough). */
7
+ export function dgettext(domain: string | null, msgid: string): string;
8
+ /** Look up `msgid` in `domain`/`category` (passthrough). */
9
+ export function dcgettext(domain: string | null, msgid: string, category: number): string;
10
+ /** Plural lookup in the default domain (passthrough). */
11
+ export function ngettext(msgid1: string, msgid2: string, n: number): string;
12
+ /** Plural lookup in `domain` (passthrough). */
13
+ export function dngettext(domain: string | null, msgid1: string, msgid2: string, n: number): string;
14
+ /** Context lookup in the default domain (passthrough). */
15
+ export function pgettext(context: string, msgid: string): string;
16
+ /** Context lookup in `domain` (passthrough). */
17
+ export function dpgettext(domain: string | null, context: string, msgid: string): string;
18
+ /** Domain-bound gettext bindings. */
19
+ export function domain(domainName: string): {
20
+ gettext(msgid: string): string;
21
+ ngettext(msgid1: string, msgid2: string, n: number): string;
22
+ pgettext(context: string, msgid: string): string;
23
+ };
24
+ /** Set the locale for `category` (no-op on Node). */
25
+ export function setlocale(category: number, locale: string | null): null;
26
+ /** Set the default text domain (no-op on Node). */
27
+ export function textdomain(domainName: string | null): null;
28
+ /** Bind a text domain to a directory (no-op on Node). */
29
+ export function bindtextdomain(domainName: string, dirName: string | null): null;
30
+ /** Set the output codeset for a text domain (no-op on Node). */
31
+ export function bindtextdomainCodeset(domainName: string, codeset: string | null): null;
32
+ /** The standard POSIX locale category constants. */
33
+ export const LocaleCategory: {
34
+ CTYPE: number;
35
+ NUMERIC: number;
36
+ TIME: number;
37
+ COLLATE: number;
38
+ MONETARY: number;
39
+ MESSAGES: number;
40
+ ALL: number;
41
+ };
42
+
43
+ /** The GJS `Gettext` module object (`import Gettext from 'gettext'`). */
44
+ export interface GettextModule {
45
+ gettext(msgid: string): string;
46
+ dgettext(domain: string | null, msgid: string): string;
47
+ dcgettext(domain: string | null, msgid: string, category: number): string;
48
+ ngettext(msgid1: string, msgid2: string, n: number): string;
49
+ dngettext(domain: string | null, msgid1: string, msgid2: string, n: number): string;
50
+ pgettext(context: string, msgid: string): string;
51
+ dpgettext(domain: string | null, context: string, msgid: string): string;
52
+ domain(domainName: string): {
53
+ gettext(msgid: string): string;
54
+ ngettext(msgid1: string, msgid2: string, n: number): string;
55
+ pgettext(context: string, msgid: string): string;
56
+ };
57
+ setlocale(category: number, locale: string | null): null;
58
+ textdomain(domainName: string | null): null;
59
+ bindtextdomain(domainName: string, dirName: string | null): null;
60
+ bindtextdomainCodeset(domainName: string, codeset: string | null): null;
61
+ LocaleCategory: typeof LocaleCategory;
62
+ }
63
+
64
+ declare const Gettext: GettextModule;
65
+ export default Gettext;