@structured-world/structured-public-domains 0.0.6 → 0.0.8

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.
@@ -1,309 +0,0 @@
1
- /* @ts-self-types="./structured_public_domains.d.ts" */
2
-
3
- /**
4
- * Result of a PSL lookup, returned as an opaque JS object.
5
- *
6
- * JavaScript consumers receive property accessors; the JS wrapper layer
7
- * copies these into a plain object and calls the generated JS `.free()`
8
- * method so callers never deal with manual memory management.
9
- */
10
- export class DomainInfo {
11
- static __wrap(ptr) {
12
- ptr = ptr >>> 0;
13
- const obj = Object.create(DomainInfo.prototype);
14
- obj.__wbg_ptr = ptr;
15
- DomainInfoFinalization.register(obj, obj.__wbg_ptr, obj);
16
- return obj;
17
- }
18
- __destroy_into_raw() {
19
- const ptr = this.__wbg_ptr;
20
- this.__wbg_ptr = 0;
21
- DomainInfoFinalization.unregister(this);
22
- return ptr;
23
- }
24
- free() {
25
- const ptr = this.__destroy_into_raw();
26
- wasm.__wbg_domaininfo_free(ptr, 0);
27
- }
28
- /**
29
- * Whether the suffix matched an explicit PSL rule (vs the `*` fallback).
30
- * @returns {boolean}
31
- */
32
- get known() {
33
- const ret = wasm.domaininfo_known(this.__wbg_ptr);
34
- return ret !== 0;
35
- }
36
- /**
37
- * The registrable domain (eTLD+1), or `undefined` if the input is a
38
- * bare suffix.
39
- * @returns {string | undefined}
40
- */
41
- get registrableDomain() {
42
- const ret = wasm.domaininfo_registrableDomain(this.__wbg_ptr);
43
- let v1;
44
- if (ret[0] !== 0) {
45
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
46
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
47
- }
48
- return v1;
49
- }
50
- /**
51
- * The public suffix (e.g. `"co.uk"`).
52
- * @returns {string}
53
- */
54
- get suffix() {
55
- let deferred1_0;
56
- let deferred1_1;
57
- try {
58
- const ret = wasm.domaininfo_suffix(this.__wbg_ptr);
59
- deferred1_0 = ret[0];
60
- deferred1_1 = ret[1];
61
- return getStringFromWasm0(ret[0], ret[1]);
62
- } finally {
63
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
64
- }
65
- }
66
- }
67
- if (Symbol.dispose) DomainInfo.prototype[Symbol.dispose] = DomainInfo.prototype.free;
68
-
69
- /**
70
- * Check if a domain's suffix is a known entry in the PSL.
71
- * @param {string} domain
72
- * @returns {boolean}
73
- */
74
- export function isKnownSuffix(domain) {
75
- const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
- const len0 = WASM_VECTOR_LEN;
77
- const ret = wasm.isKnownSuffix(ptr0, len0);
78
- return ret !== 0;
79
- }
80
-
81
- /**
82
- * Look up a domain in the Public Suffix List.
83
- *
84
- * Returns `undefined` for empty or invalid input.
85
- * @param {string} domain
86
- * @returns {DomainInfo | undefined}
87
- */
88
- export function lookup(domain) {
89
- const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
90
- const len0 = WASM_VECTOR_LEN;
91
- const ret = wasm.lookup(ptr0, len0);
92
- return ret === 0 ? undefined : DomainInfo.__wrap(ret);
93
- }
94
-
95
- /**
96
- * Extract the registrable domain (eTLD+1).
97
- *
98
- * Returns `undefined` if the domain is itself a public suffix.
99
- * @param {string} domain
100
- * @returns {string | undefined}
101
- */
102
- export function registrableDomain(domain) {
103
- const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
- const len0 = WASM_VECTOR_LEN;
105
- const ret = wasm.registrableDomain(ptr0, len0);
106
- let v2;
107
- if (ret[0] !== 0) {
108
- v2 = getStringFromWasm0(ret[0], ret[1]).slice();
109
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
110
- }
111
- return v2;
112
- }
113
-
114
- function __wbg_get_imports() {
115
- const import0 = {
116
- __proto__: null,
117
- __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
118
- throw new Error(getStringFromWasm0(arg0, arg1));
119
- },
120
- __wbindgen_init_externref_table: function() {
121
- const table = wasm.__wbindgen_externrefs;
122
- const offset = table.grow(4);
123
- table.set(0, undefined);
124
- table.set(offset + 0, undefined);
125
- table.set(offset + 1, null);
126
- table.set(offset + 2, true);
127
- table.set(offset + 3, false);
128
- },
129
- };
130
- return {
131
- __proto__: null,
132
- "./structured_public_domains_bg.js": import0,
133
- };
134
- }
135
-
136
- const DomainInfoFinalization = (typeof FinalizationRegistry === 'undefined')
137
- ? { register: () => {}, unregister: () => {} }
138
- : new FinalizationRegistry(ptr => wasm.__wbg_domaininfo_free(ptr >>> 0, 1));
139
-
140
- function getStringFromWasm0(ptr, len) {
141
- ptr = ptr >>> 0;
142
- return decodeText(ptr, len);
143
- }
144
-
145
- let cachedUint8ArrayMemory0 = null;
146
- function getUint8ArrayMemory0() {
147
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
148
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
149
- }
150
- return cachedUint8ArrayMemory0;
151
- }
152
-
153
- function passStringToWasm0(arg, malloc, realloc) {
154
- if (realloc === undefined) {
155
- const buf = cachedTextEncoder.encode(arg);
156
- const ptr = malloc(buf.length, 1) >>> 0;
157
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
158
- WASM_VECTOR_LEN = buf.length;
159
- return ptr;
160
- }
161
-
162
- let len = arg.length;
163
- let ptr = malloc(len, 1) >>> 0;
164
-
165
- const mem = getUint8ArrayMemory0();
166
-
167
- let offset = 0;
168
-
169
- for (; offset < len; offset++) {
170
- const code = arg.charCodeAt(offset);
171
- if (code > 0x7F) break;
172
- mem[ptr + offset] = code;
173
- }
174
- if (offset !== len) {
175
- if (offset !== 0) {
176
- arg = arg.slice(offset);
177
- }
178
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
179
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
180
- const ret = cachedTextEncoder.encodeInto(arg, view);
181
-
182
- offset += ret.written;
183
- ptr = realloc(ptr, len, offset, 1) >>> 0;
184
- }
185
-
186
- WASM_VECTOR_LEN = offset;
187
- return ptr;
188
- }
189
-
190
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
191
- cachedTextDecoder.decode();
192
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
193
- let numBytesDecoded = 0;
194
- function decodeText(ptr, len) {
195
- numBytesDecoded += len;
196
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
197
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
198
- cachedTextDecoder.decode();
199
- numBytesDecoded = len;
200
- }
201
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
202
- }
203
-
204
- const cachedTextEncoder = new TextEncoder();
205
-
206
- if (!('encodeInto' in cachedTextEncoder)) {
207
- cachedTextEncoder.encodeInto = function (arg, view) {
208
- const buf = cachedTextEncoder.encode(arg);
209
- view.set(buf);
210
- return {
211
- read: arg.length,
212
- written: buf.length
213
- };
214
- };
215
- }
216
-
217
- let WASM_VECTOR_LEN = 0;
218
-
219
- let wasmModule, wasm;
220
- function __wbg_finalize_init(instance, module) {
221
- wasm = instance.exports;
222
- wasmModule = module;
223
- cachedUint8ArrayMemory0 = null;
224
- wasm.__wbindgen_start();
225
- return wasm;
226
- }
227
-
228
- async function __wbg_load(module, imports) {
229
- if (typeof Response === 'function' && module instanceof Response) {
230
- if (typeof WebAssembly.instantiateStreaming === 'function') {
231
- try {
232
- return await WebAssembly.instantiateStreaming(module, imports);
233
- } catch (e) {
234
- const validResponse = module.ok && expectedResponseType(module.type);
235
-
236
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
237
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
238
-
239
- } else { throw e; }
240
- }
241
- }
242
-
243
- const bytes = await module.arrayBuffer();
244
- return await WebAssembly.instantiate(bytes, imports);
245
- } else {
246
- const instance = await WebAssembly.instantiate(module, imports);
247
-
248
- if (instance instanceof WebAssembly.Instance) {
249
- return { instance, module };
250
- } else {
251
- return instance;
252
- }
253
- }
254
-
255
- function expectedResponseType(type) {
256
- switch (type) {
257
- case 'basic': case 'cors': case 'default': return true;
258
- }
259
- return false;
260
- }
261
- }
262
-
263
- function initSync(module) {
264
- if (wasm !== undefined) return wasm;
265
-
266
-
267
- if (module !== undefined) {
268
- if (Object.getPrototypeOf(module) === Object.prototype) {
269
- ({module} = module)
270
- } else {
271
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
272
- }
273
- }
274
-
275
- const imports = __wbg_get_imports();
276
- if (!(module instanceof WebAssembly.Module)) {
277
- module = new WebAssembly.Module(module);
278
- }
279
- const instance = new WebAssembly.Instance(module, imports);
280
- return __wbg_finalize_init(instance, module);
281
- }
282
-
283
- async function __wbg_init(module_or_path) {
284
- if (wasm !== undefined) return wasm;
285
-
286
-
287
- if (module_or_path !== undefined) {
288
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
289
- ({module_or_path} = module_or_path)
290
- } else {
291
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
292
- }
293
- }
294
-
295
- if (module_or_path === undefined) {
296
- module_or_path = new URL('structured_public_domains_bg.wasm', import.meta.url);
297
- }
298
- const imports = __wbg_get_imports();
299
-
300
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
301
- module_or_path = fetch(module_or_path);
302
- }
303
-
304
- const { instance, module } = await __wbg_load(await module_or_path, imports);
305
-
306
- return __wbg_finalize_init(instance, module);
307
- }
308
-
309
- export { initSync, __wbg_init as default };
@@ -1,219 +0,0 @@
1
- /* @ts-self-types="./structured_public_domains.d.ts" */
2
-
3
- /**
4
- * Result of a PSL lookup, returned as an opaque JS object.
5
- *
6
- * JavaScript consumers receive property accessors; the JS wrapper layer
7
- * copies these into a plain object and calls the generated JS `.free()`
8
- * method so callers never deal with manual memory management.
9
- */
10
- class DomainInfo {
11
- static __wrap(ptr) {
12
- ptr = ptr >>> 0;
13
- const obj = Object.create(DomainInfo.prototype);
14
- obj.__wbg_ptr = ptr;
15
- DomainInfoFinalization.register(obj, obj.__wbg_ptr, obj);
16
- return obj;
17
- }
18
- __destroy_into_raw() {
19
- const ptr = this.__wbg_ptr;
20
- this.__wbg_ptr = 0;
21
- DomainInfoFinalization.unregister(this);
22
- return ptr;
23
- }
24
- free() {
25
- const ptr = this.__destroy_into_raw();
26
- wasm.__wbg_domaininfo_free(ptr, 0);
27
- }
28
- /**
29
- * Whether the suffix matched an explicit PSL rule (vs the `*` fallback).
30
- * @returns {boolean}
31
- */
32
- get known() {
33
- const ret = wasm.domaininfo_known(this.__wbg_ptr);
34
- return ret !== 0;
35
- }
36
- /**
37
- * The registrable domain (eTLD+1), or `undefined` if the input is a
38
- * bare suffix.
39
- * @returns {string | undefined}
40
- */
41
- get registrableDomain() {
42
- const ret = wasm.domaininfo_registrableDomain(this.__wbg_ptr);
43
- let v1;
44
- if (ret[0] !== 0) {
45
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
46
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
47
- }
48
- return v1;
49
- }
50
- /**
51
- * The public suffix (e.g. `"co.uk"`).
52
- * @returns {string}
53
- */
54
- get suffix() {
55
- let deferred1_0;
56
- let deferred1_1;
57
- try {
58
- const ret = wasm.domaininfo_suffix(this.__wbg_ptr);
59
- deferred1_0 = ret[0];
60
- deferred1_1 = ret[1];
61
- return getStringFromWasm0(ret[0], ret[1]);
62
- } finally {
63
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
64
- }
65
- }
66
- }
67
- if (Symbol.dispose) DomainInfo.prototype[Symbol.dispose] = DomainInfo.prototype.free;
68
- exports.DomainInfo = DomainInfo;
69
-
70
- /**
71
- * Check if a domain's suffix is a known entry in the PSL.
72
- * @param {string} domain
73
- * @returns {boolean}
74
- */
75
- function isKnownSuffix(domain) {
76
- const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
- const len0 = WASM_VECTOR_LEN;
78
- const ret = wasm.isKnownSuffix(ptr0, len0);
79
- return ret !== 0;
80
- }
81
- exports.isKnownSuffix = isKnownSuffix;
82
-
83
- /**
84
- * Look up a domain in the Public Suffix List.
85
- *
86
- * Returns `undefined` for empty or invalid input.
87
- * @param {string} domain
88
- * @returns {DomainInfo | undefined}
89
- */
90
- function lookup(domain) {
91
- const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
92
- const len0 = WASM_VECTOR_LEN;
93
- const ret = wasm.lookup(ptr0, len0);
94
- return ret === 0 ? undefined : DomainInfo.__wrap(ret);
95
- }
96
- exports.lookup = lookup;
97
-
98
- /**
99
- * Extract the registrable domain (eTLD+1).
100
- *
101
- * Returns `undefined` if the domain is itself a public suffix.
102
- * @param {string} domain
103
- * @returns {string | undefined}
104
- */
105
- function registrableDomain(domain) {
106
- const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
107
- const len0 = WASM_VECTOR_LEN;
108
- const ret = wasm.registrableDomain(ptr0, len0);
109
- let v2;
110
- if (ret[0] !== 0) {
111
- v2 = getStringFromWasm0(ret[0], ret[1]).slice();
112
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
113
- }
114
- return v2;
115
- }
116
- exports.registrableDomain = registrableDomain;
117
-
118
- function __wbg_get_imports() {
119
- const import0 = {
120
- __proto__: null,
121
- __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
122
- throw new Error(getStringFromWasm0(arg0, arg1));
123
- },
124
- __wbindgen_init_externref_table: function() {
125
- const table = wasm.__wbindgen_externrefs;
126
- const offset = table.grow(4);
127
- table.set(0, undefined);
128
- table.set(offset + 0, undefined);
129
- table.set(offset + 1, null);
130
- table.set(offset + 2, true);
131
- table.set(offset + 3, false);
132
- },
133
- };
134
- return {
135
- __proto__: null,
136
- "./structured_public_domains_bg.js": import0,
137
- };
138
- }
139
-
140
- const DomainInfoFinalization = (typeof FinalizationRegistry === 'undefined')
141
- ? { register: () => {}, unregister: () => {} }
142
- : new FinalizationRegistry(ptr => wasm.__wbg_domaininfo_free(ptr >>> 0, 1));
143
-
144
- function getStringFromWasm0(ptr, len) {
145
- ptr = ptr >>> 0;
146
- return decodeText(ptr, len);
147
- }
148
-
149
- let cachedUint8ArrayMemory0 = null;
150
- function getUint8ArrayMemory0() {
151
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
152
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
153
- }
154
- return cachedUint8ArrayMemory0;
155
- }
156
-
157
- function passStringToWasm0(arg, malloc, realloc) {
158
- if (realloc === undefined) {
159
- const buf = cachedTextEncoder.encode(arg);
160
- const ptr = malloc(buf.length, 1) >>> 0;
161
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
162
- WASM_VECTOR_LEN = buf.length;
163
- return ptr;
164
- }
165
-
166
- let len = arg.length;
167
- let ptr = malloc(len, 1) >>> 0;
168
-
169
- const mem = getUint8ArrayMemory0();
170
-
171
- let offset = 0;
172
-
173
- for (; offset < len; offset++) {
174
- const code = arg.charCodeAt(offset);
175
- if (code > 0x7F) break;
176
- mem[ptr + offset] = code;
177
- }
178
- if (offset !== len) {
179
- if (offset !== 0) {
180
- arg = arg.slice(offset);
181
- }
182
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
183
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
184
- const ret = cachedTextEncoder.encodeInto(arg, view);
185
-
186
- offset += ret.written;
187
- ptr = realloc(ptr, len, offset, 1) >>> 0;
188
- }
189
-
190
- WASM_VECTOR_LEN = offset;
191
- return ptr;
192
- }
193
-
194
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
195
- cachedTextDecoder.decode();
196
- function decodeText(ptr, len) {
197
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
198
- }
199
-
200
- const cachedTextEncoder = new TextEncoder();
201
-
202
- if (!('encodeInto' in cachedTextEncoder)) {
203
- cachedTextEncoder.encodeInto = function (arg, view) {
204
- const buf = cachedTextEncoder.encode(arg);
205
- view.set(buf);
206
- return {
207
- read: arg.length,
208
- written: buf.length
209
- };
210
- };
211
- }
212
-
213
- let WASM_VECTOR_LEN = 0;
214
-
215
- const wasmPath = `${__dirname}/structured_public_domains_bg.wasm`;
216
- const wasmBytes = require('fs').readFileSync(wasmPath);
217
- const wasmModule = new WebAssembly.Module(wasmBytes);
218
- let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
219
- wasm.__wbindgen_start();
@@ -1,47 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /**
5
- * Result of a PSL lookup, returned as an opaque JS object.
6
- *
7
- * JavaScript consumers receive property accessors; the JS wrapper layer
8
- * copies these into a plain object and calls the generated JS `.free()`
9
- * method so callers never deal with manual memory management.
10
- */
11
- export class DomainInfo {
12
- private constructor();
13
- free(): void;
14
- [Symbol.dispose](): void;
15
- /**
16
- * Whether the suffix matched an explicit PSL rule (vs the `*` fallback).
17
- */
18
- readonly known: boolean;
19
- /**
20
- * The registrable domain (eTLD+1), or `undefined` if the input is a
21
- * bare suffix.
22
- */
23
- readonly registrableDomain: string | undefined;
24
- /**
25
- * The public suffix (e.g. `"co.uk"`).
26
- */
27
- readonly suffix: string;
28
- }
29
-
30
- /**
31
- * Check if a domain's suffix is a known entry in the PSL.
32
- */
33
- export function isKnownSuffix(domain: string): boolean;
34
-
35
- /**
36
- * Look up a domain in the Public Suffix List.
37
- *
38
- * Returns `undefined` for empty or invalid input.
39
- */
40
- export function lookup(domain: string): DomainInfo | undefined;
41
-
42
- /**
43
- * Extract the registrable domain (eTLD+1).
44
- *
45
- * Returns `undefined` if the domain is itself a public suffix.
46
- */
47
- export function registrableDomain(domain: string): string | undefined;