fontdue-js 2.0.0-alpha6 → 2.0.0-alpha7

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 (99) hide show
  1. package/dist/__generated__/CharacterViewerIDQuery.graphql.d.ts +21 -0
  2. package/dist/__generated__/CharacterViewerIDQuery.graphql.js +230 -0
  3. package/dist/__generated__/CharacterViewerSlugQuery.graphql.d.ts +25 -0
  4. package/dist/__generated__/CharacterViewerSlugQuery.graphql.js +257 -0
  5. package/dist/__generated__/NewsletterSignupQuery.graphql.d.ts +21 -0
  6. package/dist/__generated__/NewsletterSignupQuery.graphql.js +99 -0
  7. package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +32 -0
  8. package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +385 -0
  9. package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -2
  10. package/dist/__generated__/TypeTestersIDQuery.graphql.js +70 -107
  11. package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -2
  12. package/dist/__generated__/TypeTestersSlugQuery.graphql.js +70 -107
  13. package/dist/__generated__/TypeTesters_collection.graphql.d.ts +1 -1
  14. package/dist/__generated__/TypeTesters_collection.graphql.js +5 -14
  15. package/dist/components/BuyButton/BuyButton.server.d.ts +3 -0
  16. package/dist/components/BuyButton/BuyButton.server.js +39 -0
  17. package/dist/components/BuyButton/index.d.ts +11 -3
  18. package/dist/components/BuyButton/index.js +39 -13
  19. package/dist/components/BuyButton/index.server.d.ts +3 -0
  20. package/dist/components/BuyButton/index.server.js +37 -0
  21. package/dist/components/CartButton/index-server.d.ts +3 -0
  22. package/dist/components/CartButton/index-server.js +18 -0
  23. package/dist/components/CartButton/index.d.ts +9 -3
  24. package/dist/components/CartButton/index.js +22 -9
  25. package/dist/components/CartButton/index.server.d.ts +3 -0
  26. package/dist/components/CartButton/index.server.js +18 -0
  27. package/dist/components/CharacterViewer/index.d.ts +11 -3
  28. package/dist/components/CharacterViewer/index.js +88 -23
  29. package/dist/components/CharacterViewer/index.server.d.ts +3 -0
  30. package/dist/components/CharacterViewer/index.server.js +37 -0
  31. package/dist/components/FontdueProvider/FontdueProviderClientComponent.d.ts +14 -0
  32. package/dist/components/FontdueProvider/FontdueProviderClientComponent.js +44 -0
  33. package/dist/components/FontdueProvider/index.d.ts +3 -13
  34. package/dist/components/FontdueProvider/index.js +11 -31
  35. package/dist/components/FontdueProvider/index.server.d.ts +4 -0
  36. package/dist/components/FontdueProvider/index.server.js +27 -0
  37. package/dist/components/NewsletterSignup/index.d.ts +11 -3
  38. package/dist/components/NewsletterSignup/index.js +27 -12
  39. package/dist/components/NewsletterSignup/index.server.d.ts +3 -0
  40. package/dist/components/NewsletterSignup/index.server.js +18 -0
  41. package/dist/components/Precart/index.js +5 -3
  42. package/dist/components/PriceBar/PriceBarSection.js +3 -2
  43. package/dist/components/SKUPrice/index.js +4 -3
  44. package/dist/components/StoreModalProductSummary/index.js +3 -0
  45. package/dist/components/Stylesheet/index.js +1 -0
  46. package/dist/components/TestFontsForm/index.d.ts +7 -3
  47. package/dist/components/TestFontsForm/index.js +28 -11
  48. package/dist/components/TestFontsForm/index.server.d.ts +3 -0
  49. package/dist/components/TestFontsForm/index.server.js +18 -0
  50. package/dist/components/TestModeBanner/index.d.ts +6 -2
  51. package/dist/components/TestModeBanner/index.js +28 -10
  52. package/dist/components/TestModeBanner/index.server.d.ts +2 -0
  53. package/dist/components/TestModeBanner/index.server.js +17 -0
  54. package/dist/components/ThemeConfig/index.d.ts +6 -2
  55. package/dist/components/ThemeConfig/index.js +27 -10
  56. package/dist/components/ThemeConfig/index.server.d.ts +2 -0
  57. package/dist/components/ThemeConfig/index.server.js +17 -0
  58. package/dist/components/TypeTester/TypeTesterSlider.js +1 -1
  59. package/dist/components/TypeTester/TypeTesterStandalone.d.ts +12 -5
  60. package/dist/components/TypeTester/TypeTesterStandalone.js +43 -20
  61. package/dist/components/TypeTester/TypeTesterStandalone.server.d.ts +3 -0
  62. package/dist/components/TypeTester/TypeTesterStandalone.server.js +26 -0
  63. package/dist/components/TypeTesters/index.d.ts +11 -4
  64. package/dist/components/TypeTesters/index.js +50 -54
  65. package/dist/components/TypeTesters/index.server.d.ts +3 -0
  66. package/dist/components/TypeTesters/index.server.js +43 -0
  67. package/dist/fontdue.css +2656 -0
  68. package/dist/react-ranger.d.js +1 -0
  69. package/dist/react-ranger.js +306 -0
  70. package/dist/relay/environment.d.ts +10 -0
  71. package/dist/relay/environment.js +84 -0
  72. package/dist/relay/loadSerializableQuery.d.ts +7 -0
  73. package/dist/relay/loadSerializableQuery.js +19 -0
  74. package/dist/relay/useSerializablePreloadedQuery.d.ts +4 -0
  75. package/dist/relay/useSerializablePreloadedQuery.js +44 -0
  76. package/fontdue.css +0 -2
  77. package/package.json +43 -8
  78. package/BuyButton.d.ts +0 -3
  79. package/BuyButton.js +0 -1
  80. package/CartButton.d.ts +0 -3
  81. package/CartButton.js +0 -1
  82. package/CharacterViewer.d.ts +0 -3
  83. package/CharacterViewer.js +0 -1
  84. package/CustomerLoginForm.d.ts +0 -3
  85. package/CustomerLoginForm.js +0 -1
  86. package/FontdueProvider.d.ts +0 -3
  87. package/FontdueProvider.js +0 -1
  88. package/NewsletterSignup.d.ts +0 -3
  89. package/NewsletterSignup.js +0 -1
  90. package/StoreModal.d.ts +0 -3
  91. package/StoreModal.js +0 -1
  92. package/TestFontsForm.d.ts +0 -3
  93. package/TestFontsForm.js +0 -1
  94. package/TypeTester.d.ts +0 -3
  95. package/TypeTester.js +0 -1
  96. package/TypeTesters.d.ts +0 -3
  97. package/TypeTesters.js +0 -1
  98. package/useFontStyle.d.ts +0 -3
  99. package/useFontStyle.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,306 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRanger = useRanger;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const getBoundingClientRect = element => {
10
+ const rect = element.getBoundingClientRect();
11
+ return {
12
+ left: Math.ceil(rect.left),
13
+ width: Math.ceil(rect.width)
14
+ };
15
+ };
16
+ const sortNumList = arr => [...arr].sort((a, b) => Number(a) - Number(b));
17
+ const useGetLatest = val => {
18
+ const ref = _react.default.useRef(val);
19
+ ref.current = val;
20
+ return _react.default.useCallback(() => ref.current, []);
21
+ };
22
+ const linearInterpolator = {
23
+ getPercentageForValue: (val, min, max) => {
24
+ return Math.max(0, Math.min(100, (val - min) / (max - min) * 100));
25
+ },
26
+ getValueForClientX: (clientX, trackDims, min, max) => {
27
+ const {
28
+ left,
29
+ width
30
+ } = trackDims;
31
+ const percentageValue = (clientX - left) / width;
32
+ const value = (max - min) * percentageValue;
33
+ return value + min;
34
+ }
35
+ };
36
+ function useRanger(_ref) {
37
+ let {
38
+ interpolator = linearInterpolator,
39
+ tickSize = 10,
40
+ values,
41
+ min,
42
+ max,
43
+ ticks: controlledTicks,
44
+ steps,
45
+ onChange,
46
+ onDrag,
47
+ stepSize
48
+ } = _ref;
49
+ const [activeHandleIndex, setActiveHandleIndex] = _react.default.useState(null);
50
+ const [tempValues, setTempValues] = _react.default.useState();
51
+ const getLatest = useGetLatest({
52
+ activeHandleIndex,
53
+ onChange,
54
+ onDrag,
55
+ values,
56
+ tempValues
57
+ });
58
+ const trackElRef = _react.default.useRef();
59
+ const getValueForClientX = _react.default.useCallback(clientX => {
60
+ const trackDims = getBoundingClientRect(trackElRef.current);
61
+ return interpolator.getValueForClientX(clientX, trackDims, min, max);
62
+ }, [interpolator, max, min]);
63
+ const getNextStep = _react.default.useCallback((val, direction) => {
64
+ if (steps) {
65
+ let currIndex = steps.indexOf(val);
66
+ let nextIndex = currIndex + direction;
67
+ if (nextIndex >= 0 && nextIndex < steps.length) {
68
+ return steps[nextIndex];
69
+ } else {
70
+ return val;
71
+ }
72
+ } else {
73
+ if (process.env.NODE_ENV !== 'production') {
74
+ if (typeof stepSize === 'undefined') {
75
+ throw new Error('Warning: The option `stepSize` is expected in `useRanger`, but its value is `undefined`');
76
+ }
77
+ }
78
+ let nextVal = val + stepSize * direction;
79
+ if (nextVal >= min && nextVal <= max) {
80
+ return nextVal;
81
+ } else {
82
+ return val;
83
+ }
84
+ }
85
+ }, [max, min, stepSize, steps]);
86
+ const roundToStep = _react.default.useCallback(val => {
87
+ let left = min;
88
+ let right = max;
89
+ if (steps) {
90
+ steps.forEach(step => {
91
+ if (step <= val && step > left) {
92
+ left = step;
93
+ }
94
+ if (step >= val && step < right) {
95
+ right = step;
96
+ }
97
+ });
98
+ } else {
99
+ if (process.env.NODE_ENV !== 'production') {
100
+ if (typeof stepSize === 'undefined') {
101
+ throw new Error('Warning: The option `stepSize` is expected in `useRanger`, but its value is `undefined`');
102
+ }
103
+ }
104
+ while (left < val && left + stepSize < val) {
105
+ left += stepSize;
106
+ }
107
+ right = Math.min(left + stepSize, max);
108
+ }
109
+ if (val - left < right - val) {
110
+ return left;
111
+ }
112
+ return right;
113
+ }, [max, min, stepSize, steps]);
114
+ const handleDrag = _react.default.useCallback(e => {
115
+ const {
116
+ activeHandleIndex,
117
+ onDrag
118
+ } = getLatest();
119
+ const clientX = e.type === 'touchmove' ? e.changedTouches[0].clientX : e.clientX;
120
+ const newValue = getValueForClientX(clientX);
121
+ const newRoundedValue = roundToStep(newValue);
122
+ const newValues = [...values.slice(0, activeHandleIndex), newRoundedValue, ...values.slice(activeHandleIndex + 1)];
123
+ if (onDrag) {
124
+ onDrag(newValues);
125
+ } else {
126
+ setTempValues(newValues);
127
+ }
128
+ }, [getLatest, getValueForClientX, roundToStep, values]);
129
+ const handleKeyDown = _react.default.useCallback((e, i) => {
130
+ const {
131
+ values,
132
+ onChange = () => {}
133
+ } = getLatest();
134
+ // Left Arrow || Right Arrow
135
+ if (e.keyCode === 37 || e.keyCode === 39) {
136
+ setActiveHandleIndex(i);
137
+ const direction = e.keyCode === 37 ? -1 : 1;
138
+ const newValue = getNextStep(values[i], direction);
139
+ const newValues = [...values.slice(0, i), newValue, ...values.slice(i + 1)];
140
+ const sortedValues = sortNumList(newValues);
141
+ onChange(sortedValues);
142
+ }
143
+ }, [getLatest, getNextStep]);
144
+ const handlePress = _react.default.useCallback((e, i) => {
145
+ setActiveHandleIndex(i);
146
+ const handleRelease = e => {
147
+ const {
148
+ tempValues,
149
+ values,
150
+ onChange = () => {},
151
+ onDrag = () => {}
152
+ } = getLatest();
153
+ document.removeEventListener('mousemove', handleDrag);
154
+ document.removeEventListener('touchmove', handleDrag);
155
+ document.removeEventListener('mouseup', handleRelease);
156
+ document.removeEventListener('touchend', handleRelease);
157
+ const sortedValues = sortNumList(tempValues || values);
158
+ onChange(sortedValues);
159
+ onDrag(sortedValues);
160
+ setActiveHandleIndex(null);
161
+ setTempValues();
162
+ };
163
+ document.addEventListener('mousemove', handleDrag);
164
+ document.addEventListener('touchmove', handleDrag);
165
+ document.addEventListener('mouseup', handleRelease);
166
+ document.addEventListener('touchend', handleRelease);
167
+ }, [getLatest, handleDrag]);
168
+ const getPercentageForValue = _react.default.useCallback(val => interpolator.getPercentageForValue(val, min, max), [interpolator, max, min]);
169
+
170
+ // Build the ticks
171
+ const ticks = _react.default.useMemo(() => {
172
+ let ticks = controlledTicks || steps;
173
+ if (!ticks) {
174
+ ticks = [min];
175
+ while (ticks[ticks.length - 1] < max - tickSize) {
176
+ ticks.push(ticks[ticks.length - 1] + tickSize);
177
+ }
178
+ ticks.push(max);
179
+ }
180
+ return ticks.map((value, i) => ({
181
+ value,
182
+ getTickProps: function () {
183
+ let {
184
+ key = i,
185
+ style = {},
186
+ ...rest
187
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
188
+ return {
189
+ key,
190
+ style: {
191
+ position: 'absolute',
192
+ width: 0,
193
+ left: `${getPercentageForValue(value)}%`,
194
+ transform: `translateX(-50%)`,
195
+ ...style
196
+ },
197
+ ...rest
198
+ };
199
+ }
200
+ }));
201
+ }, [controlledTicks, getPercentageForValue, max, min, steps, tickSize]);
202
+ const segments = _react.default.useMemo(() => {
203
+ const sortedValues = sortNumList(tempValues || values);
204
+ return [...sortedValues, max].map((value, i) => ({
205
+ value,
206
+ getSegmentProps: function () {
207
+ let {
208
+ key = i,
209
+ style = {},
210
+ ...rest
211
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
212
+ const left = getPercentageForValue(sortedValues[i - 1] ? sortedValues[i - 1] : min);
213
+ const width = getPercentageForValue(value) - left;
214
+ return {
215
+ key,
216
+ style: {
217
+ position: 'absolute',
218
+ left: `${left}%`,
219
+ width: `${width}%`,
220
+ ...style
221
+ },
222
+ ...rest
223
+ };
224
+ }
225
+ }));
226
+ }, [getPercentageForValue, max, min, tempValues, values]);
227
+ const handles = _react.default.useMemo(() => (tempValues || values).map((value, i) => ({
228
+ value,
229
+ active: i === activeHandleIndex,
230
+ getHandleProps: function () {
231
+ let {
232
+ key = i,
233
+ ref,
234
+ innerRef = () => {},
235
+ onKeyDown,
236
+ onMouseDown,
237
+ onTouchStart,
238
+ style = {},
239
+ ...rest
240
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
241
+ return {
242
+ key,
243
+ onKeyDown: e => {
244
+ e.persist();
245
+ handleKeyDown(e, i);
246
+ if (onKeyDown) onKeyDown(e);
247
+ },
248
+ onMouseDown: e => {
249
+ e.persist();
250
+ handlePress(e, i);
251
+ if (onMouseDown) onMouseDown(e);
252
+ },
253
+ onTouchStart: e => {
254
+ e.persist();
255
+ handlePress(e, i);
256
+ if (onTouchStart) onTouchStart(e);
257
+ },
258
+ role: 'slider',
259
+ 'aria-valuemin': min,
260
+ 'aria-valuemax': max,
261
+ 'aria-valuenow': value,
262
+ style: {
263
+ position: 'absolute',
264
+ top: '50%',
265
+ left: `${getPercentageForValue(value)}%`,
266
+ zIndex: i === activeHandleIndex ? '1' : '0',
267
+ transform: 'translate(-50%, -50%)',
268
+ ...style
269
+ },
270
+ ...rest
271
+ };
272
+ }
273
+ })), [activeHandleIndex, getPercentageForValue, handleKeyDown, handlePress, min, max, tempValues, values]);
274
+ const getTrackProps = function () {
275
+ let {
276
+ style = {},
277
+ ref,
278
+ ...rest
279
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
280
+ return {
281
+ ref: el => {
282
+ trackElRef.current = el;
283
+ if (ref) {
284
+ if (typeof ref === 'function') {
285
+ ref(el);
286
+ } else {
287
+ ref.current = el;
288
+ }
289
+ }
290
+ },
291
+ style: {
292
+ position: 'relative',
293
+ userSelect: 'none',
294
+ ...style
295
+ },
296
+ ...rest
297
+ };
298
+ };
299
+ return {
300
+ activeHandleIndex,
301
+ getTrackProps,
302
+ ticks,
303
+ segments,
304
+ handles
305
+ };
306
+ }
@@ -0,0 +1,10 @@
1
+ import { Environment, RequestParameters, QueryResponseCache, Variables, GraphQLResponse } from 'relay-runtime';
2
+ export declare const networkFetch: (request: RequestParameters, variables: Variables) => Promise<GraphQLResponse>;
3
+ export declare const responseCache: QueryResponseCache | null;
4
+ interface CreateRelayEnvironmentOptions {
5
+ url?: string;
6
+ stripeIntegration?: 'payment-element' | 'card-element';
7
+ }
8
+ export declare function createEnvironment(options: CreateRelayEnvironmentOptions): Environment;
9
+ export declare function useCurrentEnvironment(options: CreateRelayEnvironmentOptions): Environment;
10
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createEnvironment = createEnvironment;
7
+ exports.responseCache = exports.networkFetch = void 0;
8
+ exports.useCurrentEnvironment = useCurrentEnvironment;
9
+ var _react = require("react");
10
+ var _relayRuntime = require("relay-runtime");
11
+ const IS_SERVER = typeof window === typeof undefined;
12
+ const FONTDUE_URL = process.env.NEXT_PUBLIC_FONTDUE_URL;
13
+ if (IS_SERVER && (FONTDUE_URL == null || FONTDUE_URL === '')) {
14
+ throw new Error('fontdue-js requires a Fontdue URL to be configured via environment variables on the server, please set a NEXT_PUBLIC_FONTDUE_URL');
15
+ }
16
+ const STRIPE_INTEGRATION = process.env.NEXT_PUBLIC_FONTDUE_STRIPE_INTEGRATION || 'payment-element';
17
+ const CACHE_TTL = 10 * 1000; // 10 seconds, to resolve preloaded results
18
+
19
+ function createNetworkFetch(options) {
20
+ return async function networkFetch(request, variables) {
21
+ const url = (FONTDUE_URL && `${FONTDUE_URL}/graphql`) ?? ((options === null || options === void 0 ? void 0 : options.url) ?? '') + '/graphql';
22
+ const resp = await fetch(url, {
23
+ method: 'POST',
24
+ credentials: 'include',
25
+ headers: {
26
+ Accept: 'application/json',
27
+ 'Content-Type': 'application/json',
28
+ 'fontdue-stripe-integration': (STRIPE_INTEGRATION ?? (options === null || options === void 0 ? void 0 : options.stripeIntegration)) || 'payment-element'
29
+ },
30
+ body: JSON.stringify({
31
+ query: request.text,
32
+ variables
33
+ })
34
+ });
35
+ const json = await resp.json();
36
+
37
+ // GraphQL returns exceptions (for example, a missing required variable) in the "errors"
38
+ // property of the response. If any exceptions occurred when processing the request,
39
+ // throw an error to indicate to the developer what went wrong.
40
+ if (Array.isArray(json.errors)) {
41
+ console.error(json.errors);
42
+ throw new Error(`Error fetching GraphQL query '${request.name}' with variables '${JSON.stringify(variables)}': ${JSON.stringify(json.errors)}`);
43
+ }
44
+ return json;
45
+ };
46
+ }
47
+ const networkFetch = createNetworkFetch();
48
+ exports.networkFetch = networkFetch;
49
+ const responseCache = IS_SERVER ? null : new _relayRuntime.QueryResponseCache({
50
+ size: 250,
51
+ ttl: CACHE_TTL
52
+ });
53
+ exports.responseCache = responseCache;
54
+ function createNetwork(options) {
55
+ async function fetchResponse(params, variables, cacheConfig) {
56
+ const isQuery = params.operationKind === 'query';
57
+ // @ts-ignore
58
+ const cacheKey = params.id ?? params.cacheID;
59
+ const forceFetch = cacheConfig && cacheConfig.force;
60
+ if (responseCache != null && isQuery && !forceFetch) {
61
+ const fromCache = responseCache.get(cacheKey, variables);
62
+ if (fromCache != null) {
63
+ return Promise.resolve(fromCache);
64
+ }
65
+ }
66
+ return createNetworkFetch(options)(params, variables);
67
+ }
68
+ const network = _relayRuntime.Network.create(fetchResponse);
69
+ return network;
70
+ }
71
+ function createEnvironment(options) {
72
+ return new _relayRuntime.Environment({
73
+ network: createNetwork(options),
74
+ store: new _relayRuntime.Store(_relayRuntime.RecordSource.create()),
75
+ isServer: IS_SERVER
76
+ });
77
+ }
78
+ function useCurrentEnvironment(options) {
79
+ if (IS_SERVER) {
80
+ return createEnvironment(options);
81
+ }
82
+ const environmentRef = (0, _react.useRef)(createEnvironment(options));
83
+ return environmentRef.current;
84
+ }
@@ -0,0 +1,7 @@
1
+ import { GraphQLResponse, GraphQLTaggedNode, OperationType, RequestParameters, VariablesOf } from 'relay-runtime';
2
+ export interface SerializablePreloadedQuery<TQuery extends OperationType> {
3
+ params: RequestParameters;
4
+ variables: VariablesOf<TQuery>;
5
+ response: GraphQLResponse;
6
+ }
7
+ export default function loadSerializableQuery<TQuery extends OperationType>(query: GraphQLTaggedNode, variables: VariablesOf<TQuery>): Promise<SerializablePreloadedQuery<TQuery>>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = loadSerializableQuery;
7
+ var _environment = require("./environment");
8
+ // Call into raw network fetch to get serializable GraphQL query response
9
+ // This response will be sent to the client to "warm" the QueryResponseCache
10
+ // to avoid the client fetches.
11
+ async function loadSerializableQuery(query, variables) {
12
+ if (!('params' in query)) throw new Error('Params not found in query, is it a fragment instead of a query?');
13
+ const response = await (0, _environment.networkFetch)(query.params, variables);
14
+ return {
15
+ params: query.params,
16
+ variables,
17
+ response
18
+ };
19
+ }
@@ -0,0 +1,4 @@
1
+ import { PreloadedQuery, PreloadFetchPolicy } from "react-relay";
2
+ import { OperationType } from "relay-runtime";
3
+ import { SerializablePreloadedQuery } from "./loadSerializableQuery";
4
+ export default function useSerializablePreloadedQuery<TQuery extends OperationType>(preloadQuery: SerializablePreloadedQuery<TQuery>, fetchPolicy?: PreloadFetchPolicy): PreloadedQuery<TQuery>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useSerializablePreloadedQuery;
7
+ var _react = require("react");
8
+ var _reactRelay = require("react-relay");
9
+ var _environment = require("./environment");
10
+ // Convert preloaded query object (with raw GraphQL Response) into
11
+ // Relay's PreloadedQuery.
12
+
13
+ // This hook convert serializable preloaded query
14
+ // into Relay's PreloadedQuery object.
15
+ // It is also writes this serializable preloaded query
16
+ // into QueryResponseCache, so we the network layer
17
+ // can use these cache results when fetching data
18
+ // in `usePreloadedQuery`.
19
+ function useSerializablePreloadedQuery(
20
+ //environment: IEnvironment,
21
+ preloadQuery) {
22
+ let fetchPolicy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "store-or-network";
23
+ (0, _react.useMemo)(() => {
24
+ writePreloadedQueryToCache(preloadQuery);
25
+ }, [preloadQuery]);
26
+ const environment = (0, _reactRelay.useRelayEnvironment)();
27
+ return {
28
+ environment,
29
+ fetchKey: preloadQuery.params.id ?? preloadQuery.params.cacheID,
30
+ fetchPolicy,
31
+ isDisposed: false,
32
+ name: preloadQuery.params.name,
33
+ kind: "PreloadedQuery",
34
+ variables: preloadQuery.variables,
35
+ dispose: () => {
36
+ return;
37
+ }
38
+ };
39
+ }
40
+ function writePreloadedQueryToCache(preloadedQueryObject) {
41
+ // @ts-ignore
42
+ const cacheKey = preloadedQueryObject.params.id ?? preloadedQueryObject.params.cacheID;
43
+ _environment.responseCache === null || _environment.responseCache === void 0 ? void 0 : _environment.responseCache.set(cacheKey, preloadedQueryObject.variables, preloadedQueryObject.response);
44
+ }
package/fontdue.css CHANGED
@@ -2654,5 +2654,3 @@ fontdue-newsletter-signup,
2654
2654
  fontdue-customer-login-form {
2655
2655
  font-size: 1rem;
2656
2656
  }
2657
-
2658
- /*# sourceMappingURL=fontdue.css.map */
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "fontdue-js",
3
- "version": "2.0.0-alpha6",
4
- "main": "index.js",
3
+ "version": "2.0.0-alpha7",
5
4
  "scripts": {
6
5
  "build": "npm run relay && run-p build-js build-css build-ts-declarations",
7
6
  "build-js": "babel src --out-dir dist --extensions .ts,.tsx,.js,.jsx",
8
7
  "build-ts-declarations": "tsc",
9
- "build-css": "sass --load-path=node_modules src/index.scss fontdue.css",
8
+ "build-css": "sass --load-path=node_modules --no-source-map src/index.scss dist/fontdue.css",
10
9
  "relay": "relay-compiler",
11
10
  "prepublishOnly": "npm run build"
12
11
  },
@@ -27,7 +26,6 @@
27
26
  "fast-deep-equal": "^2.0.1",
28
27
  "fontfaceobserver": "^2.0.13",
29
28
  "react-device-detect": "^2.2.3",
30
- "react-ranger": "^2.1.0",
31
29
  "react-redux": "^8",
32
30
  "react-relay": "^14.0.0",
33
31
  "react-select": "^5.0.0",
@@ -45,9 +43,8 @@
45
43
  "@babel/preset-typescript": "^7.18.0",
46
44
  "@types/draft-js": "^0.10.44",
47
45
  "@types/fontfaceobserver": "^2.1.0",
48
- "@types/react": "^18.0.0",
49
- "@types/react-dom": "^18.0.0",
50
- "@types/react-ranger": "^2.0.1",
46
+ "@types/react": "18.2.12",
47
+ "@types/react-dom": "18.2.4",
51
48
  "@types/react-relay": "^14.0.0",
52
49
  "@types/react-transition-group": "^4.4.4",
53
50
  "@types/relay-runtime": "^14.0.0",
@@ -60,7 +57,7 @@
60
57
  "react-dom": "^18.0.0",
61
58
  "relay-compiler": "^14.0.0",
62
59
  "sass": "^1.62",
63
- "typescript": "^5"
60
+ "typescript": "5.1.3"
64
61
  },
65
62
  "relay": {
66
63
  "src": "./src",
@@ -73,5 +70,43 @@
73
70
  },
74
71
  "resolutions": {
75
72
  "@types/react": "18.2.7"
73
+ },
74
+ "exports": {
75
+ "./fontdue.css": "./dist/fontdue.css",
76
+ "./BuyButton": {
77
+ "react-server": "./dist/components/BuyButton/index.server.js",
78
+ "default": "./dist/components/BuyButton/index.js"
79
+ },
80
+ "./CartButton": {
81
+ "react-server": "./dist/components/CartButton/index.server.js",
82
+ "default": "./dist/components/CartButton/index.js"
83
+ },
84
+ "./CharacterViewer": {
85
+ "react-server": "./dist/components/CharacterViewer/index.server.js",
86
+ "default": "./dist/components/CharacterViewer/index.js"
87
+ },
88
+ "./CustomerLoginForm": "./dist/components/CustomerLoginForm/index.js",
89
+ "./FontdueProvider": {
90
+ "react-server": "./dist/components/FontdueProvider/index.server.js",
91
+ "default": "./dist/components/FontdueProvider/index.js"
92
+ },
93
+ "./NewsletterSignup": {
94
+ "react-server": "./dist/components/NewsletterSignup/index.server.js",
95
+ "default": "./dist/components/NewsletterSignup/index.js"
96
+ },
97
+ "./StoreModal": "./dist/components/StoreModal/index.js",
98
+ "./TestFontsForm": {
99
+ "react-server": "./dist/components/TestFontsForm/index.server.js",
100
+ "default": "./dist/components/TestFontsForm/index.js"
101
+ },
102
+ "./TypeTester": {
103
+ "react-server": "./dist/components/TypeTester/TypeTesterStandalone.server.js",
104
+ "default": "./dist/components/TypeTester/TypeTesterStandalone.js"
105
+ },
106
+ "./TypeTesters": {
107
+ "react-server": "./dist/components/TypeTesters/index.server.js",
108
+ "default": "./dist/components/TypeTesters/index.js"
109
+ },
110
+ "./useFontStyle": "./dist/components/useFontStyle.js"
76
111
  }
77
112
  }
package/BuyButton.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import BuyButton from './dist/components/BuyButton';
2
- export * from './dist/components/BuyButton';
3
- export default BuyButton;
package/BuyButton.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/BuyButton');
package/CartButton.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import CartButton from './dist/components/CartButton';
2
- export * from './dist/components/CartButton';
3
- export default CartButton;
package/CartButton.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/CartButton');
@@ -1,3 +0,0 @@
1
- import CharacterViewer from './dist/components/CharacterViewer';
2
- export * from './dist/components/CharacterViewer';
3
- export default CharacterViewer;
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/CharacterViewer');
@@ -1,3 +0,0 @@
1
- import CustomerLoginForm from './dist/components/CustomerLoginForm';
2
- export * from './dist/components/CustomerLoginForm';
3
- export default CustomerLoginForm;
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/CustomerLoginForm');
@@ -1,3 +0,0 @@
1
- import FontdueProvider from './dist/components/FontdueProvider';
2
- export * from './dist/components/FontdueProvider';
3
- export default FontdueProvider;
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/FontdueProvider');
@@ -1,3 +0,0 @@
1
- import NewsletterSignup from './dist/components/NewsletterSignup';
2
- export * from './dist/components/NewsletterSignup';
3
- export default NewsletterSignup;
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/NewsletterSignup');
package/StoreModal.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import StoreModal from './dist/components/StoreModal';
2
- export * from './dist/components/StoreModal';
3
- export default StoreModal;
package/StoreModal.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/StoreModal');
@@ -1,3 +0,0 @@
1
- import TestFontsForm from './dist/components/TestFontsForm';
2
- export * from './dist/components/TestFontsForm';
3
- export default TestFontsForm;
package/TestFontsForm.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/TestFontsForm');
package/TypeTester.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import TypeTesterStandalone from './dist/components/TypeTester/TypeTesterStandalone';
2
- export * from './dist/components/TypeTester/TypeTesterStandalone';
3
- export default TypeTesterStandalone;
package/TypeTester.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/TypeTester/TypeTesterStandalone');
package/TypeTesters.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import TypeTesters from './dist/components/TypeTesters';
2
- export * from './dist/components/TypeTesters';
3
- export default TypeTesters;
package/TypeTesters.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/TypeTesters');
package/useFontStyle.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import useFontStyle from './dist/components/useFontStyle';
2
- export * from './dist/components/useFontStyle';
3
- export default useFontStyle;
package/useFontStyle.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/components/useFontStyle');