@miradorlabs/parallax-web 1.0.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,243 @@
1
+ import * as apiGateway from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway';
2
+ import { Observable } from 'rxjs';
3
+
4
+ class GrpcWebRpc {
5
+ constructor(url, apiKey) {
6
+ Object.defineProperty(this, "url", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ Object.defineProperty(this, "apiKey", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ this.url = url;
19
+ this.apiKey = apiKey;
20
+ }
21
+ async request(service, method, data, metadata) {
22
+ console.log(`[gRPC-Web] Making request to ${this.url}/${service}/${method}`);
23
+ const headers = {
24
+ 'Content-Type': 'application/grpc-web+proto',
25
+ 'X-Grpc-Web': '1',
26
+ };
27
+ // Add API key to headers if provided
28
+ if (this.apiKey) {
29
+ headers['x-api-key'] = this.apiKey;
30
+ }
31
+ // Add custom metadata
32
+ if (metadata) {
33
+ Object.entries(metadata).forEach(([key, value]) => {
34
+ headers[key] = value;
35
+ });
36
+ }
37
+ try {
38
+ const response = await fetch(`${this.url}/${service}/${method}`, {
39
+ method: 'POST',
40
+ headers,
41
+ body: data.buffer,
42
+ });
43
+ if (!response.ok) {
44
+ const errorText = await response.text();
45
+ throw new Error(`gRPC-Web error: ${response.status} ${response.statusText} - ${errorText}`);
46
+ }
47
+ const arrayBuffer = await response.arrayBuffer();
48
+ console.log(`[gRPC-Web] Success from ${this.url}/${service}/${method}`);
49
+ return new Uint8Array(arrayBuffer);
50
+ }
51
+ catch (error) {
52
+ console.error(`[gRPC-Web] Error from ${this.url}/${service}/${method}:`, error instanceof Error ? error.message : String(error));
53
+ throw error;
54
+ }
55
+ }
56
+ clientStreamingRequest() {
57
+ throw new Error("Client streaming not yet implemented for gRPC-Web");
58
+ }
59
+ serverStreamingRequest(service, method, data) {
60
+ return new Observable((subscriber) => {
61
+ const headers = {
62
+ 'Content-Type': 'application/grpc-web+proto',
63
+ 'X-Grpc-Web': '1',
64
+ };
65
+ // Add API key to headers if provided
66
+ if (this.apiKey) {
67
+ headers['x-api-key'] = this.apiKey;
68
+ }
69
+ fetch(`${this.url}/${service}/${method}`, {
70
+ method: 'POST',
71
+ headers,
72
+ body: data.buffer,
73
+ })
74
+ .then(async (response) => {
75
+ if (!response.ok) {
76
+ throw new Error(`gRPC-Web error: ${response.status} ${response.statusText}`);
77
+ }
78
+ if (!response.body) {
79
+ throw new Error('Response body is null');
80
+ }
81
+ const reader = response.body.getReader();
82
+ try {
83
+ while (true) {
84
+ const { done, value } = await reader.read();
85
+ if (done) {
86
+ subscriber.complete();
87
+ break;
88
+ }
89
+ if (value) {
90
+ subscriber.next(value);
91
+ }
92
+ }
93
+ }
94
+ catch (error) {
95
+ subscriber.error(error);
96
+ }
97
+ })
98
+ .catch((error) => {
99
+ subscriber.error(error);
100
+ });
101
+ return () => {
102
+ // Cleanup logic if needed
103
+ };
104
+ });
105
+ }
106
+ bidirectionalStreamingRequest() {
107
+ throw new Error("Bidirectional streaming not yet implemented for gRPC-Web");
108
+ }
109
+ }
110
+
111
+ const GRPC_GATEWAY_API_URL = "https://gateway-parallax-dev.platform.svc.cluster.local:50053";
112
+ const debugIssue = (trace, error) => {
113
+ // Handle our own debugging / logging here
114
+ console.error(`[ParallaxClient][${trace}] Error:`, error);
115
+ };
116
+ class ParallaxClient {
117
+ constructor(apiKey, apiUrl) {
118
+ Object.defineProperty(this, "apiKey", {
119
+ enumerable: true,
120
+ configurable: true,
121
+ writable: true,
122
+ value: apiKey
123
+ });
124
+ Object.defineProperty(this, "apiUrl", {
125
+ enumerable: true,
126
+ configurable: true,
127
+ writable: true,
128
+ value: GRPC_GATEWAY_API_URL
129
+ });
130
+ Object.defineProperty(this, "apiGatewayRpc", {
131
+ enumerable: true,
132
+ configurable: true,
133
+ writable: true,
134
+ value: void 0
135
+ });
136
+ if (apiUrl) {
137
+ this.apiUrl = apiUrl;
138
+ }
139
+ this.apiGatewayRpc = new GrpcWebRpc(this.apiUrl, apiKey);
140
+ }
141
+ /**
142
+ * Create a new trace
143
+ * @param params Parameters to create a new trace
144
+ * @returns Response from the create trace operation
145
+ */
146
+ async createTrace(params) {
147
+ try {
148
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
149
+ return await apiGatewayClient.CreateTrace(params);
150
+ }
151
+ catch (_error) {
152
+ debugIssue("createTrace", new Error('Error creating trace'));
153
+ throw _error;
154
+ }
155
+ }
156
+ /**
157
+ * Start a new span within a trace
158
+ * @param params Parameters to start a new span
159
+ */
160
+ async startSpan(params) {
161
+ try {
162
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
163
+ return await apiGatewayClient.StartSpan(params);
164
+ }
165
+ catch (_error) {
166
+ debugIssue("startSpan", new Error('Error starting span'));
167
+ throw _error;
168
+ }
169
+ }
170
+ /**
171
+ * Finish a span within a trace
172
+ * @param params Parameters to finish a span
173
+ */
174
+ async finishSpan(params) {
175
+ try {
176
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
177
+ return await apiGatewayClient.FinishSpan(params);
178
+ }
179
+ catch (_error) {
180
+ debugIssue("finishSpan", new Error('Error finishing span'));
181
+ throw _error;
182
+ }
183
+ }
184
+ /**
185
+ * Add attributes to a span
186
+ * @param params Parameters to add attributes to a span
187
+ */
188
+ async addSpanAttributes(params) {
189
+ try {
190
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
191
+ return await apiGatewayClient.AddSpanAttributes(params);
192
+ }
193
+ catch (_error) {
194
+ debugIssue("addSpanAttributes", new Error('Error adding span attributes'));
195
+ throw _error;
196
+ }
197
+ }
198
+ /**
199
+ * Add an event to a span
200
+ * @param params Parameters to add an event to a span
201
+ */
202
+ async addSpanEvent(params) {
203
+ try {
204
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
205
+ return await apiGatewayClient.AddSpanEvent(params);
206
+ }
207
+ catch (_error) {
208
+ debugIssue("addSpanEvent", new Error('Error adding span event'));
209
+ throw _error;
210
+ }
211
+ }
212
+ /**
213
+ * Add an error to a span
214
+ * @param params Parameters to add an error to a span
215
+ */
216
+ async addSpanError(params) {
217
+ try {
218
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
219
+ return await apiGatewayClient.AddSpanError(params);
220
+ }
221
+ catch (_error) {
222
+ debugIssue("addSpanError", new Error('Error adding span error'));
223
+ throw _error;
224
+ }
225
+ }
226
+ /**
227
+ * Add a hint to a span
228
+ * @param params Parameters to add a hint to a span
229
+ */
230
+ async addSpanHint(params) {
231
+ try {
232
+ const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
233
+ return await apiGatewayClient.AddSpanHint(params);
234
+ }
235
+ catch (_error) {
236
+ debugIssue("addSpanHint", new Error('Error adding span hint'));
237
+ throw _error;
238
+ }
239
+ }
240
+ }
241
+
242
+ export { GrpcWebRpc, ParallaxClient };
243
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/grpc/index.ts","../../src/parallax/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;MA8Ba,UAAU,CAAA;IAIrB,WAAA,CAAY,GAAW,EAAE,MAAe,EAAA;AAHhC,QAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,KAAA,EAAA;;;;;AAAY,SAAA,CAAA;AACZ,QAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,QAAA,EAAA;;;;;AAAgB,SAAA,CAAA;AAGtB,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;AACd,QAAA,IAAI,CAAC,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ACd;IACF;AAEA;;;AAGG;IACH,MAAM,WAAW,CAAC,MAA0B,EAAA;AAC1C,QAAA,IAAI;YACF,MAAM,gBAAgB,GAAG,IAAI,UAAU,CAAC,gCAAgC,CACtE,IAAI,CAAC,aAAa,CACnB;AACD,YAAA,OAAO,MAAM,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC;QACnD;QAAE,OAAO,MAAM,EAAE;YACf,UAAU,CAAC,aAAa,EAAE,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAC9D,YAAA,MAAM,MAAM;QACd;IACF;AACD;;;;"}
@@ -0,0 +1,268 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway'), require('rxjs')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway', 'rxjs'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ParallaxWeb = {}, global.miradorGatewayParallaxWeb.parallaxGateway, global.rxjs));
5
+ })(this, (function (exports, apiGateway, rxjs) { 'use strict';
6
+
7
+ function _interopNamespaceDefault(e) {
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var apiGateway__namespace = /*#__PURE__*/_interopNamespaceDefault(apiGateway);
25
+
26
+ class GrpcWebRpc {
27
+ constructor(url, apiKey) {
28
+ Object.defineProperty(this, "url", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ Object.defineProperty(this, "apiKey", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: void 0
39
+ });
40
+ this.url = url;
41
+ this.apiKey = apiKey;
42
+ }
43
+ async request(service, method, data, metadata) {
44
+ console.log(`[gRPC-Web] Making request to ${this.url}/${service}/${method}`);
45
+ const headers = {
46
+ 'Content-Type': 'application/grpc-web+proto',
47
+ 'X-Grpc-Web': '1',
48
+ };
49
+ // Add API key to headers if provided
50
+ if (this.apiKey) {
51
+ headers['x-api-key'] = this.apiKey;
52
+ }
53
+ // Add custom metadata
54
+ if (metadata) {
55
+ Object.entries(metadata).forEach(([key, value]) => {
56
+ headers[key] = value;
57
+ });
58
+ }
59
+ try {
60
+ const response = await fetch(`${this.url}/${service}/${method}`, {
61
+ method: 'POST',
62
+ headers,
63
+ body: data.buffer,
64
+ });
65
+ if (!response.ok) {
66
+ const errorText = await response.text();
67
+ throw new Error(`gRPC-Web error: ${response.status} ${response.statusText} - ${errorText}`);
68
+ }
69
+ const arrayBuffer = await response.arrayBuffer();
70
+ console.log(`[gRPC-Web] Success from ${this.url}/${service}/${method}`);
71
+ return new Uint8Array(arrayBuffer);
72
+ }
73
+ catch (error) {
74
+ console.error(`[gRPC-Web] Error from ${this.url}/${service}/${method}:`, error instanceof Error ? error.message : String(error));
75
+ throw error;
76
+ }
77
+ }
78
+ clientStreamingRequest() {
79
+ throw new Error("Client streaming not yet implemented for gRPC-Web");
80
+ }
81
+ serverStreamingRequest(service, method, data) {
82
+ return new rxjs.Observable((subscriber) => {
83
+ const headers = {
84
+ 'Content-Type': 'application/grpc-web+proto',
85
+ 'X-Grpc-Web': '1',
86
+ };
87
+ // Add API key to headers if provided
88
+ if (this.apiKey) {
89
+ headers['x-api-key'] = this.apiKey;
90
+ }
91
+ fetch(`${this.url}/${service}/${method}`, {
92
+ method: 'POST',
93
+ headers,
94
+ body: data.buffer,
95
+ })
96
+ .then(async (response) => {
97
+ if (!response.ok) {
98
+ throw new Error(`gRPC-Web error: ${response.status} ${response.statusText}`);
99
+ }
100
+ if (!response.body) {
101
+ throw new Error('Response body is null');
102
+ }
103
+ const reader = response.body.getReader();
104
+ try {
105
+ while (true) {
106
+ const { done, value } = await reader.read();
107
+ if (done) {
108
+ subscriber.complete();
109
+ break;
110
+ }
111
+ if (value) {
112
+ subscriber.next(value);
113
+ }
114
+ }
115
+ }
116
+ catch (error) {
117
+ subscriber.error(error);
118
+ }
119
+ })
120
+ .catch((error) => {
121
+ subscriber.error(error);
122
+ });
123
+ return () => {
124
+ // Cleanup logic if needed
125
+ };
126
+ });
127
+ }
128
+ bidirectionalStreamingRequest() {
129
+ throw new Error("Bidirectional streaming not yet implemented for gRPC-Web");
130
+ }
131
+ }
132
+
133
+ const GRPC_GATEWAY_API_URL = "https://gateway-parallax-dev.platform.svc.cluster.local:50053";
134
+ const debugIssue = (trace, error) => {
135
+ // Handle our own debugging / logging here
136
+ console.error(`[ParallaxClient][${trace}] Error:`, error);
137
+ };
138
+ class ParallaxClient {
139
+ constructor(apiKey, apiUrl) {
140
+ Object.defineProperty(this, "apiKey", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: apiKey
145
+ });
146
+ Object.defineProperty(this, "apiUrl", {
147
+ enumerable: true,
148
+ configurable: true,
149
+ writable: true,
150
+ value: GRPC_GATEWAY_API_URL
151
+ });
152
+ Object.defineProperty(this, "apiGatewayRpc", {
153
+ enumerable: true,
154
+ configurable: true,
155
+ writable: true,
156
+ value: void 0
157
+ });
158
+ if (apiUrl) {
159
+ this.apiUrl = apiUrl;
160
+ }
161
+ this.apiGatewayRpc = new GrpcWebRpc(this.apiUrl, apiKey);
162
+ }
163
+ /**
164
+ * Create a new trace
165
+ * @param params Parameters to create a new trace
166
+ * @returns Response from the create trace operation
167
+ */
168
+ async createTrace(params) {
169
+ try {
170
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
171
+ return await apiGatewayClient.CreateTrace(params);
172
+ }
173
+ catch (_error) {
174
+ debugIssue("createTrace", new Error('Error creating trace'));
175
+ throw _error;
176
+ }
177
+ }
178
+ /**
179
+ * Start a new span within a trace
180
+ * @param params Parameters to start a new span
181
+ */
182
+ async startSpan(params) {
183
+ try {
184
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
185
+ return await apiGatewayClient.StartSpan(params);
186
+ }
187
+ catch (_error) {
188
+ debugIssue("startSpan", new Error('Error starting span'));
189
+ throw _error;
190
+ }
191
+ }
192
+ /**
193
+ * Finish a span within a trace
194
+ * @param params Parameters to finish a span
195
+ */
196
+ async finishSpan(params) {
197
+ try {
198
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
199
+ return await apiGatewayClient.FinishSpan(params);
200
+ }
201
+ catch (_error) {
202
+ debugIssue("finishSpan", new Error('Error finishing span'));
203
+ throw _error;
204
+ }
205
+ }
206
+ /**
207
+ * Add attributes to a span
208
+ * @param params Parameters to add attributes to a span
209
+ */
210
+ async addSpanAttributes(params) {
211
+ try {
212
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
213
+ return await apiGatewayClient.AddSpanAttributes(params);
214
+ }
215
+ catch (_error) {
216
+ debugIssue("addSpanAttributes", new Error('Error adding span attributes'));
217
+ throw _error;
218
+ }
219
+ }
220
+ /**
221
+ * Add an event to a span
222
+ * @param params Parameters to add an event to a span
223
+ */
224
+ async addSpanEvent(params) {
225
+ try {
226
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
227
+ return await apiGatewayClient.AddSpanEvent(params);
228
+ }
229
+ catch (_error) {
230
+ debugIssue("addSpanEvent", new Error('Error adding span event'));
231
+ throw _error;
232
+ }
233
+ }
234
+ /**
235
+ * Add an error to a span
236
+ * @param params Parameters to add an error to a span
237
+ */
238
+ async addSpanError(params) {
239
+ try {
240
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
241
+ return await apiGatewayClient.AddSpanError(params);
242
+ }
243
+ catch (_error) {
244
+ debugIssue("addSpanError", new Error('Error adding span error'));
245
+ throw _error;
246
+ }
247
+ }
248
+ /**
249
+ * Add a hint to a span
250
+ * @param params Parameters to add a hint to a span
251
+ */
252
+ async addSpanHint(params) {
253
+ try {
254
+ const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
255
+ return await apiGatewayClient.AddSpanHint(params);
256
+ }
257
+ catch (_error) {
258
+ debugIssue("addSpanHint", new Error('Error adding span hint'));
259
+ throw _error;
260
+ }
261
+ }
262
+ }
263
+
264
+ exports.GrpcWebRpc = GrpcWebRpc;
265
+ exports.ParallaxClient = ParallaxClient;
266
+
267
+ }));
268
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../../src/grpc/index.ts","../../src/parallax/index.ts"],"sourcesContent":[null,null],"names":["Observable","apiGateway"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;UA8Ba,UAAU,CAAA;QAIrB,WAAA,CAAY,GAAW,EAAE,MAAe,EAAA;IAHhC,QAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,KAAA,EAAA;;;;;IAAY,SAAA,CAAA;IACZ,QAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,QAAA,EAAA;;;;;IAAgB,SAAA,CAAA;IAGtB,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IACd,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACtB;QAEA,MAAM,OAAO,CACX,OAAe,EACf,MAAc,EACd,IAAgB,EAChB,QAAmB,EAAA;IAEnB,QAAA,OAAO,CAAC,GAAG,CAAC,CAAA,6BAAA,EAAgC,IAAI,CAAC,GAAG,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,CAAE,CAAC;IAE5E,QAAA,MAA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,CAAC;YACnD;YAAE,OAAO,MAAM,EAAE;gBACf,UAAU,CAAC,aAAa,EAAE,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9D,YAAA,MAAM,MAAM;YACd;QACF;IACD;;;;;;;;;"}
@@ -0,0 +1,40 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import tseslint from "typescript-eslint";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+
9
+ export default [
10
+ {
11
+ ignores: ["dist/**", "node_modules/**", "*.config.{js,mjs}", "rollup.config.mjs"],
12
+ },
13
+ {
14
+ files: ["**/*.{js,mjs,cjs,ts}"],
15
+ ...js.configs.recommended,
16
+ languageOptions: {
17
+ globals: {
18
+ ...globals.browser,
19
+ ...globals.es2020,
20
+ },
21
+ },
22
+ },
23
+ ...tseslint.configs.recommended.map(config => ({
24
+ ...config,
25
+ files: ["**/*.{ts,tsx}"],
26
+ rules: {
27
+ ...(config.rules || {}),
28
+ "react-refresh/only-export-components": "off",
29
+ },
30
+ })),
31
+ {
32
+ files: ["**/*.{ts,tsx}"],
33
+ languageOptions: {
34
+ parserOptions: {
35
+ project: "./tsconfig.json",
36
+ tsconfigRootDir: __dirname,
37
+ },
38
+ },
39
+ },
40
+ ];
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './src/parallax';
2
+ export { GrpcWebRpc } from './src/grpc';
package/jest.config.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type { Config } from 'jest';
2
+
3
+ const config: Config = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'jsdom',
6
+ roots: ['<rootDir>/tests', '<rootDir>/src'],
7
+ testMatch: ['**/*.test.ts'],
8
+ collectCoverageFrom: [
9
+ 'src/**/*.ts',
10
+ '!src/**/*.d.ts',
11
+ '!src/**/index.ts'
12
+ ],
13
+ coverageDirectory: 'coverage',
14
+ coverageReporters: ['text', 'lcov', 'html'],
15
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
16
+ verbose: true,
17
+ testTimeout: 10000,
18
+ transform: {
19
+ '^.+\\.tsx?$': 'ts-jest',
20
+ },
21
+ transformIgnorePatterns: [
22
+ 'node_modules/(?!(mirador-gateway-parallax-web)/)'
23
+ ],
24
+ };
25
+
26
+ export default config;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@miradorlabs/parallax-web",
3
+ "version": "1.0.0",
4
+ "description": "Parallax Web Client Side SDK ",
5
+ "main": "dist/index.umd.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "browser": "dist/index.umd.js",
9
+ "publishConfig": {
10
+ "access": "restricted",
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "scripts": {
14
+ "prepare": "npm run build",
15
+ "build": "rm -rf dist/ && rollup -c",
16
+ "test": "jest",
17
+ "test:watch": "jest --watch",
18
+ "test:coverage": "jest --coverage",
19
+ "release:patch": "npm version patch && git push --follow-tags",
20
+ "release:minor": "npm version minor && git push --follow-tags",
21
+ "release:major": "npm version major && git push --follow-tags"
22
+ },
23
+ "devDependencies": {
24
+ "@eslint/js": "^9.39.1",
25
+ "@rollup/plugin-commonjs": "^29.0.0",
26
+ "@rollup/plugin-node-resolve": "^16.0.3",
27
+ "@rollup/plugin-typescript": "^12.3.0",
28
+ "@types/jest": "^30.0.0",
29
+ "@types/node": "^24.10.1",
30
+ "eslint": "^9.39.1",
31
+ "eslint-config-prettier": "^10.1.8",
32
+ "eslint-plugin-prettier": "^5.5.4",
33
+ "globals": "^16.5.0",
34
+ "jest": "^30.2.0",
35
+ "jest-environment-jsdom": "^30.2.0",
36
+ "jiti": "^2.6.1",
37
+ "prettier": "^3.6.2",
38
+ "rollup": "^4.53.3",
39
+ "rollup-plugin-dts": "^6.2.3",
40
+ "ts-jest": "^29.4.5",
41
+ "ts-node": "^10.9.2",
42
+ "ts-proto": "^2.8.3",
43
+ "typescript": "^5.9.3",
44
+ "typescript-eslint": "^8.47.0"
45
+ },
46
+ "dependencies": {
47
+ "google-protobuf": "^4.0.1",
48
+ "mirador-gateway-parallax-web": "https://storage.googleapis.com/mirador-shd-packages/gateway/parallax/grpc-web/mirador-gateway-parallax-grpc-web-1.0.9.tgz",
49
+ "rxjs": "^7.8.2"
50
+ },
51
+ "author": "@mirador",
52
+ "license": "ISC"
53
+ }