@gjsify/http2-native 0.4.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.
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";let e=null,t=!1,n=null;function loadNativeHttp2(){if(t)return e;t=!0;try{let t=globalThis.imports?.gi;if(!t)return n=Error(`imports.gi not available — not running under GJS?`),null;let r=t.GjsifyHttp2;return r?(e=r,e):(n=Error(`GjsifyHttp2 typelib not found on GI_TYPELIB_PATH`),null)}catch(t){return n=t instanceof Error?t:Error(String(t)),e=null,null}}function hasNativeHttp2(){return loadNativeHttp2()!==null}function getLoadError(){return n}export{getLoadError,hasNativeHttp2,loadNativeHttp2};
@@ -0,0 +1,27 @@
1
+ import type { GjsifyHttp2 as GjsifyHttp2NS } from 'gi://GjsifyHttp2?version=1.0';
2
+ type FrameEncoderInstance = GjsifyHttp2NS.FrameEncoder;
3
+ type FrameEncoderCtor = typeof GjsifyHttp2NS.FrameEncoder;
4
+ type StreamIdAllocatorInstance = GjsifyHttp2NS.StreamIdAllocator;
5
+ type StreamIdAllocatorCtor = typeof GjsifyHttp2NS.StreamIdAllocator;
6
+ type SessionBridgeStatic = typeof GjsifyHttp2NS.SessionBridge;
7
+ export interface NativeHttp2Module {
8
+ FrameEncoder: FrameEncoderCtor;
9
+ StreamIdAllocator: StreamIdAllocatorCtor;
10
+ SessionBridge: SessionBridgeStatic;
11
+ }
12
+ export type { FrameEncoderInstance as FrameEncoder };
13
+ export type { StreamIdAllocatorInstance as StreamIdAllocator };
14
+ /**
15
+ * Lazily load the GjsifyHttp2 typelib. Idempotent — subsequent calls
16
+ * return the cached module (or `null` if the first call failed).
17
+ */
18
+ export declare function loadNativeHttp2(): NativeHttp2Module | null;
19
+ /**
20
+ * Returns `true` if the GjsifyHttp2 typelib is loadable (prebuild present).
21
+ */
22
+ export declare function hasNativeHttp2(): boolean;
23
+ /**
24
+ * Returns the load error from the first `loadNativeHttp2()` call, or `null`
25
+ * if loading succeeded or hasn't been attempted yet.
26
+ */
27
+ export declare function getLoadError(): Error | null;
package/meson.build ADDED
@@ -0,0 +1,57 @@
1
+ project('GjsifyHttp2', ['c', 'vala'], version: '1.0')
2
+
3
+ root_dir = meson.current_source_dir()
4
+
5
+ # Required system packages (Fedora 43+):
6
+ # dnf install vala meson ninja-build libnghttp2-devel
7
+ #
8
+ # Bindings: there is no upstream nghttp2 VAPI, so we wrap the handful of
9
+ # symbols we need in a small C shim (src/vala/nghttp2-helpers.{h,c}) and
10
+ # call into it from Vala via [CCode] extern declarations. This keeps every
11
+ # nghttp2 pointer C-side, mirroring the pattern in @gjsify/webrtc-native.
12
+ #
13
+ # We use cc.find_library / cc.find_header instead of `dependency()` for
14
+ # nghttp2 — `dependency()` makes meson pass `--pkg libnghttp2` to valac,
15
+ # which then looks for an nghttp2.vapi we don't have. find_library only
16
+ # affects the C compile + link stages, not Vala.
17
+ cc = meson.get_compiler('c')
18
+
19
+ nghttp2_lib = cc.find_library('nghttp2', has_headers: ['nghttp2/nghttp2.h'])
20
+
21
+ vala_deps = [
22
+ dependency('glib-2.0'),
23
+ dependency('gobject-2.0'),
24
+ ]
25
+
26
+ sources = files(
27
+ 'src/vala/nghttp2-helpers.c',
28
+ 'src/vala/frame-encoder.vala',
29
+ 'src/vala/stream-id-allocator.vala',
30
+ 'src/vala/session-bridge.vala',
31
+ )
32
+
33
+ # Compiler picks up nghttp2-helpers.h via the include dir.
34
+ inc = include_directories('src/vala')
35
+
36
+ libGjsifyHttp2 = library('gjsifyhttp2', sources,
37
+ dependencies: vala_deps + [nghttp2_lib],
38
+ include_directories: inc,
39
+ vala_gir: meson.project_name() + '-1.0.gir',
40
+ install: true,
41
+ install_dir: [true, true, true, true],
42
+ )
43
+
44
+ g_ir_compiler = find_program('g-ir-compiler')
45
+
46
+ custom_target(meson.project_name() + '-1.0.typelib',
47
+ command: [
48
+ g_ir_compiler,
49
+ '--shared-library', 'libgjsifyhttp2.so',
50
+ '--output', '@OUTPUT@',
51
+ meson.current_build_dir() / meson.project_name() + '-1.0.gir',
52
+ ],
53
+ output: meson.project_name() + '-1.0.typelib',
54
+ depends: libGjsifyHttp2,
55
+ install: true,
56
+ install_dir: get_option('libdir') / 'girepository-1.0',
57
+ )
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@gjsify/http2-native",
3
+ "version": "0.4.0",
4
+ "description": "Optional Vala/GObject bridge providing nghttp2 primitives unreachable through libsoup's high-level GIR API: HPACK header-block encoding (for PUSH_PROMISE / DATA frames), server-side push stream-ID allocation, and a thin nghttp2_session wrapper for future cleartext HTTP/2 (h2c) support. Used by @gjsify/http2 to back ServerHttp2Stream.pushStream() / respondWithFD() / respondWithFile() and enable createServer() over plain TCP once the full Soup ↔ nghttp2 boundary is in place.",
5
+ "type": "module",
6
+ "main": "lib/esm/index.js",
7
+ "module": "lib/esm/index.js",
8
+ "types": "lib/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "default": "./lib/esm/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "lib",
17
+ "prebuilds",
18
+ "meson.build",
19
+ "src/vala"
20
+ ],
21
+ "gjsify": {
22
+ "prebuilds": "prebuilds"
23
+ },
24
+ "scripts": {
25
+ "clear": "rm -rf lib build tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo || exit 0",
26
+ "check": "tsc --noEmit",
27
+ "init:meson": "meson setup build .",
28
+ "init:meson:wipe": "yarn init:meson --wipe",
29
+ "build": "yarn build:gjsify && yarn build:types",
30
+ "build:gjsify": "gjsify build --library 'src/ts/**/*.{ts,js}'",
31
+ "build:meson": "yarn init:meson && meson compile -C build",
32
+ "build:types": "tsc",
33
+ "build:prebuilds": "yarn build:meson && mkdir -p prebuilds/linux-x86_64 && cp build/libgjsifyhttp2.so build/GjsifyHttp2-1.0.gir build/GjsifyHttp2-1.0.typelib prebuilds/linux-x86_64/",
34
+ "build:gir-types": "ts-for-gir generate --externalDeps --allowMissingDeps --girDirectories=./prebuilds/linux-x86_64 --girDirectories=/usr/share/gir-1.0 --modules=GjsifyHttp2-1.0 --outdir=src/ts --npmScope=@girs --package=false --ignoreVersionConflicts=true"
35
+ },
36
+ "keywords": [
37
+ "gjs",
38
+ "http2",
39
+ "nghttp2",
40
+ "hpack",
41
+ "push-promise",
42
+ "h2c",
43
+ "vala",
44
+ "native"
45
+ ],
46
+ "dependencies": {
47
+ "@girs/gjs": "4.0.0-rc.15",
48
+ "@girs/glib-2.0": "2.88.0-4.0.0-rc.15",
49
+ "@girs/gobject-2.0": "2.88.0-4.0.0-rc.15"
50
+ },
51
+ "devDependencies": {
52
+ "@gjsify/cli": "^0.4.0",
53
+ "@ts-for-gir/cli": "^4.0.0-rc.15",
54
+ "@types/node": "^25.6.2",
55
+ "typescript": "^6.0.3"
56
+ }
57
+ }
@@ -0,0 +1,253 @@
1
+ <?xml version="1.0"?>
2
+ <!-- GjsifyHttp2-1.0.gir generated by valac 0.56.19, do not modify. -->
3
+ <repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:doc="http://www.gtk.org/introspection/doc/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
4
+ <include name="GObject" version="2.0"/>
5
+ <include name="GLib" version="2.0"/>
6
+ <package name="gjsifyhttp2"/>
7
+ <c:include name="nghttp2-helpers.h"/>
8
+ <c:include name="gjsifyhttp2.h"/>
9
+ <doc:format name="unknown"/>
10
+ <namespace name="GjsifyHttp2" version="1.0" shared-library="libgjsifyhttp2.so" c:prefix="GjsifyHttp2" c:identifier-prefixes="GjsifyHttp2" c:symbol-prefixes="gjsify_http2">
11
+ <class name="FrameEncoder" c:type="GjsifyHttp2FrameEncoder" c:symbol-prefix="frame_encoder" glib:type-name="GjsifyHttp2FrameEncoder" glib:get-type="gjsify_http2_frame_encoder_get_type" glib:type-struct="FrameEncoderClass" parent="GObject.Object">
12
+ <field name="parent_instance" readable="0" private="1">
13
+ <type name="GObject.Object" c:type="GObject"/>
14
+ </field>
15
+ <field name="priv" readable="0" private="1">
16
+ <type name="FrameEncoderPrivate" c:type="GjsifyHttp2FrameEncoderPrivate*"/>
17
+ </field>
18
+ <constant name="TYPE_DATA" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_TYPE_DATA" value="0x00">
19
+ <type name="gint" c:type="gint"/>
20
+ </constant>
21
+ <constant name="TYPE_HEADERS" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_TYPE_HEADERS" value="0x01">
22
+ <type name="gint" c:type="gint"/>
23
+ </constant>
24
+ <constant name="TYPE_PUSH_PROMISE" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_TYPE_PUSH_PROMISE" value="0x05">
25
+ <type name="gint" c:type="gint"/>
26
+ </constant>
27
+ <constant name="TYPE_GOAWAY" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_TYPE_GOAWAY" value="0x07">
28
+ <type name="gint" c:type="gint"/>
29
+ </constant>
30
+ <constant name="TYPE_WINDOW_UPDATE" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_TYPE_WINDOW_UPDATE" value="0x08">
31
+ <type name="gint" c:type="gint"/>
32
+ </constant>
33
+ <constant name="FLAG_END_STREAM" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_FLAG_END_STREAM" value="0x01">
34
+ <type name="gint" c:type="gint"/>
35
+ </constant>
36
+ <constant name="FLAG_END_HEADERS" c:identifier="GJSIFY_HTTP2_FRAME_ENCODER_FLAG_END_HEADERS" value="0x04">
37
+ <type name="gint" c:type="gint"/>
38
+ </constant>
39
+ <method name="encode_headers" c:identifier="gjsify_http2_frame_encoder_encode_headers">
40
+ <return-value transfer-ownership="full" nullable="1">
41
+ <type name="GLib.Bytes" c:type="GBytes*"/>
42
+ </return-value>
43
+ <parameters>
44
+ <instance-parameter name="self" transfer-ownership="none">
45
+ <type name="GjsifyHttp2.FrameEncoder" c:type="GjsifyHttp2FrameEncoder*"/>
46
+ </instance-parameter>
47
+ <parameter name="names" transfer-ownership="none">
48
+ <array length="1" c:type="gchar**">
49
+ <type name="utf8" c:type="gchar*"/>
50
+ </array>
51
+ </parameter>
52
+ <parameter name="names_length1" transfer-ownership="none">
53
+ <type name="gint" c:type="gint"/>
54
+ </parameter>
55
+ <parameter name="values" transfer-ownership="none">
56
+ <array length="3" c:type="gchar**">
57
+ <type name="utf8" c:type="gchar*"/>
58
+ </array>
59
+ </parameter>
60
+ <parameter name="values_length1" transfer-ownership="none">
61
+ <type name="gint" c:type="gint"/>
62
+ </parameter>
63
+ </parameters>
64
+ </method>
65
+ <method name="build_data_frame" c:identifier="gjsify_http2_frame_encoder_build_data_frame">
66
+ <return-value transfer-ownership="full">
67
+ <type name="GLib.Bytes" c:type="GBytes*"/>
68
+ </return-value>
69
+ <parameters>
70
+ <instance-parameter name="self" transfer-ownership="none">
71
+ <type name="GjsifyHttp2.FrameEncoder" c:type="GjsifyHttp2FrameEncoder*"/>
72
+ </instance-parameter>
73
+ <parameter name="stream_id" transfer-ownership="none">
74
+ <type name="guint32" c:type="guint32"/>
75
+ </parameter>
76
+ <parameter name="end_stream" transfer-ownership="none">
77
+ <type name="gboolean" c:type="gboolean"/>
78
+ </parameter>
79
+ <parameter name="payload" transfer-ownership="none">
80
+ <type name="GLib.Bytes" c:type="GBytes*"/>
81
+ </parameter>
82
+ </parameters>
83
+ </method>
84
+ <method name="build_headers_frame" c:identifier="gjsify_http2_frame_encoder_build_headers_frame">
85
+ <return-value transfer-ownership="full">
86
+ <type name="GLib.Bytes" c:type="GBytes*"/>
87
+ </return-value>
88
+ <parameters>
89
+ <instance-parameter name="self" transfer-ownership="none">
90
+ <type name="GjsifyHttp2.FrameEncoder" c:type="GjsifyHttp2FrameEncoder*"/>
91
+ </instance-parameter>
92
+ <parameter name="stream_id" transfer-ownership="none">
93
+ <type name="guint32" c:type="guint32"/>
94
+ </parameter>
95
+ <parameter name="end_stream" transfer-ownership="none">
96
+ <type name="gboolean" c:type="gboolean"/>
97
+ </parameter>
98
+ <parameter name="end_headers" transfer-ownership="none">
99
+ <type name="gboolean" c:type="gboolean"/>
100
+ </parameter>
101
+ <parameter name="header_block" transfer-ownership="none">
102
+ <type name="GLib.Bytes" c:type="GBytes*"/>
103
+ </parameter>
104
+ </parameters>
105
+ </method>
106
+ <method name="build_push_promise" c:identifier="gjsify_http2_frame_encoder_build_push_promise">
107
+ <return-value transfer-ownership="full">
108
+ <type name="GLib.Bytes" c:type="GBytes*"/>
109
+ </return-value>
110
+ <parameters>
111
+ <instance-parameter name="self" transfer-ownership="none">
112
+ <type name="GjsifyHttp2.FrameEncoder" c:type="GjsifyHttp2FrameEncoder*"/>
113
+ </instance-parameter>
114
+ <parameter name="associated_stream_id" transfer-ownership="none">
115
+ <type name="guint32" c:type="guint32"/>
116
+ </parameter>
117
+ <parameter name="promised_stream_id" transfer-ownership="none">
118
+ <type name="guint32" c:type="guint32"/>
119
+ </parameter>
120
+ <parameter name="header_block" transfer-ownership="none">
121
+ <type name="GLib.Bytes" c:type="GBytes*"/>
122
+ </parameter>
123
+ </parameters>
124
+ </method>
125
+ <method name="nghttp2_version" c:identifier="gjsify_http2_frame_encoder_nghttp2_version">
126
+ <return-value transfer-ownership="none">
127
+ <type name="utf8" c:type="const gchar*"/>
128
+ </return-value>
129
+ <parameters>
130
+ <instance-parameter name="self" transfer-ownership="none">
131
+ <type name="GjsifyHttp2.FrameEncoder" c:type="GjsifyHttp2FrameEncoder*"/>
132
+ </instance-parameter>
133
+ </parameters>
134
+ </method>
135
+ <constructor name="new" c:identifier="gjsify_http2_frame_encoder_new">
136
+ <return-value transfer-ownership="full">
137
+ <type name="GjsifyHttp2.FrameEncoder" c:type="GjsifyHttp2FrameEncoder*"/>
138
+ </return-value>
139
+ </constructor>
140
+ </class>
141
+ <record name="FrameEncoderClass" c:type="GjsifyHttp2FrameEncoderClass" glib:is-gtype-struct-for="FrameEncoder">
142
+ <field name="parent_class" readable="0" private="1">
143
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
144
+ </field>
145
+ </record>
146
+ <record name="FrameEncoderPrivate" c:type="GjsifyHttp2FrameEncoderPrivate" disguised="1"/>
147
+ <class name="StreamIdAllocator" c:type="GjsifyHttp2StreamIdAllocator" c:symbol-prefix="stream_id_allocator" glib:type-name="GjsifyHttp2StreamIdAllocator" glib:get-type="gjsify_http2_stream_id_allocator_get_type" glib:type-struct="StreamIdAllocatorClass" parent="GObject.Object">
148
+ <field name="parent_instance" readable="0" private="1">
149
+ <type name="GObject.Object" c:type="GObject"/>
150
+ </field>
151
+ <field name="priv" readable="0" private="1">
152
+ <type name="StreamIdAllocatorPrivate" c:type="GjsifyHttp2StreamIdAllocatorPrivate*"/>
153
+ </field>
154
+ <constant name="MAX_STREAM_ID" c:identifier="GJSIFY_HTTP2_STREAM_ID_ALLOCATOR_MAX_STREAM_ID" value="0x7fffffff">
155
+ <type name="guint" c:type="guint"/>
156
+ </constant>
157
+ <method name="next_promised" c:identifier="gjsify_http2_stream_id_allocator_next_promised">
158
+ <return-value transfer-ownership="full">
159
+ <type name="guint32" c:type="guint32"/>
160
+ </return-value>
161
+ <parameters>
162
+ <instance-parameter name="self" transfer-ownership="none">
163
+ <type name="GjsifyHttp2.StreamIdAllocator" c:type="GjsifyHttp2StreamIdAllocator*"/>
164
+ </instance-parameter>
165
+ </parameters>
166
+ </method>
167
+ <method name="record_client_stream" c:identifier="gjsify_http2_stream_id_allocator_record_client_stream">
168
+ <return-value transfer-ownership="full">
169
+ <type name="none" c:type="void"/>
170
+ </return-value>
171
+ <parameters>
172
+ <instance-parameter name="self" transfer-ownership="none">
173
+ <type name="GjsifyHttp2.StreamIdAllocator" c:type="GjsifyHttp2StreamIdAllocator*"/>
174
+ </instance-parameter>
175
+ <parameter name="id" transfer-ownership="none">
176
+ <type name="guint32" c:type="guint32"/>
177
+ </parameter>
178
+ </parameters>
179
+ </method>
180
+ <constructor name="new" c:identifier="gjsify_http2_stream_id_allocator_new">
181
+ <return-value transfer-ownership="full">
182
+ <type name="GjsifyHttp2.StreamIdAllocator" c:type="GjsifyHttp2StreamIdAllocator*"/>
183
+ </return-value>
184
+ </constructor>
185
+ <property name="last-client-stream-id">
186
+ <type name="guint32" c:type="guint32"/>
187
+ </property>
188
+ <method name="get_last_client_stream_id" c:identifier="gjsify_http2_stream_id_allocator_get_last_client_stream_id">
189
+ <return-value transfer-ownership="none">
190
+ <type name="guint32" c:type="guint32"/>
191
+ </return-value>
192
+ <parameters>
193
+ <instance-parameter name="self" transfer-ownership="none">
194
+ <type name="GjsifyHttp2.StreamIdAllocator" c:type="GjsifyHttp2StreamIdAllocator*"/>
195
+ </instance-parameter>
196
+ </parameters>
197
+ </method>
198
+ <property name="remaining-pushes">
199
+ <type name="guint32" c:type="guint32"/>
200
+ </property>
201
+ <method name="get_remaining_pushes" c:identifier="gjsify_http2_stream_id_allocator_get_remaining_pushes">
202
+ <return-value transfer-ownership="none">
203
+ <type name="guint32" c:type="guint32"/>
204
+ </return-value>
205
+ <parameters>
206
+ <instance-parameter name="self" transfer-ownership="none">
207
+ <type name="GjsifyHttp2.StreamIdAllocator" c:type="GjsifyHttp2StreamIdAllocator*"/>
208
+ </instance-parameter>
209
+ </parameters>
210
+ </method>
211
+ </class>
212
+ <record name="StreamIdAllocatorClass" c:type="GjsifyHttp2StreamIdAllocatorClass" glib:is-gtype-struct-for="StreamIdAllocator">
213
+ <field name="parent_class" readable="0" private="1">
214
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
215
+ </field>
216
+ </record>
217
+ <record name="StreamIdAllocatorPrivate" c:type="GjsifyHttp2StreamIdAllocatorPrivate" disguised="1"/>
218
+ <class name="SessionBridge" c:type="GjsifyHttp2SessionBridge" c:symbol-prefix="session_bridge" glib:type-name="GjsifyHttp2SessionBridge" glib:get-type="gjsify_http2_session_bridge_get_type" glib:type-struct="SessionBridgeClass" parent="GObject.Object">
219
+ <field name="parent_instance" readable="0" private="1">
220
+ <type name="GObject.Object" c:type="GObject"/>
221
+ </field>
222
+ <field name="priv" readable="0" private="1">
223
+ <type name="SessionBridgePrivate" c:type="GjsifyHttp2SessionBridgePrivate*"/>
224
+ </field>
225
+ <function name="is_client_preface" c:identifier="gjsify_http2_session_bridge_is_client_preface">
226
+ <return-value transfer-ownership="full">
227
+ <type name="gboolean" c:type="gboolean"/>
228
+ </return-value>
229
+ <parameters>
230
+ <parameter name="bytes" transfer-ownership="none" nullable="1">
231
+ <type name="GLib.Bytes" c:type="GBytes*"/>
232
+ </parameter>
233
+ </parameters>
234
+ </function>
235
+ <function name="preface_length" c:identifier="gjsify_http2_session_bridge_preface_length">
236
+ <return-value transfer-ownership="full">
237
+ <type name="guint" c:type="guint"/>
238
+ </return-value>
239
+ </function>
240
+ <constructor name="new" c:identifier="gjsify_http2_session_bridge_new">
241
+ <return-value transfer-ownership="full">
242
+ <type name="GjsifyHttp2.SessionBridge" c:type="GjsifyHttp2SessionBridge*"/>
243
+ </return-value>
244
+ </constructor>
245
+ </class>
246
+ <record name="SessionBridgeClass" c:type="GjsifyHttp2SessionBridgeClass" glib:is-gtype-struct-for="SessionBridge">
247
+ <field name="parent_class" readable="0" private="1">
248
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
249
+ </field>
250
+ </record>
251
+ <record name="SessionBridgePrivate" c:type="GjsifyHttp2SessionBridgePrivate" disguised="1"/>
252
+ </namespace>
253
+ </repository>