expo-router 4.1.0-canary-20250221-ef26fed → 5.0.0-sdk-52-router-patches

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 (117) hide show
  1. package/build/ExpoRoot.d.ts.map +1 -1
  2. package/build/ExpoRoot.js +10 -2
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/fork/NavigationContainer.js.map +1 -1
  5. package/build/fork/getPathFromState-forks.d.ts.map +1 -1
  6. package/build/fork/getPathFromState-forks.js +0 -1
  7. package/build/fork/getPathFromState-forks.js.map +1 -1
  8. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  9. package/build/fork/getStateFromPath-forks.js +2 -1
  10. package/build/fork/getStateFromPath-forks.js.map +1 -1
  11. package/build/fork/getStateFromPath.d.ts.map +1 -1
  12. package/build/fork/getStateFromPath.js +4 -2
  13. package/build/fork/getStateFromPath.js.map +1 -1
  14. package/build/fork/native-stack/createNativeStackNavigator.d.ts +1 -1
  15. package/build/fork/native-stack/createNativeStackNavigator.d.ts.map +1 -1
  16. package/build/fork/native-stack/createNativeStackNavigator.js +1 -2
  17. package/build/fork/native-stack/createNativeStackNavigator.js.map +1 -1
  18. package/build/fork/useBackButton.d.ts +1 -1
  19. package/build/fork/useBackButton.d.ts.map +1 -1
  20. package/build/fork/useBackButton.js.map +1 -1
  21. package/build/fork/useDocumentTitle.d.ts +1 -1
  22. package/build/fork/useDocumentTitle.d.ts.map +1 -1
  23. package/build/fork/useDocumentTitle.js.map +1 -1
  24. package/build/fork/useLinking.d.ts +1 -1
  25. package/build/fork/useLinking.d.ts.map +1 -1
  26. package/build/fork/useLinking.js.map +1 -1
  27. package/build/getDevServer/index.native.d.ts.map +1 -1
  28. package/build/getDevServer/index.native.js +1 -1
  29. package/build/getDevServer/index.native.js.map +1 -1
  30. package/build/getLinkingConfig.d.ts +8 -2
  31. package/build/getLinkingConfig.d.ts.map +1 -1
  32. package/build/getLinkingConfig.js +10 -2
  33. package/build/getLinkingConfig.js.map +1 -1
  34. package/build/global-state/router-store.d.ts.map +1 -1
  35. package/build/global-state/router-store.js.map +1 -1
  36. package/build/global-state/routing.d.ts +7 -0
  37. package/build/global-state/routing.d.ts.map +1 -1
  38. package/build/global-state/routing.js +7 -25
  39. package/build/global-state/routing.js.map +1 -1
  40. package/build/head/ExpoHead.d.ts +1 -1
  41. package/build/head/ExpoHead.d.ts.map +1 -1
  42. package/build/head/ExpoHead.ios.d.ts.map +1 -1
  43. package/build/head/ExpoHead.ios.js +18 -3
  44. package/build/head/ExpoHead.ios.js.map +1 -1
  45. package/build/head/ExpoHead.js +3 -3
  46. package/build/head/ExpoHead.js.map +1 -1
  47. package/build/layouts/DrawerClient.d.ts +18 -40
  48. package/build/layouts/DrawerClient.d.ts.map +1 -1
  49. package/build/layouts/StackClient.d.ts +37 -43
  50. package/build/layouts/StackClient.d.ts.map +1 -1
  51. package/build/layouts/StackClient.js +176 -5
  52. package/build/layouts/StackClient.js.map +1 -1
  53. package/build/layouts/TabsClient.d.ts +18 -40
  54. package/build/layouts/TabsClient.d.ts.map +1 -1
  55. package/build/layouts/withLayoutContext.d.ts +2 -2
  56. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  57. package/build/layouts/withLayoutContext.js +8 -4
  58. package/build/layouts/withLayoutContext.js.map +1 -1
  59. package/build/link/Link.d.ts +1 -1
  60. package/build/link/Link.d.ts.map +1 -1
  61. package/build/link/Link.js +2 -1
  62. package/build/link/Link.js.map +1 -1
  63. package/build/link/useLinkHooks.d.ts +8 -0
  64. package/build/link/useLinkHooks.d.ts.map +1 -1
  65. package/build/link/useLinkHooks.js.map +1 -1
  66. package/build/rsc/router/client.js +1 -1
  67. package/build/rsc/router/client.js.map +1 -1
  68. package/build/rsc/router/host.d.ts +5 -5
  69. package/build/rsc/router/host.d.ts.map +1 -1
  70. package/build/rsc/router/host.js.map +1 -1
  71. package/build/testing-library/index.d.ts +1 -1
  72. package/build/testing-library/index.d.ts.map +1 -1
  73. package/build/testing-library/index.js.map +1 -1
  74. package/build/testing-library/mock-config.d.ts +7 -2
  75. package/build/testing-library/mock-config.d.ts.map +1 -1
  76. package/build/ui/TabContext.d.ts +29 -19
  77. package/build/ui/TabContext.d.ts.map +1 -1
  78. package/build/ui/TabRouter.d.ts +1 -0
  79. package/build/ui/TabRouter.d.ts.map +1 -1
  80. package/build/ui/Tabs.d.ts +39 -30
  81. package/build/ui/Tabs.d.ts.map +1 -1
  82. package/build/ui/Tabs.js +12 -2
  83. package/build/ui/Tabs.js.map +1 -1
  84. package/build/ui/common.d.ts.map +1 -1
  85. package/build/ui/common.js +6 -8
  86. package/build/ui/common.js.map +1 -1
  87. package/build/ui/useComponent.d.ts +1 -1
  88. package/build/ui/useComponent.d.ts.map +1 -1
  89. package/build/ui/useComponent.js.map +1 -1
  90. package/build/useNavigation.d.ts.map +1 -1
  91. package/build/useNavigation.js +3 -1
  92. package/build/useNavigation.js.map +1 -1
  93. package/build/useScreens.d.ts +6 -4
  94. package/build/useScreens.d.ts.map +1 -1
  95. package/build/useScreens.js +38 -47
  96. package/build/useScreens.js.map +1 -1
  97. package/build/views/Navigator.d.ts +3 -2
  98. package/build/views/Navigator.d.ts.map +1 -1
  99. package/build/views/Navigator.js +3 -2
  100. package/build/views/Navigator.js.map +1 -1
  101. package/build/views/Try.d.ts +1 -1
  102. package/package.json +19 -16
  103. package/vendor/react-helmet-async/LICENSE +201 -0
  104. package/vendor/react-helmet-async/README.md +205 -0
  105. package/vendor/react-helmet-async/lib/Dispatcher.d.ts +23 -0
  106. package/vendor/react-helmet-async/lib/HelmetData.d.ts +26 -0
  107. package/vendor/react-helmet-async/lib/Provider.d.ts +17 -0
  108. package/vendor/react-helmet-async/lib/client.d.ts +3 -0
  109. package/vendor/react-helmet-async/lib/constants.d.ts +58 -0
  110. package/vendor/react-helmet-async/lib/index.d.ts +38 -0
  111. package/vendor/react-helmet-async/lib/index.esm.js +798 -0
  112. package/vendor/react-helmet-async/lib/index.js +829 -0
  113. package/vendor/react-helmet-async/lib/server.d.ts +44 -0
  114. package/vendor/react-helmet-async/lib/types.d.ts +85 -0
  115. package/vendor/react-helmet-async/lib/utils.d.ts +33 -0
  116. package/vendor/react-helmet-async/package_original.json +49 -0
  117. package/vendor/react-helmet-async/vendor.md +3 -0
