fontdue-js 3.2.6 → 3.3.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.
- package/CHANGELOG.md +20 -16
- package/dist/__generated__/CharacterViewerIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CharacterViewerIDQuery.graphql.js +33 -3
- package/dist/__generated__/CharacterViewerSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CharacterViewerSlugQuery.graphql.js +33 -3
- package/dist/__generated__/CharacterViewerStyleRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CharacterViewerStyleRefetchQuery.graphql.js +34 -4
- package/dist/__generated__/CharacterViewer_style.graphql.d.ts +2 -2
- package/dist/__generated__/CharacterViewer_style.graphql.js +6 -2
- package/dist/__generated__/FeatureTesterStandaloneQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FeatureTesterStandaloneQuery.graphql.js +15 -20
- package/dist/__generated__/FeatureTestersIdQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FeatureTestersIdQuery.graphql.js +15 -20
- package/dist/__generated__/FeatureTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FeatureTestersSlugQuery.graphql.js +15 -20
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.js +14 -20
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +14 -20
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.js +14 -20
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +17 -23
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +17 -23
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +17 -23
- package/dist/__generated__/useFeaturesData_fontStyle.graphql.d.ts +4 -4
- package/dist/__generated__/useFeaturesData_fontStyle.graphql.js +6 -6
- package/dist/__tests__/trackingRouteChanges.test.js +110 -0
- package/dist/components/CharacterViewer/index.js +17 -4
- package/dist/components/Tracking/index.js +10 -18
- package/dist/components/Tracking/routeChanges.d.ts +19 -0
- package/dist/components/Tracking/routeChanges.js +62 -0
- package/dist/components/TypeTester/useFeaturesData.d.ts +9 -9
- package/dist/components/TypeTester/useFeaturesData.js +13 -23
- package/dist/relay/environment.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<84ad14b9fc86076734fd76876c2b45f3>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
4
|
* @nogrep
|
|
5
5
|
*/
|
|
@@ -70,14 +70,14 @@ const node = function () {
|
|
|
70
70
|
"alias": null,
|
|
71
71
|
"args": null,
|
|
72
72
|
"kind": "ScalarField",
|
|
73
|
-
"name": "
|
|
73
|
+
"name": "name",
|
|
74
74
|
"storageKey": null
|
|
75
75
|
},
|
|
76
76
|
v12 = {
|
|
77
77
|
"alias": null,
|
|
78
78
|
"args": null,
|
|
79
79
|
"kind": "ScalarField",
|
|
80
|
-
"name": "
|
|
80
|
+
"name": "axis",
|
|
81
81
|
"storageKey": null
|
|
82
82
|
},
|
|
83
83
|
v13 = {
|
|
@@ -87,7 +87,7 @@ const node = function () {
|
|
|
87
87
|
"name": "value",
|
|
88
88
|
"storageKey": null
|
|
89
89
|
},
|
|
90
|
-
v14 = [
|
|
90
|
+
v14 = [v12 /*: any*/, v13 /*: any*/],
|
|
91
91
|
v15 = [v7 /*: any*/, v8 /*: any*/],
|
|
92
92
|
v16 = {
|
|
93
93
|
"alias": null,
|
|
@@ -163,7 +163,7 @@ const node = function () {
|
|
|
163
163
|
"kind": "LinkedField",
|
|
164
164
|
"name": "parent",
|
|
165
165
|
"plural": false,
|
|
166
|
-
"selections": [v10 /*: any*/,
|
|
166
|
+
"selections": [v10 /*: any*/, v11 /*: any*/, v19 /*: any*/, v20 /*: any*/, v21 /*: any*/, v22 /*: any*/],
|
|
167
167
|
"storageKey": null
|
|
168
168
|
};
|
|
169
169
|
return {
|
|
@@ -299,23 +299,17 @@ const node = function () {
|
|
|
299
299
|
}, {
|
|
300
300
|
"alias": null,
|
|
301
301
|
"args": null,
|
|
302
|
-
"concreteType": "
|
|
302
|
+
"concreteType": "FeatureName",
|
|
303
303
|
"kind": "LinkedField",
|
|
304
|
-
"name": "
|
|
304
|
+
"name": "featureNames",
|
|
305
305
|
"plural": true,
|
|
306
306
|
"selections": [{
|
|
307
307
|
"alias": null,
|
|
308
308
|
"args": null,
|
|
309
309
|
"kind": "ScalarField",
|
|
310
|
-
"name": "
|
|
311
|
-
"storageKey": null
|
|
312
|
-
}, {
|
|
313
|
-
"alias": null,
|
|
314
|
-
"args": null,
|
|
315
|
-
"kind": "ScalarField",
|
|
316
|
-
"name": "humanName",
|
|
310
|
+
"name": "tag",
|
|
317
311
|
"storageKey": null
|
|
318
|
-
}],
|
|
312
|
+
}, v11 /*: any*/],
|
|
319
313
|
"storageKey": null
|
|
320
314
|
}],
|
|
321
315
|
"storageKey": null
|
|
@@ -326,7 +320,7 @@ const node = function () {
|
|
|
326
320
|
"kind": "LinkedField",
|
|
327
321
|
"name": "variableAxes",
|
|
328
322
|
"plural": true,
|
|
329
|
-
"selections": [
|
|
323
|
+
"selections": [v12 /*: any*/, v11 /*: any*/, {
|
|
330
324
|
"alias": null,
|
|
331
325
|
"args": null,
|
|
332
326
|
"kind": "ScalarField",
|
|
@@ -340,7 +334,7 @@ const node = function () {
|
|
|
340
334
|
"storageKey": null
|
|
341
335
|
}],
|
|
342
336
|
"storageKey": null
|
|
343
|
-
},
|
|
337
|
+
}, v11 /*: any*/, {
|
|
344
338
|
"alias": null,
|
|
345
339
|
"args": null,
|
|
346
340
|
"kind": "ScalarField",
|
|
@@ -371,7 +365,7 @@ const node = function () {
|
|
|
371
365
|
"kind": "LinkedField",
|
|
372
366
|
"name": "variableInstances",
|
|
373
367
|
"plural": true,
|
|
374
|
-
"selections": [
|
|
368
|
+
"selections": [v11 /*: any*/, {
|
|
375
369
|
"alias": null,
|
|
376
370
|
"args": null,
|
|
377
371
|
"concreteType": "VariableSetting",
|
|
@@ -389,7 +383,7 @@ const node = function () {
|
|
|
389
383
|
"kind": "LinkedField",
|
|
390
384
|
"name": "family",
|
|
391
385
|
"plural": false,
|
|
392
|
-
"selections": [v10 /*: any*/,
|
|
386
|
+
"selections": [v10 /*: any*/, v11 /*: any*/],
|
|
393
387
|
"storageKey": null
|
|
394
388
|
}, {
|
|
395
389
|
"alias": null,
|
|
@@ -531,7 +525,7 @@ const node = function () {
|
|
|
531
525
|
"kind": "ScalarField",
|
|
532
526
|
"name": "typeTesterAxes",
|
|
533
527
|
"storageKey": null
|
|
534
|
-
},
|
|
528
|
+
}, v11 /*: any*/, v19 /*: any*/, v20 /*: any*/, v21 /*: any*/, v22 /*: any*/, v23 /*: any*/, {
|
|
535
529
|
"alias": "families",
|
|
536
530
|
"args": [{
|
|
537
531
|
"kind": "Literal",
|
|
@@ -542,7 +536,7 @@ const node = function () {
|
|
|
542
536
|
"kind": "LinkedField",
|
|
543
537
|
"name": "children",
|
|
544
538
|
"plural": true,
|
|
545
|
-
"selections": [v10 /*: any*/,
|
|
539
|
+
"selections": [v10 /*: any*/, v11 /*: any*/, v19 /*: any*/, v20 /*: any*/, v21 /*: any*/, v22 /*: any*/, v23 /*: any*/],
|
|
546
540
|
"storageKey": "children(collectionTypes:[\"FAMILY\"])"
|
|
547
541
|
}],
|
|
548
542
|
"type": "FontCollection",
|
|
@@ -552,12 +546,12 @@ const node = function () {
|
|
|
552
546
|
}]
|
|
553
547
|
},
|
|
554
548
|
"params": {
|
|
555
|
-
"cacheID": "
|
|
549
|
+
"cacheID": "975c51be87603cacc9ead6c58ca4944f",
|
|
556
550
|
"id": null,
|
|
557
551
|
"metadata": {},
|
|
558
552
|
"name": "TypeTestersRefetchQuery",
|
|
559
553
|
"operationKind": "query",
|
|
560
|
-
"text": "query TypeTestersRefetchQuery(\n $excludeTags: [String!] = null\n $licenseOptions: [LicenseOptionsSpec] = []\n $orderVariables: [OrderVariableSelectionInput!] = []\n $tags: [String!] = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...TypeTesters_collection_32it0Z\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n ...useFontStyle_fontStyle\n}\n\nfragment PriceBarSection_node_4sncub on FontCollection {\n id\n name\n collectionType\n sku {\n ...SelectButton_sku_4sncub\n id\n priceWithLicenseOptions: price(licenseOptions: $licenseOptions, orderVariables: $orderVariables) {\n ...Price_price\n }\n }\n totalStyles\n totalStylesPrice(licenseOptions: $licenseOptions) {\n ...Price_price\n }\n}\n\nfragment PriceBar_node_4sncub on FontCollection {\n ...PriceBarSection_node_4sncub\n parent {\n ...PriceBarSection_node_4sncub\n id\n }\n}\n\nfragment Price_price on Money {\n amount\n currency\n}\n\nfragment SKUPrice_sku_4sncub on Sku {\n id\n price(licenseOptions: $licenseOptions, orderVariables: $orderVariables) {\n amount\n ...Price_price\n }\n}\n\nfragment SelectButton_sku_4sncub on Sku {\n id\n ...SKUPrice_sku_4sncub\n}\n\nfragment TypeTesterFeaturesButton_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n}\n\nfragment TypeTesterFeatures_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n}\n\nfragment TypeTesterFloatingToolbar_testers on TypeTester {\n id\n fontStyle {\n ...TypeTesterToolbar_fontStyle\n ...TypeTesterFeatures_fontStyle\n id\n }\n}\n\nfragment TypeTesterStyleSelectData_fontStyle on FontStyle {\n id\n name\n supportedLanguages\n cssWeight\n cssStyle\n cssStretch\n variableInstances {\n name\n coordinates {\n axis\n value\n }\n }\n family {\n id\n name\n }\n}\n\nfragment TypeTesterToolbar_fontStyle on FontStyle {\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterFeaturesButton_fontStyle\n}\n\nfragment TypeTesterVariableAxes_fontStyle on FontStyle {\n variableAxes {\n axis\n name\n minValue\n maxValue\n }\n}\n\nfragment TypeTester_fontStyle_4sncub on FontStyle {\n id\n ...TypeTesterFeatures_fontStyle\n ...TypeTesterStyleSelectData_fontStyle\n ...FontStyle_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterToolbar_fontStyle\n sku {\n ...SelectButton_sku_4sncub\n ...SKUPrice_sku_4sncub\n id\n basePrice: price {\n amount\n }\n }\n}\n\nfragment TypeTesters_collection_32it0Z on FontCollection {\n typeTesters(first: 999, tags: $tags, excludeTags: $excludeTags) {\n edges {\n node {\n id\n content\n size\n lineHeight\n letterSpacing\n autofit\n direction\n alignment\n fontStyle {\n ...TypeTester_fontStyle_4sncub\n id\n family {\n id\n }\n }\n variableSettings {\n axis\n value\n }\n featureSettings {\n feature\n value\n }\n tags\n ...TypeTesterFloatingToolbar_testers\n }\n }\n }\n typeTesterFeatures\n typeTesterAxes\n id\n ...PriceBar_node_4sncub\n families: children(collectionTypes: [FAMILY]) {\n id\n ...PriceBar_node_4sncub\n }\n parent {\n id\n }\n}\n\nfragment useFeaturesData_fontStyle on FontStyle {\n fontFeatures {\n supportedFeatures\n
|
|
554
|
+
"text": "query TypeTestersRefetchQuery(\n $excludeTags: [String!] = null\n $licenseOptions: [LicenseOptionsSpec] = []\n $orderVariables: [OrderVariableSelectionInput!] = []\n $tags: [String!] = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...TypeTesters_collection_32it0Z\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n ...useFontStyle_fontStyle\n}\n\nfragment PriceBarSection_node_4sncub on FontCollection {\n id\n name\n collectionType\n sku {\n ...SelectButton_sku_4sncub\n id\n priceWithLicenseOptions: price(licenseOptions: $licenseOptions, orderVariables: $orderVariables) {\n ...Price_price\n }\n }\n totalStyles\n totalStylesPrice(licenseOptions: $licenseOptions) {\n ...Price_price\n }\n}\n\nfragment PriceBar_node_4sncub on FontCollection {\n ...PriceBarSection_node_4sncub\n parent {\n ...PriceBarSection_node_4sncub\n id\n }\n}\n\nfragment Price_price on Money {\n amount\n currency\n}\n\nfragment SKUPrice_sku_4sncub on Sku {\n id\n price(licenseOptions: $licenseOptions, orderVariables: $orderVariables) {\n amount\n ...Price_price\n }\n}\n\nfragment SelectButton_sku_4sncub on Sku {\n id\n ...SKUPrice_sku_4sncub\n}\n\nfragment TypeTesterFeaturesButton_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n}\n\nfragment TypeTesterFeatures_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n}\n\nfragment TypeTesterFloatingToolbar_testers on TypeTester {\n id\n fontStyle {\n ...TypeTesterToolbar_fontStyle\n ...TypeTesterFeatures_fontStyle\n id\n }\n}\n\nfragment TypeTesterStyleSelectData_fontStyle on FontStyle {\n id\n name\n supportedLanguages\n cssWeight\n cssStyle\n cssStretch\n variableInstances {\n name\n coordinates {\n axis\n value\n }\n }\n family {\n id\n name\n }\n}\n\nfragment TypeTesterToolbar_fontStyle on FontStyle {\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterFeaturesButton_fontStyle\n}\n\nfragment TypeTesterVariableAxes_fontStyle on FontStyle {\n variableAxes {\n axis\n name\n minValue\n maxValue\n }\n}\n\nfragment TypeTester_fontStyle_4sncub on FontStyle {\n id\n ...TypeTesterFeatures_fontStyle\n ...TypeTesterStyleSelectData_fontStyle\n ...FontStyle_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterToolbar_fontStyle\n sku {\n ...SelectButton_sku_4sncub\n ...SKUPrice_sku_4sncub\n id\n basePrice: price {\n amount\n }\n }\n}\n\nfragment TypeTesters_collection_32it0Z on FontCollection {\n typeTesters(first: 999, tags: $tags, excludeTags: $excludeTags) {\n edges {\n node {\n id\n content\n size\n lineHeight\n letterSpacing\n autofit\n direction\n alignment\n fontStyle {\n ...TypeTester_fontStyle_4sncub\n id\n family {\n id\n }\n }\n variableSettings {\n axis\n value\n }\n featureSettings {\n feature\n value\n }\n tags\n ...TypeTesterFloatingToolbar_testers\n }\n }\n }\n typeTesterFeatures\n typeTesterAxes\n id\n ...PriceBar_node_4sncub\n families: children(collectionTypes: [FAMILY]) {\n id\n ...PriceBar_node_4sncub\n }\n parent {\n id\n }\n}\n\nfragment useFeaturesData_fontStyle on FontStyle {\n fontFeatures {\n supportedFeatures\n featureNames {\n tag\n name\n }\n }\n}\n\nfragment useFontStyle_fontStyle on FontStyle {\n cssFamily\n name\n webfontSources {\n url\n format\n tech\n }\n verticalMetrics {\n unitsPerEm\n ascender\n descender\n lineGap\n avgCharWidth\n }\n}\n"
|
|
561
555
|
}
|
|
562
556
|
};
|
|
563
557
|
}();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<79778f811ed6f48a4c87a07cedd6da90>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
4
|
* @nogrep
|
|
5
5
|
*/
|
|
@@ -50,14 +50,14 @@ const node = function () {
|
|
|
50
50
|
"alias": null,
|
|
51
51
|
"args": null,
|
|
52
52
|
"kind": "ScalarField",
|
|
53
|
-
"name": "
|
|
53
|
+
"name": "name",
|
|
54
54
|
"storageKey": null
|
|
55
55
|
},
|
|
56
56
|
v8 = {
|
|
57
57
|
"alias": null,
|
|
58
58
|
"args": null,
|
|
59
59
|
"kind": "ScalarField",
|
|
60
|
-
"name": "
|
|
60
|
+
"name": "axis",
|
|
61
61
|
"storageKey": null
|
|
62
62
|
},
|
|
63
63
|
v9 = {
|
|
@@ -67,7 +67,7 @@ const node = function () {
|
|
|
67
67
|
"name": "value",
|
|
68
68
|
"storageKey": null
|
|
69
69
|
},
|
|
70
|
-
v10 = [
|
|
70
|
+
v10 = [v8 /*: any*/, v9 /*: any*/],
|
|
71
71
|
v11 = {
|
|
72
72
|
"kind": "Literal",
|
|
73
73
|
"name": "licenseOptions",
|
|
@@ -152,7 +152,7 @@ const node = function () {
|
|
|
152
152
|
"kind": "LinkedField",
|
|
153
153
|
"name": "parent",
|
|
154
154
|
"plural": false,
|
|
155
|
-
"selections": [v6 /*: any*/,
|
|
155
|
+
"selections": [v6 /*: any*/, v7 /*: any*/, v16 /*: any*/, v17 /*: any*/, v18 /*: any*/, v19 /*: any*/],
|
|
156
156
|
"storageKey": null
|
|
157
157
|
};
|
|
158
158
|
return {
|
|
@@ -312,23 +312,17 @@ const node = function () {
|
|
|
312
312
|
}, {
|
|
313
313
|
"alias": null,
|
|
314
314
|
"args": null,
|
|
315
|
-
"concreteType": "
|
|
315
|
+
"concreteType": "FeatureName",
|
|
316
316
|
"kind": "LinkedField",
|
|
317
|
-
"name": "
|
|
317
|
+
"name": "featureNames",
|
|
318
318
|
"plural": true,
|
|
319
319
|
"selections": [{
|
|
320
320
|
"alias": null,
|
|
321
321
|
"args": null,
|
|
322
322
|
"kind": "ScalarField",
|
|
323
|
-
"name": "
|
|
324
|
-
"storageKey": null
|
|
325
|
-
}, {
|
|
326
|
-
"alias": null,
|
|
327
|
-
"args": null,
|
|
328
|
-
"kind": "ScalarField",
|
|
329
|
-
"name": "humanName",
|
|
323
|
+
"name": "tag",
|
|
330
324
|
"storageKey": null
|
|
331
|
-
}],
|
|
325
|
+
}, v7 /*: any*/],
|
|
332
326
|
"storageKey": null
|
|
333
327
|
}],
|
|
334
328
|
"storageKey": null
|
|
@@ -339,7 +333,7 @@ const node = function () {
|
|
|
339
333
|
"kind": "LinkedField",
|
|
340
334
|
"name": "variableAxes",
|
|
341
335
|
"plural": true,
|
|
342
|
-
"selections": [
|
|
336
|
+
"selections": [v8 /*: any*/, v7 /*: any*/, {
|
|
343
337
|
"alias": null,
|
|
344
338
|
"args": null,
|
|
345
339
|
"kind": "ScalarField",
|
|
@@ -353,7 +347,7 @@ const node = function () {
|
|
|
353
347
|
"storageKey": null
|
|
354
348
|
}],
|
|
355
349
|
"storageKey": null
|
|
356
|
-
},
|
|
350
|
+
}, v7 /*: any*/, {
|
|
357
351
|
"alias": null,
|
|
358
352
|
"args": null,
|
|
359
353
|
"kind": "ScalarField",
|
|
@@ -384,7 +378,7 @@ const node = function () {
|
|
|
384
378
|
"kind": "LinkedField",
|
|
385
379
|
"name": "variableInstances",
|
|
386
380
|
"plural": true,
|
|
387
|
-
"selections": [
|
|
381
|
+
"selections": [v7 /*: any*/, {
|
|
388
382
|
"alias": null,
|
|
389
383
|
"args": null,
|
|
390
384
|
"concreteType": "VariableSetting",
|
|
@@ -402,7 +396,7 @@ const node = function () {
|
|
|
402
396
|
"kind": "LinkedField",
|
|
403
397
|
"name": "family",
|
|
404
398
|
"plural": false,
|
|
405
|
-
"selections": [v6 /*: any*/,
|
|
399
|
+
"selections": [v6 /*: any*/, v7 /*: any*/],
|
|
406
400
|
"storageKey": null
|
|
407
401
|
}, {
|
|
408
402
|
"alias": null,
|
|
@@ -544,7 +538,7 @@ const node = function () {
|
|
|
544
538
|
"kind": "ScalarField",
|
|
545
539
|
"name": "typeTesterAxes",
|
|
546
540
|
"storageKey": null
|
|
547
|
-
}, v6 /*: any*/,
|
|
541
|
+
}, v6 /*: any*/, v7 /*: any*/, v16 /*: any*/, v17 /*: any*/, v18 /*: any*/, v19 /*: any*/, v20 /*: any*/, {
|
|
548
542
|
"alias": "families",
|
|
549
543
|
"args": [{
|
|
550
544
|
"kind": "Literal",
|
|
@@ -555,7 +549,7 @@ const node = function () {
|
|
|
555
549
|
"kind": "LinkedField",
|
|
556
550
|
"name": "children",
|
|
557
551
|
"plural": true,
|
|
558
|
-
"selections": [v6 /*: any*/,
|
|
552
|
+
"selections": [v6 /*: any*/, v7 /*: any*/, v16 /*: any*/, v17 /*: any*/, v18 /*: any*/, v19 /*: any*/, v20 /*: any*/],
|
|
559
553
|
"storageKey": "children(collectionTypes:[\"FAMILY\"])"
|
|
560
554
|
}],
|
|
561
555
|
"storageKey": null
|
|
@@ -566,12 +560,12 @@ const node = function () {
|
|
|
566
560
|
}]
|
|
567
561
|
},
|
|
568
562
|
"params": {
|
|
569
|
-
"cacheID": "
|
|
563
|
+
"cacheID": "311b4870ba11a1df38cf98b202138e2f",
|
|
570
564
|
"id": null,
|
|
571
565
|
"metadata": {},
|
|
572
566
|
"name": "TypeTestersSlugQuery",
|
|
573
567
|
"operationKind": "query",
|
|
574
|
-
"text": "query TypeTestersSlugQuery(\n $collectionSlug: String!\n $tags: [String!]\n $excludeTags: [String!]\n) {\n viewer {\n slug(name: $collectionSlug) {\n collection: fontCollection {\n ...TypeTesters_collection_4Goyz5\n id\n }\n id\n }\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n ...useFontStyle_fontStyle\n}\n\nfragment PriceBarSection_node_3BtHDv on FontCollection {\n id\n name\n collectionType\n sku {\n ...SelectButton_sku_3BtHDv\n id\n priceWithLicenseOptions: price(licenseOptions: [], orderVariables: []) {\n ...Price_price\n }\n }\n totalStyles\n totalStylesPrice(licenseOptions: []) {\n ...Price_price\n }\n}\n\nfragment PriceBar_node_3BtHDv on FontCollection {\n ...PriceBarSection_node_3BtHDv\n parent {\n ...PriceBarSection_node_3BtHDv\n id\n }\n}\n\nfragment Price_price on Money {\n amount\n currency\n}\n\nfragment SKUPrice_sku_3BtHDv on Sku {\n id\n price(licenseOptions: [], orderVariables: []) {\n amount\n ...Price_price\n }\n}\n\nfragment SelectButton_sku_3BtHDv on Sku {\n id\n ...SKUPrice_sku_3BtHDv\n}\n\nfragment TypeTesterFeaturesButton_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n}\n\nfragment TypeTesterFeatures_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n}\n\nfragment TypeTesterFloatingToolbar_testers on TypeTester {\n id\n fontStyle {\n ...TypeTesterToolbar_fontStyle\n ...TypeTesterFeatures_fontStyle\n id\n }\n}\n\nfragment TypeTesterStyleSelectData_fontStyle on FontStyle {\n id\n name\n supportedLanguages\n cssWeight\n cssStyle\n cssStretch\n variableInstances {\n name\n coordinates {\n axis\n value\n }\n }\n family {\n id\n name\n }\n}\n\nfragment TypeTesterToolbar_fontStyle on FontStyle {\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterFeaturesButton_fontStyle\n}\n\nfragment TypeTesterVariableAxes_fontStyle on FontStyle {\n variableAxes {\n axis\n name\n minValue\n maxValue\n }\n}\n\nfragment TypeTester_fontStyle_3BtHDv on FontStyle {\n id\n ...TypeTesterFeatures_fontStyle\n ...TypeTesterStyleSelectData_fontStyle\n ...FontStyle_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterToolbar_fontStyle\n sku {\n ...SelectButton_sku_3BtHDv\n ...SKUPrice_sku_3BtHDv\n id\n basePrice: price {\n amount\n }\n }\n}\n\nfragment TypeTesters_collection_4Goyz5 on FontCollection {\n typeTesters(first: 999, tags: $tags, excludeTags: $excludeTags) {\n edges {\n node {\n id\n content\n size\n lineHeight\n letterSpacing\n autofit\n direction\n alignment\n fontStyle {\n ...TypeTester_fontStyle_3BtHDv\n id\n family {\n id\n }\n }\n variableSettings {\n axis\n value\n }\n featureSettings {\n feature\n value\n }\n tags\n ...TypeTesterFloatingToolbar_testers\n }\n }\n }\n typeTesterFeatures\n typeTesterAxes\n id\n ...PriceBar_node_3BtHDv\n families: children(collectionTypes: [FAMILY]) {\n id\n ...PriceBar_node_3BtHDv\n }\n parent {\n id\n }\n}\n\nfragment useFeaturesData_fontStyle on FontStyle {\n fontFeatures {\n supportedFeatures\n
|
|
568
|
+
"text": "query TypeTestersSlugQuery(\n $collectionSlug: String!\n $tags: [String!]\n $excludeTags: [String!]\n) {\n viewer {\n slug(name: $collectionSlug) {\n collection: fontCollection {\n ...TypeTesters_collection_4Goyz5\n id\n }\n id\n }\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n ...useFontStyle_fontStyle\n}\n\nfragment PriceBarSection_node_3BtHDv on FontCollection {\n id\n name\n collectionType\n sku {\n ...SelectButton_sku_3BtHDv\n id\n priceWithLicenseOptions: price(licenseOptions: [], orderVariables: []) {\n ...Price_price\n }\n }\n totalStyles\n totalStylesPrice(licenseOptions: []) {\n ...Price_price\n }\n}\n\nfragment PriceBar_node_3BtHDv on FontCollection {\n ...PriceBarSection_node_3BtHDv\n parent {\n ...PriceBarSection_node_3BtHDv\n id\n }\n}\n\nfragment Price_price on Money {\n amount\n currency\n}\n\nfragment SKUPrice_sku_3BtHDv on Sku {\n id\n price(licenseOptions: [], orderVariables: []) {\n amount\n ...Price_price\n }\n}\n\nfragment SelectButton_sku_3BtHDv on Sku {\n id\n ...SKUPrice_sku_3BtHDv\n}\n\nfragment TypeTesterFeaturesButton_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n}\n\nfragment TypeTesterFeatures_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n}\n\nfragment TypeTesterFloatingToolbar_testers on TypeTester {\n id\n fontStyle {\n ...TypeTesterToolbar_fontStyle\n ...TypeTesterFeatures_fontStyle\n id\n }\n}\n\nfragment TypeTesterStyleSelectData_fontStyle on FontStyle {\n id\n name\n supportedLanguages\n cssWeight\n cssStyle\n cssStretch\n variableInstances {\n name\n coordinates {\n axis\n value\n }\n }\n family {\n id\n name\n }\n}\n\nfragment TypeTesterToolbar_fontStyle on FontStyle {\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterFeaturesButton_fontStyle\n}\n\nfragment TypeTesterVariableAxes_fontStyle on FontStyle {\n variableAxes {\n axis\n name\n minValue\n maxValue\n }\n}\n\nfragment TypeTester_fontStyle_3BtHDv on FontStyle {\n id\n ...TypeTesterFeatures_fontStyle\n ...TypeTesterStyleSelectData_fontStyle\n ...FontStyle_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterToolbar_fontStyle\n sku {\n ...SelectButton_sku_3BtHDv\n ...SKUPrice_sku_3BtHDv\n id\n basePrice: price {\n amount\n }\n }\n}\n\nfragment TypeTesters_collection_4Goyz5 on FontCollection {\n typeTesters(first: 999, tags: $tags, excludeTags: $excludeTags) {\n edges {\n node {\n id\n content\n size\n lineHeight\n letterSpacing\n autofit\n direction\n alignment\n fontStyle {\n ...TypeTester_fontStyle_3BtHDv\n id\n family {\n id\n }\n }\n variableSettings {\n axis\n value\n }\n featureSettings {\n feature\n value\n }\n tags\n ...TypeTesterFloatingToolbar_testers\n }\n }\n }\n typeTesterFeatures\n typeTesterAxes\n id\n ...PriceBar_node_3BtHDv\n families: children(collectionTypes: [FAMILY]) {\n id\n ...PriceBar_node_3BtHDv\n }\n parent {\n id\n }\n}\n\nfragment useFeaturesData_fontStyle on FontStyle {\n fontFeatures {\n supportedFeatures\n featureNames {\n tag\n name\n }\n }\n}\n\nfragment useFontStyle_fontStyle on FontStyle {\n cssFamily\n name\n webfontSources {\n url\n format\n tech\n }\n verticalMetrics {\n unitsPerEm\n ascender\n descender\n lineGap\n avgCharWidth\n }\n}\n"
|
|
575
569
|
}
|
|
576
570
|
};
|
|
577
571
|
}();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<32ee5e91cb8ab1a1a26c1fd5fc534c8a>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
4
|
* @nogrep
|
|
5
5
|
*/
|
|
@@ -7,9 +7,9 @@ import { ReaderFragment } from 'relay-runtime';
|
|
|
7
7
|
import { FragmentRefs } from "relay-runtime";
|
|
8
8
|
export type useFeaturesData_fontStyle$data = {
|
|
9
9
|
readonly fontFeatures: {
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
10
|
+
readonly featureNames: ReadonlyArray<{
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly tag: string;
|
|
13
13
|
}>;
|
|
14
14
|
readonly supportedFeatures: ReadonlyArray<string>;
|
|
15
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<32ee5e91cb8ab1a1a26c1fd5fc534c8a>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
4
|
* @nogrep
|
|
5
5
|
*/
|
|
@@ -29,21 +29,21 @@ const node = {
|
|
|
29
29
|
}, {
|
|
30
30
|
"alias": null,
|
|
31
31
|
"args": null,
|
|
32
|
-
"concreteType": "
|
|
32
|
+
"concreteType": "FeatureName",
|
|
33
33
|
"kind": "LinkedField",
|
|
34
|
-
"name": "
|
|
34
|
+
"name": "featureNames",
|
|
35
35
|
"plural": true,
|
|
36
36
|
"selections": [{
|
|
37
37
|
"alias": null,
|
|
38
38
|
"args": null,
|
|
39
39
|
"kind": "ScalarField",
|
|
40
|
-
"name": "
|
|
40
|
+
"name": "tag",
|
|
41
41
|
"storageKey": null
|
|
42
42
|
}, {
|
|
43
43
|
"alias": null,
|
|
44
44
|
"args": null,
|
|
45
45
|
"kind": "ScalarField",
|
|
46
|
-
"name": "
|
|
46
|
+
"name": "name",
|
|
47
47
|
"storageKey": null
|
|
48
48
|
}],
|
|
49
49
|
"storageKey": null
|
|
@@ -53,5 +53,5 @@ const node = {
|
|
|
53
53
|
"type": "FontStyle",
|
|
54
54
|
"abstractKey": null
|
|
55
55
|
};
|
|
56
|
-
node.hash = "
|
|
56
|
+
node.hash = "6a05a092096a4a0c1dd10fc0610bbee2";
|
|
57
57
|
export default node;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { trackRouteChanges } from '../components/Tracking/routeChanges.js';
|
|
3
|
+
|
|
4
|
+
// `trackRouteChanges` wraps the History API, so these tests drive stand-in
|
|
5
|
+
// history/window objects rather than a DOM. `defer` runs the check
|
|
6
|
+
// synchronously so each call's effect can be asserted in order.
|
|
7
|
+
function setup() {
|
|
8
|
+
let startUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'https://foundry.test/fonts';
|
|
9
|
+
let url = startUrl;
|
|
10
|
+
const listeners = {};
|
|
11
|
+
const history = {
|
|
12
|
+
pushState: vi.fn(),
|
|
13
|
+
replaceState: vi.fn()
|
|
14
|
+
};
|
|
15
|
+
const windowLike = {
|
|
16
|
+
addEventListener: (type, listener) => {
|
|
17
|
+
(listeners[type] ||= []).push(listener);
|
|
18
|
+
},
|
|
19
|
+
removeEventListener: (type, listener) => {
|
|
20
|
+
listeners[type] = (listeners[type] || []).filter(l => l !== listener);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const onNavigate = vi.fn();
|
|
24
|
+
const cleanup = trackRouteChanges({
|
|
25
|
+
history,
|
|
26
|
+
window: windowLike,
|
|
27
|
+
currentUrl: () => url,
|
|
28
|
+
onNavigate,
|
|
29
|
+
defer: callback => {
|
|
30
|
+
callback();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
history,
|
|
35
|
+
onNavigate,
|
|
36
|
+
cleanup,
|
|
37
|
+
/** Navigate the way an SPA router does: change the URL, then tell history. */
|
|
38
|
+
navigate(to) {
|
|
39
|
+
url = to;
|
|
40
|
+
history.pushState({}, '', to);
|
|
41
|
+
},
|
|
42
|
+
/** Rewrite the current entry in place without moving, as LiveView does. */
|
|
43
|
+
rewriteState() {
|
|
44
|
+
history.replaceState({
|
|
45
|
+
scroll: 120
|
|
46
|
+
}, '', url);
|
|
47
|
+
},
|
|
48
|
+
popstate(to) {
|
|
49
|
+
url = to;
|
|
50
|
+
(listeners.popstate || []).forEach(listener => listener());
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
describe('trackRouteChanges', () => {
|
|
55
|
+
it('reports a page view when the URL changes', () => {
|
|
56
|
+
const t = setup();
|
|
57
|
+
t.navigate('https://foundry.test/fonts/tomka');
|
|
58
|
+
t.navigate('https://foundry.test/cart');
|
|
59
|
+
expect(t.onNavigate).toHaveBeenCalledTimes(2);
|
|
60
|
+
});
|
|
61
|
+
it('ignores a replaceState that leaves the URL alone', () => {
|
|
62
|
+
const t = setup();
|
|
63
|
+
|
|
64
|
+
// Phoenix LiveView saves the scroll offset like this after every scroll
|
|
65
|
+
// stop; before the URL check this billed a page view per scroll pause.
|
|
66
|
+
t.rewriteState();
|
|
67
|
+
t.rewriteState();
|
|
68
|
+
t.rewriteState();
|
|
69
|
+
expect(t.onNavigate).not.toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
it('still reports the navigation when a rewrite follows it', () => {
|
|
72
|
+
const t = setup();
|
|
73
|
+
|
|
74
|
+
// A LiveView redirect pushes the new URL and then immediately rewrites the
|
|
75
|
+
// entry to record how it was reached — one navigation, two history calls.
|
|
76
|
+
t.navigate('https://foundry.test/cart');
|
|
77
|
+
t.rewriteState();
|
|
78
|
+
expect(t.onNavigate).toHaveBeenCalledTimes(1);
|
|
79
|
+
});
|
|
80
|
+
it('counts a return to a previously visited URL', () => {
|
|
81
|
+
const t = setup('https://foundry.test/fonts');
|
|
82
|
+
t.navigate('https://foundry.test/cart');
|
|
83
|
+
t.navigate('https://foundry.test/fonts');
|
|
84
|
+
|
|
85
|
+
// Only the immediately preceding URL is deduplicated — going back to a page
|
|
86
|
+
// is a real second view of it.
|
|
87
|
+
expect(t.onNavigate).toHaveBeenCalledTimes(2);
|
|
88
|
+
});
|
|
89
|
+
it('reports back/forward navigation', () => {
|
|
90
|
+
const t = setup();
|
|
91
|
+
t.popstate('https://foundry.test/cart');
|
|
92
|
+
expect(t.onNavigate).toHaveBeenCalledTimes(1);
|
|
93
|
+
});
|
|
94
|
+
it('does not report the URL it started on', () => {
|
|
95
|
+
const t = setup();
|
|
96
|
+
|
|
97
|
+
// The entry page view is sent by the caller, so an immediate rewrite of the
|
|
98
|
+
// entry URL must not duplicate it.
|
|
99
|
+
t.rewriteState();
|
|
100
|
+
expect(t.onNavigate).not.toHaveBeenCalled();
|
|
101
|
+
});
|
|
102
|
+
it('restores the original history methods on cleanup', () => {
|
|
103
|
+
const t = setup();
|
|
104
|
+
const wrappedPush = t.history.pushState;
|
|
105
|
+
t.cleanup();
|
|
106
|
+
expect(t.history.pushState).not.toBe(wrappedPush);
|
|
107
|
+
t.navigate('https://foundry.test/cart');
|
|
108
|
+
expect(t.onNavigate).not.toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -18,6 +18,7 @@ import CharacterViewerIDQueryNode from '../../__generated__/CharacterViewerIDQue
|
|
|
18
18
|
import CharacterViewerSlugQueryNode from '../../__generated__/CharacterViewerSlugQuery.graphql.js';
|
|
19
19
|
import StyleSelect from './StyleSelect.js';
|
|
20
20
|
import Checkbox from '../Checkbox/index.js';
|
|
21
|
+
import useFeaturesData from '../TypeTester/useFeaturesData.js';
|
|
21
22
|
import CharacterViewerStyleRefetchQueryNode from '../../__generated__/CharacterViewerStyleRefetchQuery.graphql.js';
|
|
22
23
|
import { EnsureFontdueContext } from '../FontdueContextProvider/index.js';
|
|
23
24
|
import ConfigContext from '../ConfigContext.js';
|
|
@@ -66,7 +67,8 @@ function GlyphMeta(_ref) {
|
|
|
66
67
|
featuresChecked,
|
|
67
68
|
setFeaturesChecked,
|
|
68
69
|
getGlyphName,
|
|
69
|
-
getUnicodeName
|
|
70
|
+
getUnicodeName,
|
|
71
|
+
featureNames
|
|
70
72
|
} = _ref;
|
|
71
73
|
if (!glyph) return null;
|
|
72
74
|
const unicodeName = getUnicodeName(glyph);
|
|
@@ -75,7 +77,7 @@ function GlyphMeta(_ref) {
|
|
|
75
77
|
}, unicodeName)), /*#__PURE__*/React.createElement("span", null, "Unicode decimal"), /*#__PURE__*/React.createElement("span", null, glyph.string.split('').map(str => str.charCodeAt(0).toString(10)).join(', ')), /*#__PURE__*/React.createElement("span", null, "Unicode hex"), /*#__PURE__*/React.createElement("span", null, glyph.string.split('').map(str => str.charCodeAt(0).toString(16).padStart(4, '0')).join(', ')), glyph.features && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "OpenType feature", glyph.features.length > 1 ? 's' : ''), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
76
78
|
checked: featuresChecked,
|
|
77
79
|
onChange: e => setFeaturesChecked(e.target.checked)
|
|
78
|
-
}), glyph.features.join(', ')))));
|
|
80
|
+
}), glyph.features.map(feature => featureNames[feature] ? `${featureNames[feature]} (${feature})` : feature).join(', ')))));
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
// Glyph unicode names (~1.2 MB) are fetched lazily from the Fontdue CDN rather
|
|
@@ -129,7 +131,7 @@ function CharacterViewerComponent(_ref2) {
|
|
|
129
131
|
collection: collectionKey
|
|
130
132
|
} = _ref2;
|
|
131
133
|
const collection = useFragment((_CharacterViewer_collection.hash && _CharacterViewer_collection.hash !== "c2116c3c2c795e5306c3a2a0ecd60137" && console.error("The definition of 'CharacterViewer_collection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_collection), collectionKey);
|
|
132
|
-
const [fontStyle, refetchFontStyle] = useRefetchableFragment((_CharacterViewer_style.hash && _CharacterViewer_style.hash !== "
|
|
134
|
+
const [fontStyle, refetchFontStyle] = useRefetchableFragment((_CharacterViewer_style.hash && _CharacterViewer_style.hash !== "087471e544e0a6ed17f1b17cd0570e28" && console.error("The definition of 'CharacterViewer_style' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_style), collection.featureStyle);
|
|
133
135
|
let families = [];
|
|
134
136
|
if (collection.collectionType === 'family') families = [collection];
|
|
135
137
|
if (collection.collectionType === 'superfamily' && collection.children) families = collection.children;
|
|
@@ -152,6 +154,11 @@ function CharacterViewerComponent(_ref2) {
|
|
|
152
154
|
fetchPolicy: 'store-only'
|
|
153
155
|
});
|
|
154
156
|
setVariableSettings(value.variableSettings);
|
|
157
|
+
},
|
|
158
|
+
// Keep the current style rendered on a failed refetch; without this the
|
|
159
|
+
// error is swallowed and the style select just appears dead.
|
|
160
|
+
error: error => {
|
|
161
|
+
console.error('Fontdue: failed to load the selected font style', error);
|
|
155
162
|
}
|
|
156
163
|
});
|
|
157
164
|
};
|
|
@@ -160,6 +167,11 @@ function CharacterViewerComponent(_ref2) {
|
|
|
160
167
|
} = useFontStyle({
|
|
161
168
|
fontStyle: fontStyle
|
|
162
169
|
});
|
|
170
|
+
const {
|
|
171
|
+
featureNames
|
|
172
|
+
} = useFeaturesData({
|
|
173
|
+
fontStyle
|
|
174
|
+
});
|
|
163
175
|
if (variableSettings) {
|
|
164
176
|
style = {
|
|
165
177
|
...style,
|
|
@@ -337,7 +349,8 @@ function CharacterViewerComponent(_ref2) {
|
|
|
337
349
|
getGlyphName: getGlyphName,
|
|
338
350
|
getUnicodeName: getUnicodeName,
|
|
339
351
|
featuresChecked: featuresChecked,
|
|
340
|
-
setFeaturesChecked: setFeaturesChecked
|
|
352
|
+
setFeaturesChecked: setFeaturesChecked,
|
|
353
|
+
featureNames: featureNames
|
|
341
354
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
342
355
|
className: "character-viewer_blocks",
|
|
343
356
|
ref: blocksRef,
|
|
@@ -4,6 +4,7 @@ import { useContext, useEffect } from 'react';
|
|
|
4
4
|
import ConfigContext from '../ConfigContext.js';
|
|
5
5
|
import { useFontdueUrl } from '../UrlContext.js';
|
|
6
6
|
import { hasConsent, onConsent, setClientAnonymousId, setEntryAttribution } from '../ConsentBanner/consent.js';
|
|
7
|
+
import { trackRouteChanges } from './routeChanges.js';
|
|
7
8
|
function getCampaignDataFromUrl() {
|
|
8
9
|
const urlParams = new URLSearchParams(window.location.search);
|
|
9
10
|
const campaign = {};
|
|
@@ -155,26 +156,17 @@ const Tracking = () => {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
// Track client-side route changes
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
handleRouteChange();
|
|
167
|
-
};
|
|
168
|
-
history.replaceState = function () {
|
|
169
|
-
originalReplaceState(...arguments);
|
|
170
|
-
handleRouteChange();
|
|
171
|
-
};
|
|
172
|
-
window.addEventListener('popstate', handleRouteChange);
|
|
159
|
+
const untrackRouteChanges = trackRouteChanges({
|
|
160
|
+
history,
|
|
161
|
+
window,
|
|
162
|
+
currentUrl: () => window.location.href,
|
|
163
|
+
onNavigate: () => {
|
|
164
|
+
sendPageView(url);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
173
167
|
return () => {
|
|
174
168
|
var _consentCleanup;
|
|
175
|
-
|
|
176
|
-
history.replaceState = originalReplaceState;
|
|
177
|
-
window.removeEventListener('popstate', handleRouteChange);
|
|
169
|
+
untrackRouteChanges();
|
|
178
170
|
(_consentCleanup = consentCleanup) === null || _consentCleanup === void 0 ? void 0 : _consentCleanup();
|
|
179
171
|
};
|
|
180
172
|
}, []);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type HistoryLike = Pick<History, 'pushState' | 'replaceState'>;
|
|
2
|
+
type WindowLike = Pick<Window, 'addEventListener' | 'removeEventListener'>;
|
|
3
|
+
export type RouteChangeOptions = {
|
|
4
|
+
history: HistoryLike;
|
|
5
|
+
window: WindowLike;
|
|
6
|
+
/** The URL as it stands right now, e.g. `() => window.location.href`. */
|
|
7
|
+
currentUrl: () => string;
|
|
8
|
+
/** Called once per navigation to a URL different from the previous one. */
|
|
9
|
+
onNavigate: () => void;
|
|
10
|
+
/** Overridable so tests can run the check synchronously. */
|
|
11
|
+
defer?: (callback: () => void) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Wrap `pushState`/`replaceState` and call `onNavigate` when the URL changes.
|
|
15
|
+
*
|
|
16
|
+
* Returns a cleanup function that restores the original History methods.
|
|
17
|
+
*/
|
|
18
|
+
export declare function trackRouteChanges({ history, window: windowLike, currentUrl, onNavigate, defer, }: RouteChangeOptions): () => void;
|
|
19
|
+
export {};
|