altair-static 4.4.2 → 4.5.2

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.
Files changed (46) hide show
  1. package/build/dist/121.js +1 -0
  2. package/build/dist/206.js +1 -0
  3. package/build/dist/23.js +1 -0
  4. package/build/dist/243.js +1 -0
  5. package/build/dist/364.js +1 -0
  6. package/build/dist/3rdpartylicenses.txt +374 -16
  7. package/build/dist/471.js +1 -1
  8. package/build/dist/478.js +1 -0
  9. package/build/dist/482.js +1 -0
  10. package/build/dist/630.js +1 -0
  11. package/build/dist/657.js +1 -0
  12. package/build/dist/690.js +1 -0
  13. package/build/dist/747.js +1 -1
  14. package/build/dist/783.js +1 -0
  15. package/build/dist/852.js +1 -0
  16. package/build/dist/863.js +1 -0
  17. package/build/dist/assets/i18n/default.json +1 -0
  18. package/build/dist/main.js +1 -1
  19. package/build/dist/polyfills.js +1 -1
  20. package/build/dist/runtime.js +1 -1
  21. package/build/dist/styles.css +1 -2
  22. package/build/index.d.ts +357 -14
  23. package/build/index.js +91 -62
  24. package/package.json +9 -8
  25. package/src/{utils/get-altair-html.ts → get-altair-html.ts} +0 -0
  26. package/src/{utils/get-dist.ts → get-dist.ts} +1 -1
  27. package/src/index.test.ts +1 -1
  28. package/src/index.ts +5 -3
  29. package/build/dist/100.js +0 -1
  30. package/build/dist/108.js +0 -1
  31. package/build/dist/267.js +0 -1
  32. package/build/dist/379.js +0 -1
  33. package/build/dist/527.js +0 -1
  34. package/build/dist/604.js +0 -1
  35. package/build/dist/729.js +0 -1
  36. package/build/dist/790.js +0 -1
  37. package/build/dist/794.js +0 -1
  38. package/build/dist/873.js +0 -1
  39. package/build/dist/929.js +0 -1
  40. package/build/dist/934.js +0 -1
  41. package/build/index.test.d.ts +0 -2
  42. package/build/index.test.js +0 -67
  43. package/build/utils/get-altair-html.d.ts +0 -2
  44. package/build/utils/get-altair-html.js +0 -10
  45. package/build/utils/get-dist.d.ts +0 -5
  46. package/build/utils/get-dist.js +0 -9