@@ -0,0 +1,798 @@
1
+ // src/index.tsx
2
+ import React3, { Component as Component3 } from "react";
3
+ import fastCompare from "react-fast-compare";
4
+ import invariant from "invariant";
5
+
6
+ // src/Provider.tsx
7
+ import React2, { Component } from "react";
8
+
9
+ // src/server.ts
10
+ import React from "react";
11
+
12
+ // src/constants.ts
13
+ var TAG_NAMES = /* @__PURE__ */ ((TAG_NAMES2) => {
14
+ TAG_NAMES2["BASE"] = "base";
15
+ TAG_NAMES2["BODY"] = "body";
16
+ TAG_NAMES2["HEAD"] = "head";
17
+ TAG_NAMES2["HTML"] = "html";
18
+ TAG_NAMES2["LINK"] = "link";
19
+ TAG_NAMES2["META"] = "meta";
20
+ TAG_NAMES2["NOSCRIPT"] = "noscript";
21
+ TAG_NAMES2["SCRIPT"] = "script";
22
+ TAG_NAMES2["STYLE"] = "style";
23
+ TAG_NAMES2["TITLE"] = "title";
24
+ TAG_NAMES2["FRAGMENT"] = "Symbol(react.fragment)";
25
+ return TAG_NAMES2;
26
+ })(TAG_NAMES || {});
27
+ var SEO_PRIORITY_TAGS = {
28
+ link: { rel: ["amphtml", "canonical", "alternate"] },
29
+ script: { type: ["application/ld+json"] },
30
+ meta: {
31
+ charset: "",
32
+ name: ["generator", "robots", "description"],
33
+ property: [
34
+ "og:type",
35
+ "og:title",
36
+ "og:url",
37
+ "og:image",
38
+ "og:image:alt",
39
+ "og:description",
40
+ "twitter:url",
41
+ "twitter:title",
42
+ "twitter:description",
43
+ "twitter:image",
44
+ "twitter:image:alt",
45
+ "twitter:card",
46
+ "twitter:site"
47
+ ]
48
+ }
49
+ };
50
+ var VALID_TAG_NAMES = Object.values(TAG_NAMES);
51
+ var REACT_TAG_MAP = {
52
+ accesskey: "accessKey",
53
+ charset: "charSet",
54
+ class: "className",
55
+ contenteditable: "contentEditable",
56
+ contextmenu: "contextMenu",
57
+ "http-equiv": "httpEquiv",
58
+ itemprop: "itemProp",
59
+ tabindex: "tabIndex"
60
+ };
61
+ var HTML_TAG_MAP = Object.entries(REACT_TAG_MAP).reduce(
62
+ (carry, [key, value]) => {
63
+ carry[value] = key;
64
+ return carry;
65
+ },
66
+ {}
67
+ );
68
+ var HELMET_ATTRIBUTE = "data-rh";
69
+
70
+ // src/utils.ts
71
+ var HELMET_PROPS = {
72
+ DEFAULT_TITLE: "defaultTitle",
73
+ DEFER: "defer",
74
+ ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
75
+ ON_CHANGE_CLIENT_STATE: "onChangeClientState",
76
+ TITLE_TEMPLATE: "titleTemplate",
77
+ PRIORITIZE_SEO_TAGS: "prioritizeSeoTags"
78
+ };
79
+ var getInnermostProperty = (propsList, property) => {
80
+ for (let i = propsList.length - 1; i >= 0; i -= 1) {
81
+ const props = propsList[i];
82
+ if (Object.prototype.hasOwnProperty.call(props, property)) {
83
+ return props[property];
84
+ }
85
+ }
86
+ return null;
87
+ };
88
+ var getTitleFromPropsList = (propsList) => {
89
+ let innermostTitle = getInnermostProperty(propsList, "title" /* TITLE */);
90
+ const innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
91
+ if (Array.isArray(innermostTitle)) {
92
+ innermostTitle = innermostTitle.join("");
93
+ }
94
+ if (innermostTemplate && innermostTitle) {
95
+ return innermostTemplate.replace(/%s/g, () => innermostTitle);
96
+ }
97
+ const innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
98
+ return innermostTitle || innermostDefaultTitle || void 0;
99
+ };
100
+ var getOnChangeClientState = (propsList) => getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || (() => {
101
+ });
102
+ var getAttributesFromPropsList = (tagType, propsList) => propsList.filter((props) => typeof props[tagType] !== "undefined").map((props) => props[tagType]).reduce((tagAttrs, current) => ({ ...tagAttrs, ...current }), {});
103
+ var getBaseTagFromPropsList = (primaryAttributes, propsList) => propsList.filter((props) => typeof props["base" /* BASE */] !== "undefined").map((props) => props["base" /* BASE */]).reverse().reduce((innermostBaseTag, tag) => {
104
+ if (!innermostBaseTag.length) {
105
+ const keys = Object.keys(tag);
106
+ for (let i = 0; i < keys.length; i += 1) {
107
+ const attributeKey = keys[i];
108
+ const lowerCaseAttributeKey = attributeKey.toLowerCase();
109
+ if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
110
+ return innermostBaseTag.concat(tag);
111
+ }
112
+ }
113
+ }
114
+ return innermostBaseTag;
115
+ }, []);
116
+ var warn = (msg) => console && typeof console.warn === "function" && console.warn(msg);
117
+ var getTagsFromPropsList = (tagName, primaryAttributes, propsList) => {
118
+ const approvedSeenTags = {};
119
+ return propsList.filter((props) => {
120
+ if (Array.isArray(props[tagName])) {
121
+ return true;
122
+ }
123
+ if (typeof props[tagName] !== "undefined") {
124
+ warn(
125
+ `Helmet: ${tagName} should be of type "Array". Instead found type "${typeof props[tagName]}"`
126
+ );
127
+ }
128
+ return false;
129
+ }).map((props) => props[tagName]).reverse().reduce((approvedTags, instanceTags) => {
130
+ const instanceSeenTags = {};
131
+ instanceTags.filter((tag) => {
132
+ let primaryAttributeKey;
133
+ const keys2 = Object.keys(tag);
134
+ for (let i = 0; i < keys2.length; i += 1) {
135
+ const attributeKey = keys2[i];
136
+ const lowerCaseAttributeKey = attributeKey.toLowerCase();
137
+ if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === "rel" /* REL */ && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === "rel" /* REL */ && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
138
+ primaryAttributeKey = lowerCaseAttributeKey;
139
+ }
140
+ if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === "innerHTML" /* INNER_HTML */ || attributeKey === "cssText" /* CSS_TEXT */ || attributeKey === "itemprop" /* ITEM_PROP */)) {
141
+ primaryAttributeKey = attributeKey;
142
+ }
143
+ }
144
+ if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
145
+ return false;
146
+ }
147
+ const value = tag[primaryAttributeKey].toLowerCase();
148
+ if (!approvedSeenTags[primaryAttributeKey]) {
149
+ approvedSeenTags[primaryAttributeKey] = {};
150
+ }
151
+ if (!instanceSeenTags[primaryAttributeKey]) {
152
+ instanceSeenTags[primaryAttributeKey] = {};
153
+ }
154
+ if (!approvedSeenTags[primaryAttributeKey][value]) {
155
+ instanceSeenTags[primaryAttributeKey][value] = true;
156
+ return true;
157
+ }
158
+ return false;
159
+ }).reverse().forEach((tag) => approvedTags.push(tag));
160
+ const keys = Object.keys(instanceSeenTags);
161
+ for (let i = 0; i < keys.length; i += 1) {
162
+ const attributeKey = keys[i];
163
+ const tagUnion = {
164
+ ...approvedSeenTags[attributeKey],
165
+ ...instanceSeenTags[attributeKey]
166
+ };
167
+ approvedSeenTags[attributeKey] = tagUnion;
168
+ }
169
+ return approvedTags;
170
+ }, []).reverse();
171
+ };
172
+ var getAnyTrueFromPropsList = (propsList, checkedTag) => {
173
+ if (Array.isArray(propsList) && propsList.length) {
174
+ for (let index = 0; index < propsList.length; index += 1) {
175
+ const prop = propsList[index];
176
+ if (prop[checkedTag]) {
177
+ return true;
178
+ }
179
+ }
180
+ }
181
+ return false;
182
+ };
183
+ var reducePropsToState = (propsList) => ({
184
+ baseTag: getBaseTagFromPropsList(["href" /* HREF */], propsList),
185
+ bodyAttributes: getAttributesFromPropsList("bodyAttributes" /* BODY */, propsList),
186
+ defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
187
+ encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
188
+ htmlAttributes: getAttributesFromPropsList("htmlAttributes" /* HTML */, propsList),
189
+ linkTags: getTagsFromPropsList(
190
+ "link" /* LINK */,
191
+ ["rel" /* REL */, "href" /* HREF */],
192
+ propsList
193
+ ),
194
+ metaTags: getTagsFromPropsList(
195
+ "meta" /* META */,
196
+ [
197
+ "name" /* NAME */,
198
+ "charset" /* CHARSET */,
199
+ "http-equiv" /* HTTPEQUIV */,
200
+ "property" /* PROPERTY */,
201
+ "itemprop" /* ITEM_PROP */
202
+ ],
203
+ propsList
204
+ ),
205
+ noscriptTags: getTagsFromPropsList("noscript" /* NOSCRIPT */, ["innerHTML" /* INNER_HTML */], propsList),
206
+ onChangeClientState: getOnChangeClientState(propsList),
207
+ scriptTags: getTagsFromPropsList(
208
+ "script" /* SCRIPT */,
209
+ ["src" /* SRC */, "innerHTML" /* INNER_HTML */],
210
+ propsList
211
+ ),
212
+ styleTags: getTagsFromPropsList("style" /* STYLE */, ["cssText" /* CSS_TEXT */], propsList),
213
+ title: getTitleFromPropsList(propsList),
214
+ titleAttributes: getAttributesFromPropsList("titleAttributes" /* TITLE */, propsList),
215
+ prioritizeSeoTags: getAnyTrueFromPropsList(propsList, HELMET_PROPS.PRIORITIZE_SEO_TAGS)
216
+ });
217
+ var flattenArray = (possibleArray) => Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
218
+ var checkIfPropsMatch = (props, toMatch) => {
219
+ const keys = Object.keys(props);
220
+ for (let i = 0; i < keys.length; i += 1) {
221
+ if (toMatch[keys[i]] && toMatch[keys[i]].includes(props[keys[i]])) {
222
+ return true;
223
+ }
224
+ }
225
+ return false;
226
+ };
227
+ var prioritizer = (elementsList, propsToMatch) => {
228
+ if (Array.isArray(elementsList)) {
229
+ return elementsList.reduce(
230
+ (acc, elementAttrs) => {
231
+ if (checkIfPropsMatch(elementAttrs, propsToMatch)) {
232
+ acc.priority.push(elementAttrs);
233
+ } else {
234
+ acc.default.push(elementAttrs);
235
+ }
236
+ return acc;
237
+ },
238
+ { priority: [], default: [] }
239
+ );
240
+ }
241
+ return { default: elementsList, priority: [] };
242
+ };
243
+ var without = (obj, key) => {
244
+ return {
245
+ ...obj,
246
+ [key]: void 0
247
+ };
248
+ };
249
+
250
+ // src/server.ts
251
+ var SELF_CLOSING_TAGS = ["noscript" /* NOSCRIPT */, "script" /* SCRIPT */, "style" /* STYLE */];
252
+ var encodeSpecialCharacters = (str, encode = true) => {
253
+ if (encode === false) {
254
+ return String(str);
255
+ }
256
+ return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
257
+ };
258
+ var generateElementAttributesAsString = (attributes) => Object.keys(attributes).reduce((str, key) => {
259
+ const attr = typeof attributes[key] !== "undefined" ? `${key}="${attributes[key]}"` : `${key}`;
260
+ return str ? `${str} ${attr}` : attr;
261
+ }, "");
262
+ var generateTitleAsString = (type, title, attributes, encode) => {
263
+ const attributeString = generateElementAttributesAsString(attributes);
264
+ const flattenedTitle = flattenArray(title);
265
+ return attributeString ? `<${type} ${HELMET_ATTRIBUTE}="true" ${attributeString}>${encodeSpecialCharacters(
266
+ flattenedTitle,
267
+ encode
268
+ )}</${type}>` : `<${type} ${HELMET_ATTRIBUTE}="true">${encodeSpecialCharacters(
269
+ flattenedTitle,
270
+ encode
271
+ )}</${type}>`;
272
+ };
273
+ var generateTagsAsString = (type, tags, encode = true) => tags.reduce((str, t) => {
274
+ const tag = t;
275
+ const attributeHtml = Object.keys(tag).filter(
276
+ (attribute) => !(attribute === "innerHTML" /* INNER_HTML */ || attribute === "cssText" /* CSS_TEXT */)
277
+ ).reduce((string, attribute) => {
278
+ const attr = typeof tag[attribute] === "undefined" ? attribute : `${attribute}="${encodeSpecialCharacters(tag[attribute], encode)}"`;
279
+ return string ? `${string} ${attr}` : attr;
280
+ }, "");
281
+ const tagContent = tag.innerHTML || tag.cssText || "";
282
+ const isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
283
+ return `${str}<${type} ${HELMET_ATTRIBUTE}="true" ${attributeHtml}${isSelfClosing ? `/>` : `>${tagContent}</${type}>`}`;
284
+ }, "");
285
+ var convertElementAttributesToReactProps = (attributes, initProps = {}) => Object.keys(attributes).reduce((obj, key) => {
286
+ const mapped = REACT_TAG_MAP[key];
287
+ obj[mapped || key] = attributes[key];
288
+ return obj;
289
+ }, initProps);
290
+ var generateTitleAsReactComponent = (_type, title, attributes) => {
291
+ const initProps = {
292
+ key: title,
293
+ [HELMET_ATTRIBUTE]: true
294
+ };
295
+ const props = convertElementAttributesToReactProps(attributes, initProps);
296
+ return [React.createElement("title" /* TITLE */, props, title)];
297
+ };
298
+ var generateTagsAsReactComponent = (type, tags) => tags.map((tag, i) => {
299
+ const mappedTag = {
300
+ key: i,
301
+ [HELMET_ATTRIBUTE]: true
302
+ };
303
+ Object.keys(tag).forEach((attribute) => {
304
+ const mapped = REACT_TAG_MAP[attribute];
305
+ const mappedAttribute = mapped || attribute;
306
+ if (mappedAttribute === "innerHTML" /* INNER_HTML */ || mappedAttribute === "cssText" /* CSS_TEXT */) {
307
+ const content = tag.innerHTML || tag.cssText;
308
+ mappedTag.dangerouslySetInnerHTML = { __html: content };
309
+ } else {
310
+ mappedTag[mappedAttribute] = tag[attribute];
311
+ }
312
+ });
313
+ return React.createElement(type, mappedTag);
314
+ });
315
+ var getMethodsForTag = (type, tags, encode = true) => {
316
+ switch (type) {
317
+ case "title" /* TITLE */:
318
+ return {
319
+ toComponent: () => generateTitleAsReactComponent(type, tags.title, tags.titleAttributes),
320
+ toString: () => generateTitleAsString(type, tags.title, tags.titleAttributes, encode)
321
+ };
322
+ case "bodyAttributes" /* BODY */:
323
+ case "htmlAttributes" /* HTML */:
324
+ return {
325
+ toComponent: () => convertElementAttributesToReactProps(tags),
326
+ toString: () => generateElementAttributesAsString(tags)
327
+ };
328
+ default:
329
+ return {
330
+ toComponent: () => generateTagsAsReactComponent(type, tags),
331
+ toString: () => generateTagsAsString(type, tags, encode)
332
+ };
333
+ }
334
+ };
335
+ var getPriorityMethods = ({ metaTags, linkTags, scriptTags, encode }) => {
336
+ const meta = prioritizer(metaTags, SEO_PRIORITY_TAGS.meta);
337
+ const link = prioritizer(linkTags, SEO_PRIORITY_TAGS.link);
338
+ const script = prioritizer(scriptTags, SEO_PRIORITY_TAGS.script);
339
+ const priorityMethods = {
340
+ toComponent: () => [
341
+ ...generateTagsAsReactComponent("meta" /* META */, meta.priority),
342
+ ...generateTagsAsReactComponent("link" /* LINK */, link.priority),
343
+ ...generateTagsAsReactComponent("script" /* SCRIPT */, script.priority)
344
+ ],
345
+ toString: () => (
346
+ // generate all the tags as strings and concatenate them
347
+ `${getMethodsForTag("meta" /* META */, meta.priority, encode)} ${getMethodsForTag(
348
+ "link" /* LINK */,
349
+ link.priority,
350
+ encode
351
+ )} ${getMethodsForTag("script" /* SCRIPT */, script.priority, encode)}`
352
+ )
353
+ };
354
+ return {
355
+ priorityMethods,
356
+ metaTags: meta.default,
357
+ linkTags: link.default,
358
+ scriptTags: script.default
359
+ };
360
+ };
361
+ var mapStateOnServer = (props) => {
362
+ const {
363
+ baseTag,
364
+ bodyAttributes,
365
+ encode = true,
366
+ htmlAttributes,
367
+ noscriptTags,
368
+ styleTags,
369
+ title = "",
370
+ titleAttributes,
371
+ prioritizeSeoTags
372
+ } = props;
373
+ let { linkTags, metaTags, scriptTags } = props;
374
+ let priorityMethods = {
375
+ toComponent: () => {
376
+ },
377
+ toString: () => ""
378
+ };
379
+ if (prioritizeSeoTags) {
380
+ ({ priorityMethods, linkTags, metaTags, scriptTags } = getPriorityMethods(props));
381
+ }
382
+ return {
383
+ priority: priorityMethods,
384
+ base: getMethodsForTag("base" /* BASE */, baseTag, encode),
385
+ bodyAttributes: getMethodsForTag("bodyAttributes" /* BODY */, bodyAttributes, encode),
386
+ htmlAttributes: getMethodsForTag("htmlAttributes" /* HTML */, htmlAttributes, encode),
387
+ link: getMethodsForTag("link" /* LINK */, linkTags, encode),
388
+ meta: getMethodsForTag("meta" /* META */, metaTags, encode),
389
+ noscript: getMethodsForTag("noscript" /* NOSCRIPT */, noscriptTags, encode),
390
+ script: getMethodsForTag("script" /* SCRIPT */, scriptTags, encode),
391
+ style: getMethodsForTag("style" /* STYLE */, styleTags, encode),
392
+ title: getMethodsForTag("title" /* TITLE */, { title, titleAttributes }, encode)
393
+ };
394
+ };
395
+ var server_default = mapStateOnServer;
396
+
397
+ // src/HelmetData.ts
398
+ var instances = [];
399
+ var isDocument = !!(typeof window !== "undefined" && window.document && window.document.createElement);
400
+ var HelmetData = class {
401
+ instances = [];
402
+ canUseDOM = isDocument;
403
+ context;
404
+ value = {
405
+ setHelmet: (serverState) => {
406
+ this.context.helmet = serverState;
407
+ },
408
+ helmetInstances: {
409
+ get: () => this.canUseDOM ? instances : this.instances,
410
+ add: (instance) => {
411
+ (this.canUseDOM ? instances : this.instances).push(instance);
412
+ },
413
+ remove: (instance) => {
414
+ const index = (this.canUseDOM ? instances : this.instances).indexOf(instance);
415
+ (this.canUseDOM ? instances : this.instances).splice(index, 1);
416
+ }
417
+ }
418
+ };
419
+ constructor(context, canUseDOM) {
420
+ this.context = context;
421
+ this.canUseDOM = canUseDOM || false;
422
+ if (!canUseDOM) {
423
+ context.helmet = server_default({
424
+ baseTag: [],
425
+ bodyAttributes: {},
426
+ encodeSpecialCharacters: true,
427
+ htmlAttributes: {},
428
+ linkTags: [],
429
+ metaTags: [],
430
+ noscriptTags: [],
431
+ scriptTags: [],
432
+ styleTags: [],
433
+ title: "",
434
+ titleAttributes: {}
435
+ });
436
+ }
437
+ }
438
+ };
439
+
440
+ // src/Provider.tsx
441
+ var defaultValue = {};
442
+ var Context = React2.createContext(defaultValue);
443
+ var HelmetProvider = class _HelmetProvider extends Component {
444
+ static canUseDOM = isDocument;
445
+ helmetData;
446
+ constructor(props) {
447
+ super(props);
448
+ this.helmetData = new HelmetData(this.props.context || {}, _HelmetProvider.canUseDOM);
449
+ }
450
+ render() {
451
+ return /* @__PURE__ */ React2.createElement(Context.Provider, { value: this.helmetData.value }, this.props.children);
452
+ }
453
+ };
454
+
455
+ // src/Dispatcher.tsx
456
+ import { Component as Component2 } from "react";
457
+ import shallowEqual from "shallowequal";
458
+
459
+ // src/client.ts
460
+ var updateTags = (type, tags) => {
461
+ const headElement = document.head || document.querySelector("head" /* HEAD */);
462
+ const tagNodes = headElement.querySelectorAll(`${type}[${HELMET_ATTRIBUTE}]`);
463
+ const oldTags = [].slice.call(tagNodes);
464
+ const newTags = [];
465
+ let indexToDelete;
466
+ if (tags && tags.length) {
467
+ tags.forEach((tag) => {
468
+ const newElement = document.createElement(type);
469
+ for (const attribute in tag) {
470
+ if (Object.prototype.hasOwnProperty.call(tag, attribute)) {
471
+ if (attribute === "innerHTML" /* INNER_HTML */) {
472
+ newElement.innerHTML = tag.innerHTML;
473
+ } else if (attribute === "cssText" /* CSS_TEXT */) {
474
+ if (newElement.styleSheet) {
475
+ newElement.styleSheet.cssText = tag.cssText;
476
+ } else {
477
+ newElement.appendChild(document.createTextNode(tag.cssText));
478
+ }
479
+ } else {
480
+ const attr = attribute;
481
+ const value = typeof tag[attr] === "undefined" ? "" : tag[attr];
482
+ newElement.setAttribute(attribute, value);
483
+ }
484
+ }
485
+ }
486
+ newElement.setAttribute(HELMET_ATTRIBUTE, "true");
487
+ if (oldTags.some((existingTag, index) => {
488
+ indexToDelete = index;
489
+ return newElement.isEqualNode(existingTag);
490
+ })) {
491
+ oldTags.splice(indexToDelete, 1);
492
+ } else {
493
+ newTags.push(newElement);
494
+ }
495
+ });
496
+ }
497
+ oldTags.forEach((tag) => tag.parentNode?.removeChild(tag));
498
+ newTags.forEach((tag) => headElement.appendChild(tag));
499
+ return {
500
+ oldTags,
501
+ newTags
502
+ };
503
+ };
504
+ var updateAttributes = (tagName, attributes) => {
505
+ const elementTag = document.getElementsByTagName(tagName)[0];
506
+ if (!elementTag) {
507
+ return;
508
+ }
509
+ const helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
510
+ const helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
511
+ const attributesToRemove = [...helmetAttributes];
512
+ const attributeKeys = Object.keys(attributes);
513
+ for (const attribute of attributeKeys) {
514
+ const value = attributes[attribute] || "";
515
+ if (elementTag.getAttribute(attribute) !== value) {
516
+ elementTag.setAttribute(attribute, value);
517
+ }
518
+ if (helmetAttributes.indexOf(attribute) === -1) {
519
+ helmetAttributes.push(attribute);
520
+ }
521
+ const indexToSave = attributesToRemove.indexOf(attribute);
522
+ if (indexToSave !== -1) {
523
+ attributesToRemove.splice(indexToSave, 1);
524
+ }
525
+ }
526
+ for (let i = attributesToRemove.length - 1; i >= 0; i -= 1) {
527
+ elementTag.removeAttribute(attributesToRemove[i]);
528
+ }
529
+ if (helmetAttributes.length === attributesToRemove.length) {
530
+ elementTag.removeAttribute(HELMET_ATTRIBUTE);
531
+ } else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
532
+ elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
533
+ }
534
+ };
535
+ var updateTitle = (title, attributes) => {
536
+ if (typeof title !== "undefined" && document.title !== title) {
537
+ document.title = flattenArray(title);
538
+ }
539
+ updateAttributes("title" /* TITLE */, attributes);
540
+ };
541
+ var commitTagChanges = (newState, cb) => {
542
+ const {
543
+ baseTag,
544
+ bodyAttributes,
545
+ htmlAttributes,
546
+ linkTags,
547
+ metaTags,
548
+ noscriptTags,
549
+ onChangeClientState,
550
+ scriptTags,
551
+ styleTags,
552
+ title,
553
+ titleAttributes
554
+ } = newState;
555
+ updateAttributes("body" /* BODY */, bodyAttributes);
556
+ updateAttributes("html" /* HTML */, htmlAttributes);
557
+ updateTitle(title, titleAttributes);
558
+ const tagUpdates = {
559
+ baseTag: updateTags("base" /* BASE */, baseTag),
560
+ linkTags: updateTags("link" /* LINK */, linkTags),
561
+ metaTags: updateTags("meta" /* META */, metaTags),
562
+ noscriptTags: updateTags("noscript" /* NOSCRIPT */, noscriptTags),
563
+ scriptTags: updateTags("script" /* SCRIPT */, scriptTags),
564
+ styleTags: updateTags("style" /* STYLE */, styleTags)
565
+ };
566
+ const addedTags = {};
567
+ const removedTags = {};
568
+ Object.keys(tagUpdates).forEach((tagType) => {
569
+ const { newTags, oldTags } = tagUpdates[tagType];
570
+ if (newTags.length) {
571
+ addedTags[tagType] = newTags;
572
+ }
573
+ if (oldTags.length) {
574
+ removedTags[tagType] = tagUpdates[tagType].oldTags;
575
+ }
576
+ });
577
+ if (cb) {
578
+ cb();
579
+ }
580
+ onChangeClientState(newState, addedTags, removedTags);
581
+ };
582
+ var _helmetCallback = null;
583
+ var handleStateChangeOnClient = (newState) => {
584
+ if (_helmetCallback) {
585
+ cancelAnimationFrame(_helmetCallback);
586
+ }
587
+ if (newState.defer) {
588
+ _helmetCallback = requestAnimationFrame(() => {
589
+ commitTagChanges(newState, () => {
590
+ _helmetCallback = null;
591
+ });
592
+ });
593
+ } else {
594
+ commitTagChanges(newState);
595
+ _helmetCallback = null;
596
+ }
597
+ };
598
+ var client_default = handleStateChangeOnClient;
599
+
600
+ // src/Dispatcher.tsx
601
+ var HelmetDispatcher = class extends Component2 {
602
+ rendered = false;
603
+ shouldComponentUpdate(nextProps) {
604
+ return !shallowEqual(nextProps, this.props);
605
+ }
606
+ componentDidUpdate() {
607
+ this.emitChange();
608
+ }
609
+ componentWillUnmount() {
610
+ const { helmetInstances } = this.props.context;
611
+ helmetInstances.remove(this);
612
+ this.emitChange();
613
+ }
614
+ emitChange() {
615
+ const { helmetInstances, setHelmet } = this.props.context;
616
+ let serverState = null;
617
+ const state = reducePropsToState(
618
+ helmetInstances.get().map((instance) => {
619
+ const props = { ...instance.props };
620
+ delete props.context;
621
+ return props;
622
+ })
623
+ );
624
+ if (HelmetProvider.canUseDOM) {
625
+ client_default(state);
626
+ } else if (server_default) {
627
+ serverState = server_default(state);
628
+ }
629
+ setHelmet(serverState);
630
+ }
631
+ // componentWillMount will be deprecated
632
+ // for SSR, initialize on first render
633
+ // constructor is also unsafe in StrictMode
634
+ init() {
635
+ if (this.rendered) {
636
+ return;
637
+ }
638
+ this.rendered = true;
639
+ const { helmetInstances } = this.props.context;
640
+ helmetInstances.add(this);
641
+ this.emitChange();
642
+ }
643
+ render() {
644
+ this.init();
645
+ return null;
646
+ }
647
+ };
648
+
649
+ // src/index.tsx
650
+ var Helmet = class extends Component3 {
651
+ static defaultProps = {
652
+ defer: true,
653
+ encodeSpecialCharacters: true,
654
+ prioritizeSeoTags: false
655
+ };
656
+ shouldComponentUpdate(nextProps) {
657
+ return !fastCompare(without(this.props, "helmetData"), without(nextProps, "helmetData"));
658
+ }
659
+ mapNestedChildrenToProps(child, nestedChildren) {
660
+ if (!nestedChildren) {
661
+ return null;
662
+ }
663
+ switch (child.type) {
664
+ case "script" /* SCRIPT */:
665
+ case "noscript" /* NOSCRIPT */:
666
+ return {
667
+ innerHTML: nestedChildren
668
+ };
669
+ case "style" /* STYLE */:
670
+ return {
671
+ cssText: nestedChildren
672
+ };
673
+ default:
674
+ throw new Error(
675
+ `<${child.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`
676
+ );
677
+ }
678
+ }
679
+ flattenArrayTypeChildren(child, arrayTypeChildren, newChildProps, nestedChildren) {
680
+ return {
681
+ ...arrayTypeChildren,
682
+ [child.type]: [
683
+ ...arrayTypeChildren[child.type] || [],
684
+ {
685
+ ...newChildProps,
686
+ ...this.mapNestedChildrenToProps(child, nestedChildren)
687
+ }
688
+ ]
689
+ };
690
+ }
691
+ mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren) {
692
+ switch (child.type) {
693
+ case "title" /* TITLE */:
694
+ return {
695
+ ...newProps,
696
+ [child.type]: nestedChildren,
697
+ titleAttributes: { ...newChildProps }
698
+ };
699
+ case "body" /* BODY */:
700
+ return {
701
+ ...newProps,
702
+ bodyAttributes: { ...newChildProps }
703
+ };
704
+ case "html" /* HTML */:
705
+ return {
706
+ ...newProps,
707
+ htmlAttributes: { ...newChildProps }
708
+ };
709
+ default:
710
+ return {
711
+ ...newProps,
712
+ [child.type]: { ...newChildProps }
713
+ };
714
+ }
715
+ }
716
+ mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
717
+ let newFlattenedProps = { ...newProps };
718
+ Object.keys(arrayTypeChildren).forEach((arrayChildName) => {
719
+ newFlattenedProps = {
720
+ ...newFlattenedProps,
721
+ [arrayChildName]: arrayTypeChildren[arrayChildName]
722
+ };
723
+ });
724
+ return newFlattenedProps;
725
+ }
726
+ warnOnInvalidChildren(child, nestedChildren) {
727
+ invariant(
728
+ VALID_TAG_NAMES.some((name) => child.type === name),
729
+ typeof child.type === "function" ? `You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.` : `Only elements types ${VALID_TAG_NAMES.join(
730
+ ", "
731
+ )} are allowed. Helmet does not support rendering <${child.type}> elements. Refer to our API for more information.`
732
+ );
733
+ invariant(
734
+ !nestedChildren || typeof nestedChildren === "string" || Array.isArray(nestedChildren) && !nestedChildren.some((nestedChild) => typeof nestedChild !== "string"),
735
+ `Helmet expects a string as a child of <${child.type}>. Did you forget to wrap your children in braces? ( <${child.type}>{\`\`}</${child.type}> ) Refer to our API for more information.`
736
+ );
737
+ return true;
738
+ }
739
+ mapChildrenToProps(children, newProps) {
740
+ let arrayTypeChildren = {};
741
+ React3.Children.forEach(children, (child) => {
742
+ if (!child || !child.props) {
743
+ return;
744
+ }
745
+ const { children: nestedChildren, ...childProps } = child.props;
746
+ const newChildProps = Object.keys(childProps).reduce((obj, key) => {
747
+ obj[HTML_TAG_MAP[key] || key] = childProps[key];
748
+ return obj;
749
+ }, {});
750
+ let { type } = child;
751
+ if (typeof type === "symbol") {
752
+ type = type.toString();
753
+ } else {
754
+ this.warnOnInvalidChildren(child, nestedChildren);
755
+ }
756
+ switch (type) {
757
+ case "Symbol(react.fragment)" /* FRAGMENT */:
758
+ newProps = this.mapChildrenToProps(nestedChildren, newProps);
759
+ break;
760
+ case "link" /* LINK */:
761
+ case "meta" /* META */:
762
+ case "noscript" /* NOSCRIPT */:
763
+ case "script" /* SCRIPT */:
764
+ case "style" /* STYLE */:
765
+ arrayTypeChildren = this.flattenArrayTypeChildren(
766
+ child,
767
+ arrayTypeChildren,
768
+ newChildProps,
769
+ nestedChildren
770
+ );
771
+ break;
772
+ default:
773
+ newProps = this.mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren);
774
+ break;
775
+ }
776
+ });
777
+ return this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
778
+ }
779
+ render() {
780
+ const { children, ...props } = this.props;
781
+ let newProps = { ...props };
782
+ let { helmetData } = props;
783
+ if (children) {
784
+ newProps = this.mapChildrenToProps(children, newProps);
785
+ }
786
+ if (helmetData && !(helmetData instanceof HelmetData)) {
787
+ const data = helmetData;
788
+ helmetData = new HelmetData(data.context, true);
789
+ delete newProps.helmetData;
790
+ }
791
+ return helmetData ? /* @__PURE__ */ React3.createElement(HelmetDispatcher, { ...newProps, context: helmetData.value }) : /* @__PURE__ */ React3.createElement(Context.Consumer, null, (context) => /* @__PURE__ */ React3.createElement(HelmetDispatcher, { ...newProps, context }));
792
+ }
793
+ };
794
+ export {
795
+ Helmet,
796
+ HelmetData,
797
+ HelmetProvider
798
+ };