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