package/build/index.d.ts CHANGED
@@ -1,15 +1,355 @@
1
- import { AltairConfigOptions } from 'altair-graphql-core/build/config';
1
+ // Generated by dts-bundle-generator v6.11.0
2
+
3
+ export function getAltairHtml(): string;
4
+ export interface IDictionary<V = any> {
5
+ [key: string]: V;
6
+ }
7
+ declare const SUBSCRIPTION_PROVIDER_IDS: {
8
+ readonly WEBSOCKET: "websocket";
9
+ readonly GRAPHQL_WS: "graphql-ws";
10
+ readonly APP_SYNC: "app-sync";
11
+ readonly ACTION_CABLE: "action-cable";
12
+ readonly GRAPHQL_SSE: "graphql-sse";
13
+ };
14
+ export declare type SubscriptionProviderIds = typeof SUBSCRIPTION_PROVIDER_IDS[keyof typeof SUBSCRIPTION_PROVIDER_IDS];
15
+ export interface InitialEnvironmentState {
16
+ id?: string;
17
+ title?: string;
18
+ variables?: IDictionary;
19
+ }
20
+ export interface IInitialEnvironments {
21
+ base?: InitialEnvironmentState;
22
+ subEnvironments?: InitialEnvironmentState[];
23
+ }
24
+ declare const HTTP_VERBS: readonly [
25
+ "POST",
26
+ "GET",
27
+ "PUT",
28
+ "DELETE"
29
+ ];
30
+ export declare type HttpVerb = typeof HTTP_VERBS[number];
31
+ declare const theme: {
32
+ easing: string;
33
+ colors: {
34
+ black: string;
35
+ darkGray: string;
36
+ gray: string;
37
+ lightGray: string;
38
+ white: string;
39
+ green: string;
40
+ blue: string;
41
+ cerise: string;
42
+ red: string;
43
+ orange: string;
44
+ yellow: string;
45
+ lightRed: string;
46
+ darkPurple: string;
47
+ };
48
+ type: {
49
+ fontSize: {
50
+ base: number;
51
+ remBase: number;
52
+ body: number;
53
+ bodySmaller: number;
54
+ };
55
+ fontFamily: {
56
+ default: string;
57
+ };
58
+ };
59
+ } & {
60
+ isSystem: boolean;
61
+ colors: {
62
+ primary: string;
63
+ secondary: string;
64
+ bg: string;
65
+ offBg: string;
66
+ font: string;
67
+ offFont: string;
68
+ border: string;
69
+ offBorder: string;
70
+ headerBg: string;
71
+ };
72
+ shadow: {
73
+ color: string;
74
+ opacity: number;
75
+ };
76
+ editor: {
77
+ fontFamily: {
78
+ default: string;
79
+ };
80
+ fontSize: number;
81
+ colors: {
82
+ comment: string;
83
+ string: string;
84
+ number: string;
85
+ variable: string;
86
+ keyword: string;
87
+ atom: string;
88
+ attribute: string;
89
+ property: string;
90
+ punctuation: string;
91
+ definition: string;
92
+ builtin: string;
93
+ cursor: string;
94
+ };
95
+ };
96
+ };
97
+ export declare type RecursivePartial<T> = {
98
+ [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
99
+ };
100
+ export declare type ITheme = typeof theme;
101
+ export declare type ICustomTheme = RecursivePartial<ITheme>;
102
+ declare const config: AltairConfig;
103
+ export declare type SettingsLanguage = keyof typeof config.languages;
104
+ export interface SettingsState {
105
+ /**
106
+ * Theme
107
+ */
108
+ theme: string;
109
+ /**
110
+ * Theme for dark mode
111
+ */
112
+ "theme.dark"?: string;
113
+ /**
114
+ * Set language
115
+ */
116
+ language: SettingsLanguage;
117
+ /**
118
+ * 'Add query' functionality depth
119
+ */
120
+ addQueryDepthLimit: number;
121
+ /**
122
+ * Editor tab size
123
+ */
124
+ tabSize: number;
125
+ /**
126
+ * Enable experimental features.
127
+ * Note: Might be unstable
128
+ */
129
+ enableExperimental?: boolean;
130
+ /**
131
+ * Base Font Size
132
+ * (Default - 24)
133
+ */
134
+ "theme.fontsize"?: number;
135
+ /**
136
+ * Editor Font Family
137
+ */
138
+ "theme.editorFontFamily"?: string;
139
+ /**
140
+ * Editor Font Size
141
+ */
142
+ "theme.editorFontSize"?: number;
143
+ /**
144
+ * Disable push notifications
145
+ */
146
+ disablePushNotification?: boolean;
147
+ /**
148
+ * Enabled plugins
149
+ */
150
+ "plugin.list"?: string[];
151
+ /**
152
+ * Send requests with credentials (cookies)
153
+ */
154
+ "request.withCredentials"?: boolean;
155
+ /**
156
+ * Reload schema on app start
157
+ */
158
+ "schema.reloadOnStart"?: boolean;
159
+ /**
160
+ * Disable update notification
161
+ */
162
+ "alert.disableUpdateNotification"?: boolean;
163
+ /**
164
+ * Disable warning alerts
165
+ */
166
+ "alert.disableWarnings"?: boolean;
167
+ /**
168
+ * Number of items allowed in history pane
169
+ */
170
+ historyDepth?: number;
171
+ /**
172
+ * Theme config object
173
+ */
174
+ themeConfig?: ICustomTheme;
175
+ /**
176
+ * Theme config object for dark mode
177
+ */
178
+ "themeConfig.dark"?: ICustomTheme;
179
+ /**
180
+ * Hides extensions object
181
+ */
182
+ "response.hideExtensions"?: boolean;
183
+ /**
184
+ * Contains shortcut to action mapping
185
+ */
186
+ "editor.shortcuts"?: Record<string, string>;
187
+ }
188
+ export interface AltairWindowOptions {
189
+ /**
190
+ * Initial name of the window
191
+ */
192
+ initialName?: string;
193
+ /**
194
+ * URL to set as the server endpoint
195
+ */
196
+ endpointURL?: string;
197
+ /**
198
+ * URL to set as the subscription endpoint. This can be relative or absolute.
199
+ */
200
+ subscriptionsEndpoint?: string;
201
+ /**
202
+ * URL protocol for the subscription endpoint. This is used if the specified subscriptions endpoint is relative.
203
+ * e.g. wss
204
+ */
205
+ subscriptionsProtocol?: string;
206
+ /**
207
+ * Initial query to be added
208
+ */
209
+ initialQuery?: string;
210
+ /**
211
+ * Initial variables to be added
212
+ */
213
+ initialVariables?: string;
214
+ /**
215
+ * Initial pre-request script to be added
216
+ */
217
+ initialPreRequestScript?: string;
218
+ /**
219
+ * Initial post-request script to be added
220
+ */
221
+ initialPostRequestScript?: string;
222
+ /**
223
+ * Initial headers object to be added
224
+ * @example
225
+ * {
226
+ * 'X-GraphQL-Token': 'asd7-237s-2bdk-nsdk4'
227
+ * }
228
+ */
229
+ initialHeaders?: IDictionary;
230
+ /**
231
+ * Initial subscriptions provider
232
+ *
233
+ * @default "websocket"
234
+ */
235
+ initialSubscriptionsProvider?: SubscriptionProviderIds;
236
+ /**
237
+ * Initial subscriptions connection params
238
+ */
239
+ initialSubscriptionsPayload?: IDictionary;
240
+ /**
241
+ * HTTP method to use for making requests
242
+ */
243
+ initialHttpMethod?: HttpVerb;
244
+ }
245
+ export interface AltairConfigOptions extends AltairWindowOptions {
246
+ /**
247
+ * Initial Environments to be added
248
+ * @example
249
+ * {
250
+ * base: {
251
+ * title: 'Environment',
252
+ * variables: {}
253
+ * },
254
+ * subEnvironments: [
255
+ * {
256
+ * title: 'sub-1',
257
+ * variables: {}
258
+ * }
259
+ * ]
260
+ * }
261
+ */
262
+ initialEnvironments?: IInitialEnvironments;
263
+ /**
264
+ * Namespace for storing the data for the altair instance.
265
+ * Use this when you have multiple altair instances running on the same domain.
266
+ * @example
267
+ * instanceStorageNamespace: 'altair_dev_'
268
+ */
269
+ instanceStorageNamespace?: string;
270
+ /**
271
+ * Initial app settings to use
272
+ */
273
+ initialSettings?: Partial<SettingsState>;
274
+ /**
275
+ * Indicates if the state should be preserved for subsequent app loads
276
+ *
277
+ * @default true
278
+ */
279
+ preserveState?: boolean;
280
+ /**
281
+ * List of options for windows to be loaded
282
+ */
283
+ initialWindows?: AltairWindowOptions[];
284
+ }
285
+ declare class AltairConfig {
286
+ donation: {
287
+ url: string;
288
+ action_count_threshold: number;
289
+ };
290
+ ga: string;
291
+ add_query_depth_limit: number;
292
+ tab_size: number;
293
+ max_windows: number;
294
+ default_language: string;
295
+ languages: {
296
+ "en-US": string;
297
+ "fr-FR": string;
298
+ "es-ES": string;
299
+ "cs-CZ": string;
300
+ "de-DE": string;
301
+ "pt-BR": string;
302
+ "ru-RU": string;
303
+ "uk-UA": string;
304
+ "zh-CN": string;
305
+ "ja-JP": string;
306
+ "sr-SP": string;
307
+ "it-IT": string;
308
+ "pl-PL": string;
309
+ "ko-KR": string;
310
+ "ro-RO": string;
311
+ "vi-VN": string;
312
+ };
313
+ query_history_depth: number;
314
+ defaultTheme: string;
315
+ themes: string[];
316
+ isTranslateMode: any;
317
+ isWebApp: any;
318
+ initialData: {
319
+ url: string;
320
+ subscriptionsEndpoint: string;
321
+ subscriptionsProtocol: string;
322
+ query: string;
323
+ variables: string;
324
+ headers: IDictionary<any>;
325
+ environments: IInitialEnvironments;
326
+ preRequestScript: string;
327
+ postRequestScript: string;
328
+ instanceStorageNamespace: string;
329
+ settings: Partial<SettingsState>;
330
+ initialSubscriptionsProvider: SubscriptionProviderIds;
331
+ initialSubscriptionsPayload: IDictionary<any>;
332
+ initialHttpMethod: "POST" | "GET" | "PUT" | "DELETE";
333
+ preserveState: boolean;
334
+ windows: AltairWindowOptions[];
335
+ };
336
+ constructor({ endpointURL, subscriptionsEndpoint, subscriptionsProtocol, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript, instanceStorageNamespace, initialSettings, initialSubscriptionsProvider, initialSubscriptionsPayload, initialHttpMethod, preserveState, initialWindows, }?: AltairConfigOptions);
337
+ }
338
+ /**
339
+ * Returns the path to Altair assets, for resolving the assets when rendering Altair
340
+ */
341
+ export declare const getDistDirectory: () => string;
2
342
  export interface RenderOptions extends AltairConfigOptions {
3
- /**
4
- * URL to be used as a base for relative URLs
5
- */
6
- baseURL?: string;
7
- /**
8
- * Whether to render the initial options in a seperate javascript file or not.
9
- * Use this to be able to enforce strict CSP rules.
10
- * @default false
11
- */
12
- serveInitialOptionsInSeperateRequest?: boolean;
343
+ /**
344
+ * URL to be used as a base for relative URLs
345
+ */
346
+ baseURL?: string;
347
+ /**
348
+ * Whether to render the initial options in a seperate javascript file or not.
349
+ * Use this to be able to enforce strict CSP rules.
350
+ * @default false
351
+ */
352
+ serveInitialOptionsInSeperateRequest?: boolean;
13
353
  }
14
354
  /**
15
355
  * Render Altair Initial options as a string using the provided renderOptions
@@ -21,6 +361,9 @@ export declare const renderInitialOptions: (options?: RenderOptions) => string;
21
361
  * @param renderOptions
22
362
  */
23
363
  export declare const renderAltair: (options?: RenderOptions) => string;
24
- export { getDistDirectory } from './utils/get-dist';
25
- export default renderAltair;
26
- //# sourceMappingURL=index.d.ts.map
364
+
365
+ export {
366
+ renderAltair as default,
367
+ };
368
+
369
+ export {};
package/build/index.js CHANGED
@@ -1,70 +1,99 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDistDirectory = exports.renderAltair = exports.renderInitialOptions = void 0;
4
- const get_altair_html_1 = require("./utils/get-altair-html");
5
- /**
6
- * Render Altair Initial options as a string using the provided renderOptions
7
- * @param renderOptions
8
- */
9
- exports.renderInitialOptions = (options = {}) => {
10
- return `
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ default: () => src_default,
23
+ getAltairHtml: () => getAltairHtml,
24
+ getDistDirectory: () => getDistDirectory,
25
+ renderAltair: () => renderAltair,
26
+ renderInitialOptions: () => renderInitialOptions
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+
30
+ // src/get-altair-html.ts
31
+ var import_fs = require("fs");
32
+ var import_path2 = require("path");
33
+
34
+ // src/get-dist.ts
35
+ var import_path = require("path");
36
+ var getDistDirectory = () => (0, import_path.resolve)(__dirname, "./dist");
37
+
38
+ // src/get-altair-html.ts
39
+ function getAltairHtml() {
40
+ return (0, import_fs.readFileSync)((0, import_path2.resolve)(getDistDirectory(), "index.html"), "utf8");
41
+ }
42
+
43
+ // src/index.ts
44
+ var renderInitialOptions = (options = {}) => {
45
+ return `
11
46
  AltairGraphQL.init(${getRenderedAltairOpts(options, [
12
- 'endpointURL',
13
- 'subscriptionsEndpoint',
14
- 'initialQuery',
15
- 'initialVariables',
16
- 'initialPreRequestScript',
17
- 'initialPostRequestScript',
18
- 'initialHeaders',
19
- 'initialEnvironments',
20
- 'instanceStorageNamespace',
21
- 'initialSettings',
22
- 'initialSubscriptionsProvider',
23
- 'initialSubscriptionsPayload',
24
- 'preserveState',
25
- 'initialHttpMethod',
26
- 'initialWindows',
27
- ])});
47
+ "endpointURL",
48
+ "subscriptionsEndpoint",
49
+ "subscriptionsProtocol",
50
+ "initialQuery",
51
+ "initialVariables",
52
+ "initialPreRequestScript",
53
+ "initialPostRequestScript",
54
+ "initialHeaders",
55
+ "initialEnvironments",
56
+ "instanceStorageNamespace",
57
+ "initialSettings",
58
+ "initialSubscriptionsProvider",
59
+ "initialSubscriptionsPayload",
60
+ "preserveState",
61
+ "initialHttpMethod",
62
+ "initialWindows"
63
+ ])});
28
64
  `;
29
65
  };
30
- /**
31
- * Render Altair as a string using the provided renderOptions
32
- * @param renderOptions
33
- */
34
- exports.renderAltair = (options = {}) => {
35
- const altairHtml = get_altair_html_1.default();
36
- const initialOptions = exports.renderInitialOptions(options);
37
- const baseURL = options.baseURL || './';
38
- if (options.serveInitialOptionsInSeperateRequest) {
39
- return altairHtml
40
- .replace(/<base.*>/, `<base href="${baseURL}">`)
41
- .replace('</body>', `<script src="initial_options.js"></script></body>`);
42
- }
43
- else {
44
- return altairHtml
45
- .replace(/<base.*>/, `<base href="${baseURL}">`)
46
- .replace('</body>', `<script>${initialOptions}</script></body>`);
47
- }
66
+ var renderAltair = (options = {}) => {
67
+ const altairHtml = getAltairHtml();
68
+ const initialOptions = renderInitialOptions(options);
69
+ const baseURL = options.baseURL || "./";
70
+ if (options.serveInitialOptionsInSeperateRequest) {
71
+ return altairHtml.replace(/<base.*>/, `<base href="${baseURL}">`).replace("</body>", `<script src="initial_options.js"><\/script></body>`);
72
+ } else {
73
+ return altairHtml.replace(/<base.*>/, `<base href="${baseURL}">`).replace("</body>", `<script>${initialOptions}<\/script></body>`);
74
+ }
48
75
  };
49
- const getRenderedAltairOpts = (renderOptions, keys) => {
50
- const optProps = Object.keys(renderOptions)
51
- .filter((key) => keys.includes(key))
52
- .map(key => getObjectPropertyForOption(renderOptions[key], key));
53
- return ['{', ...optProps, '}'].join('\n');
76
+ var getRenderedAltairOpts = (renderOptions, keys) => {
77
+ const optProps = Object.keys(renderOptions).filter((key) => keys.includes(key)).map((key) => getObjectPropertyForOption(renderOptions[key], key));
78
+ return ["{", ...optProps, "}"].join("\n");
54
79
  };
55
80
  function getObjectPropertyForOption(option, propertyName) {
56
- if (typeof option !== 'undefined') {
57
- switch (typeof option) {
58
- case 'object':
59
- return `${propertyName}: ${JSON.stringify(option)},`;
60
- case 'boolean':
61
- return `${propertyName}: ${option},`;
62
- }
63
- return `${propertyName}: \`${option}\`,`;
81
+ if (typeof option !== "undefined") {
82
+ switch (typeof option) {
83
+ case "object":
84
+ return `${propertyName}: ${JSON.stringify(option)},`;
85
+ case "boolean":
86
+ return `${propertyName}: ${option},`;
64
87
  }
65
- return '';
88
+ return `${propertyName}: \`${option}\`,`;
89
+ }
90
+ return "";
66
91
  }
67
- var get_dist_1 = require("./utils/get-dist");
68
- Object.defineProperty(exports, "getDistDirectory", { enumerable: true, get: function () { return get_dist_1.getDistDirectory; } });
69
- exports.default = exports.renderAltair;
70
- //# sourceMappingURL=index.js.map
92
+ var src_default = renderAltair;
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ getAltairHtml,
96
+ getDistDirectory,
97
+ renderAltair,
98
+ renderInitialOptions
99
+ });
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "altair-static",
3
- "version": "4.4.2",
3
+ "version": "4.5.2",
4
4
  "description": "Static package for altair graphql client",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "jest",
9
9
  "prepare-dist": "node scripts/prepare_dist.js",
10
- "compile": "tsc --declaration",
11
- "prepare": "npm run prepare-dist && npm run compile"
10
+ "compile": "node scripts/build.js",
11
+ "prepare": "yarn prepare-dist && yarn compile && yarn types",
12
+ "types": "dts-bundle-generator src/index.ts -o build/index.d.ts --external-inlines altair-graphql-core --external-inlines altair-static"
12
13
  },
13
14
  "engines": {
14
15
  "node": ">= 6.9.1"
@@ -28,12 +29,12 @@
28
29
  "url": "https://github.com/altair-graphql/altair/issues"
29
30
  },
30
31
  "homepage": "https://github.com/altair-graphql/altair#readme",
31
- "dependencies": {
32
- "altair-graphql-core": "^4.4.2"
33
- },
34
32
  "devDependencies": {
35
33
  "@types/jest": "^24.0.23",
36
- "altair-app": "^4.4.2",
34
+ "altair-app": "^4.5.2",
35
+ "altair-graphql-core": "^4.5.2",
36
+ "dts-bundle-generator": "^6.11.0",
37
+ "esbuild": "^0.14.43",
37
38
  "jest": "^24.9.0",
38
39
  "ts-jest": "^24.2.0",
39
40
  "typescript": "4.0.7"
@@ -43,5 +44,5 @@
43
44
  "url": "https://opencollective.com/altair",
44
45
  "logo": "https://opencollective.com/altair/logo.txt"
45
46
  },
46
- "gitHead": "44bf6dbb486b9afb51be1cb56228903346f515d4"
47
+ "gitHead": "9536b57d20d1e05b013adf3c0885a8bfef8e2b88"
47
48
  }
@@ -3,4 +3,4 @@ import { resolve } from 'path';
3
3
  /**
4
4
  * Returns the path to Altair assets, for resolving the assets when rendering Altair
5
5
  */
6
- export const getDistDirectory = () => resolve(__dirname, '../dist');
6
+ export const getDistDirectory = () => resolve(__dirname, './dist');
package/src/index.test.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
3
  import { renderAltair, renderInitialOptions } from './index';
4
- import * as getAltairHtml from './utils/get-altair-html';
4
+ import * as getAltairHtml from './get-altair-html';
5
5
 
6
6
  const translateRenderedStrToObj = (result) => {
7
7
  const resultObj = Function(`
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import getAltairHtml from './utils/get-altair-html';
2
- import { AltairConfigOptions } from 'altair-graphql-core/build/config';
1
+ import getAltairHtml from './get-altair-html';
2
+ import type { AltairConfigOptions } from 'altair-graphql-core/build/config';
3
3
 
4
4
  export interface RenderOptions extends AltairConfigOptions {
5
5
  /**
@@ -25,6 +25,7 @@ export const renderInitialOptions = (options: RenderOptions = {}) => {
25
25
  getRenderedAltairOpts(options, [
26
26
  'endpointURL',
27
27
  'subscriptionsEndpoint',
28
+ 'subscriptionsProtocol',
28
29
  'initialQuery',
29
30
  'initialVariables',
30
31
  'initialPreRequestScript',
@@ -82,6 +83,7 @@ function getObjectPropertyForOption(option: any, propertyName: keyof AltairConfi
82
83
  return '';
83
84
  }
84
85
 
85
- export { getDistDirectory } from './utils/get-dist';
86
+ export { getDistDirectory } from './get-dist';
87
+ export { getAltairHtml };
86
88
 
87
89
  export default renderAltair;
package/build/dist/100.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkaltair_app=self.webpackChunkaltair_app||[]).push([[100],{22100:(se,Q,S)=>{S.r(Q),S.d(Q,{GraphQLWsSubscriptionProvider:()=>_});var H=S(71251),J=S(82475),h=S(8239);const E=Object.prototype.hasOwnProperty;function C(e){return"object"==typeof e&&null!==e}function O(e,n){return E.call(e,n)}function A(e,n){return E.call(e,n)&&C(e[n])}function w(e,n){return E.call(e,n)&&"string"==typeof e[n]}const K="graphql-transport-ws";var s=(()=>{return(e=s||(s={})).ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete",s;var e})();function G(e){if(C(e)){if(!w(e,"type"))return!1;switch(e.type){case s.ConnectionInit:return!O(e,"payload")||void 0===e.payload||C(e.payload);case s.ConnectionAck:case s.Ping:case s.Pong:return!O(e,"payload")||void 0===e.payload||C(e.payload);case s.Subscribe:return w(e,"id")&&A(e,"payload")&&(!O(e.payload,"operationName")||null==e.payload.operationName||"string"==typeof e.payload.operationName)&&w(e.payload,"query")&&(!O(e.payload,"variables")||null==e.payload.variables||A(e.payload,"variables"))&&(!O(e.payload,"extensions")||null==e.payload.extensions||A(e.payload,"extensions"));case s.Next:return w(e,"id")&&A(e,"payload");case s.Error:return w(e,"id")&&function(e){return Array.isArray(e)&&e.length>0&&e.every(n=>"message"in n)}(e.payload);case s.Complete:return w(e,"id");default:return!1}}return!1}function V(e,n){if(G(e))return e;if("string"!=typeof e)throw new Error("Message not parsable");const c=JSON.parse(e,n);if(!G(c))throw new Error("Invalid message");return c}function N(e,n){if(!G(e))throw new Error("Cannot stringify invalid message");return JSON.stringify(e,n)}function v(e){return C(e)&&"code"in e&&"reason"in e}class _ extends H.q{createClient(){this.client=function(e){const{url:n,connectionParams:c,lazy:y=!0,onNonLazyError:R=console.error,lazyCloseTimeout:M=0,keepAlive:T=0,disablePong:ee,retryAttempts:q=5,retryWait:ne=function(){var t=(0,h.Z)(function*(a){let i=1e3;for(let o=0;o<a;o++)i*=2;yield new Promise(o=>setTimeout(o,i+Math.floor(2700*Math.random()+300)))});return function(a){return t.apply(this,arguments)}}(),isFatalConnectionProblem:te=(t=>!v(t)),on:r,webSocketImpl:Z,generateID:re=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,u=>{const a=16*Math.random()|0;return("x"==u?a:3&a|8).toString(16)})},jsonMessageReplacer:z,jsonMessageReviver:oe}=e;let b;if(Z){if(!function(e){return"function"==typeof e&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}(Z))throw new Error("Invalid WebSocket implementation provided");b=Z}else"undefined"!=typeof WebSocket?b=WebSocket:"undefined"!=typeof global?b=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&(b=window.WebSocket||window.MozWebSocket);if(!b)throw new Error("WebSocket implementation missing");const k=b,p=(()=>{const t=(()=>{const a={};return{on:(i,o)=>(a[i]=o,()=>{delete a[i]}),emit(i){var o;"id"in i&&(null===(o=a[i.id])||void 0===o||o.call(a,i))}}})(),u={connecting:(null==r?void 0:r.connecting)?[r.connecting]:[],connected:(null==r?void 0:r.connected)?[r.connected]:[],ping:(null==r?void 0:r.ping)?[r.ping]:[],pong:(null==r?void 0:r.pong)?[r.pong]:[],message:(null==r?void 0:r.message)?[t.emit,r.message]:[t.emit],closed:(null==r?void 0:r.closed)?[r.closed]:[],error:(null==r?void 0:r.error)?[r.error]:[]};return{onMessage:t.on,on(a,i){const o=u[a];return o.push(i),()=>{o.splice(o.indexOf(i),1)}},emit(a,...i){for(const o of u[a])o(...i)}}})();let m,g=0,F=!1,I=0,U=!1;function j(){return D.apply(this,arguments)}function D(){return(D=(0,h.Z)(function*(){const[t,u]=yield null!=m?m:m=new Promise((o,x)=>(0,h.Z)(function*(){if(F){if(yield ne(I),!g)return m=void 0,x({code:1e3,reason:"All Subscriptions Gone"});I++}p.emit("connecting");const l=new k("function"==typeof n?yield n():n,K);let P;function W(){isFinite(T)&&T>0&&(clearTimeout(P),P=setTimeout(()=>{l.readyState===k.OPEN&&(l.send(N({type:s.Ping})),p.emit("ping",!1,void 0))},T))}l.onerror=f=>{p.emit("error",f)},l.onclose=f=>{m=void 0,clearTimeout(P),p.emit("closed",f),x(f)},l.onopen=(0,h.Z)(function*(){try{l.send(N({type:s.ConnectionInit,payload:"function"==typeof c?yield c():c},z)),W()}catch(f){l.close(4400,f instanceof Error?f.message:new Error(f).message)}});let L=!1;l.onmessage=({data:f})=>{try{const d=V(f,oe);if(p.emit("message",d),"ping"===d.type||"pong"===d.type)return p.emit(d.type,!0,d.payload),void("pong"===d.type?W():ee||(l.send(N(d.payload?{type:s.Pong,payload:d.payload}:{type:s.Pong})),p.emit("pong",!1,d.payload)));if(L)return;if(d.type!==s.ConnectionAck)throw new Error(`First message cannot be of type ${d.type}`);L=!0,p.emit("connected",l,d.payload),F=!1,I=0,o([l,new Promise((le,ie)=>l.addEventListener("close",ie))])}catch(d){l.close(4400,d instanceof Error?d.message:new Error(d).message)}}})());t.readyState===k.CLOSING&&(yield u);let a=()=>{};const i=new Promise(o=>a=o);return[t,a,Promise.race([i.then(()=>{if(!g){const o=()=>t.close(1e3,"Normal Closure");isFinite(M)&&M>0?setTimeout(()=>{!g&&t.readyState===k.OPEN&&o()},M):o()}}),u])]})).apply(this,arguments)}function B(t){if(v(t)&&[1002,1011,4400,4401,4409,4429].includes(t.code))throw t;if(U)return!1;if(v(t)&&1e3===t.code)return g>0;if(!q||I>=q||te(t))throw t;return F=!0}return y||(0,h.Z)(function*(){for(g++;;)try{const[,,t]=yield j();yield t}catch(t){try{if(!B(t))return}catch(u){return null==R?void 0:R(u)}}})(),{on:p.on,subscribe(t,u){const a=re();let i=!1,o=!1,x=()=>{g--,i=!0};return(0,h.Z)(function*(){for(g++;;)try{const[l,P,W]=yield j();if(i)return P();const L=p.onMessage(a,f=>{switch(f.type){case s.Next:return void u.next(f.payload);case s.Error:return o=!0,i=!0,u.error(f.payload),void x();case s.Complete:return i=!0,void x()}});return l.send(N({id:a,type:s.Subscribe,payload:t},z)),x=()=>{!i&&l.readyState===k.OPEN&&l.send(N({id:a,type:s.Complete},z)),g--,i=!0,P()},void(yield W.finally(L))}catch(l){if(!B(l))return}})().catch(u.error).then(()=>{o||u.complete()}),()=>{i||x()}},dispose:()=>(0,h.Z)(function*(){if(U=!0,m){const[t]=yield m;t.close(1e3,"Normal Closure")}})()}}({url:this.subscriptionUrl,connectionParams:this.connectionParams,on:{connected:()=>{var n,c;null==(c=null==(n=this.extraOptions)?void 0:n.onConnected)||c.call(n,void 0,void 0)},error:n=>{var c,y;null==(y=null==(c=this.extraOptions)?void 0:c.onConnected)||y.call(c,n,void 0)}}})}execute(n){if(this.createClient(),!this.client)throw new Error("Could not create subscription client!");return new J.y(c=>{this.cleanup=this.client.subscribe({query:n.query,variables:n.variables,operationName:n.operationName},{next:(...y)=>c.next(...y),error:(...y)=>c.error(...y),complete:()=>c.complete()})})}close(){var n,c;null==(n=this.cleanup)||n.call(this),this.cleanup=void 0,null==(c=this.client)||c.dispose(),this.client=void 0}}}}]);