octane 0.1.37 → 0.1.38

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.
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var form_diagnostics_exports = {};
20
+ __export(form_diagnostics_exports, {
21
+ formAuthoringDiagnostics: () => formAuthoringDiagnostics
22
+ });
23
+ module.exports = __toCommonJS(form_diagnostics_exports);
24
+ function formAuthoringDiagnostics(tag, props, children) {
25
+ const diagnostics = [];
26
+ if (tag === "input" || tag === "textarea" || tag === "select") {
27
+ if (props.value !== void 0 && props.defaultValue !== void 0) {
28
+ diagnostics.push({
29
+ kind: "value-default",
30
+ message: `A <${tag}> has both \`value\` and \`defaultValue\` props. A form field must be either controlled or uncontrolled; remove one of these props.`
31
+ });
32
+ }
33
+ if (tag === "input" && props.checked !== void 0 && props.defaultChecked !== void 0) {
34
+ diagnostics.push({
35
+ kind: "checked-default",
36
+ message: "A <input> has both `checked` and `defaultChecked` props. A form field must be either controlled or uncontrolled; remove one of these props."
37
+ });
38
+ }
39
+ }
40
+ if (tag === "textarea" && children != null && props.value == null) {
41
+ diagnostics.push({
42
+ kind: "textarea-children",
43
+ message: "Use `defaultValue` or `value` instead of children on <textarea>."
44
+ });
45
+ }
46
+ if (tag === "option") {
47
+ if (props.selected != null) {
48
+ diagnostics.push({
49
+ kind: "option-selected",
50
+ message: "Use `value` or `defaultValue` on <select> instead of `selected` on <option>."
51
+ });
52
+ }
53
+ if (props.value == null && children !== void 0 && typeof children === "object" && children !== null) {
54
+ diagnostics.push({
55
+ kind: "option-children",
56
+ message: "Cannot infer an <option> value from complex children. Pass an explicit `value` prop or use plain text children."
57
+ });
58
+ }
59
+ }
60
+ const action = tag === "form" ? props.action : props.formAction ?? props.formaction;
61
+ if (action == null) return diagnostics;
62
+ if (tag === "input") {
63
+ if (props.type !== "submit" && props.type !== "image") {
64
+ diagnostics.push({
65
+ kind: "action-type",
66
+ message: 'A <input> can only specify `formAction` with type="submit" or type="image".'
67
+ });
68
+ return diagnostics;
69
+ }
70
+ } else if (tag === "button") {
71
+ if (props.type != null && props.type !== "submit") {
72
+ diagnostics.push({
73
+ kind: "action-type",
74
+ message: 'A <button> can only specify `formAction` with type="submit" or no type.'
75
+ });
76
+ return diagnostics;
77
+ }
78
+ } else if (tag !== "form") {
79
+ return diagnostics;
80
+ }
81
+ if (typeof action !== "function") return diagnostics;
82
+ if (tag === "form") {
83
+ if (props.method != null || props.encType != null || props.enctype != null) {
84
+ diagnostics.push({
85
+ kind: "action-method",
86
+ message: "A function form action cannot specify `method` or `encType`; Octane controls the submission transport."
87
+ });
88
+ }
89
+ if (props.target != null) {
90
+ diagnostics.push({
91
+ kind: "action-target",
92
+ message: "A function form action cannot specify `target`; the action always executes in the current window."
93
+ });
94
+ }
95
+ return diagnostics;
96
+ }
97
+ if (props.name != null) {
98
+ diagnostics.push({
99
+ kind: "action-name",
100
+ message: "A function `formAction` cannot specify `name`; the submitter identity is controlled by the action."
101
+ });
102
+ }
103
+ if (props.formMethod != null || props.formmethod != null || props.formEncType != null || props.formenctype != null) {
104
+ diagnostics.push({
105
+ kind: "action-method",
106
+ message: "A function `formAction` cannot specify `formMethod` or `formEncType`; Octane controls the submission transport."
107
+ });
108
+ }
109
+ if (props.formTarget != null || props.formtarget != null) {
110
+ diagnostics.push({
111
+ kind: "action-target",
112
+ message: "A function `formAction` cannot specify `formTarget`; the action always executes in the current window."
113
+ });
114
+ }
115
+ return diagnostics;
116
+ }
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ formAuthoringDiagnostics
120
+ });
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var host_property_diagnostics_exports = {};
20
+ __export(host_property_diagnostics_exports, {
21
+ booleanAttributeStringWarning: () => booleanAttributeStringWarning,
22
+ emptyResourceUrlWarning: () => emptyResourceUrlWarning,
23
+ hostPropertyWarning: () => hostPropertyWarning,
24
+ invalidHostPropertiesWarning: () => invalidHostPropertiesWarning,
25
+ unsupportedAttributeCoercionWarning: () => unsupportedAttributeCoercionWarning
26
+ });
27
+ module.exports = __toCommonJS(host_property_diagnostics_exports);
28
+ var import_constants = require("./constants.cjs");
29
+ const KNOWN_CAMELCASE_PROPERTIES = /* @__PURE__ */ new Set([
30
+ "autoCapitalize",
31
+ "autoComplete",
32
+ "autoCorrect",
33
+ "autoFocus",
34
+ "autoPlay",
35
+ "allowFullScreen",
36
+ "charSet",
37
+ "className",
38
+ "contentEditable",
39
+ "dangerouslySetInnerHTML",
40
+ "defaultChecked",
41
+ "defaultValue",
42
+ "disablePictureInPicture",
43
+ "disableRemotePlayback",
44
+ "encType",
45
+ "fetchPriority",
46
+ "formAction",
47
+ "formEncType",
48
+ "formMethod",
49
+ "formNoValidate",
50
+ "formTarget",
51
+ "imageSizes",
52
+ "imageSrcSet",
53
+ "inputMode",
54
+ "itemID",
55
+ "itemProp",
56
+ "itemRef",
57
+ "itemScope",
58
+ "itemType",
59
+ "maxLength",
60
+ "noModule",
61
+ "noValidate",
62
+ "playsInline",
63
+ "readOnly",
64
+ "referrerPolicy",
65
+ "spellCheck",
66
+ "srcDoc",
67
+ "srcLang",
68
+ "srcSet",
69
+ "suppressContentEditableWarning",
70
+ "suppressHydrationWarning",
71
+ "suppressNativeChangeWarning",
72
+ "tabIndex",
73
+ "viewBox"
74
+ ]);
75
+ const KNOWN_PROPERTY_SPELLINGS = /* @__PURE__ */ new Map();
76
+ for (const name of KNOWN_CAMELCASE_PROPERTIES)
77
+ KNOWN_PROPERTY_SPELLINGS.set(name.toLowerCase(), name);
78
+ for (const [name, alias] of import_constants.ATTRIBUTE_ALIASES) {
79
+ KNOWN_PROPERTY_SPELLINGS.set(name.toLowerCase(), name);
80
+ KNOWN_PROPERTY_SPELLINGS.set(alias.toLowerCase(), name);
81
+ }
82
+ const KNOWN_SVG_PROPERTY_SPELLINGS = /* @__PURE__ */ new Map();
83
+ for (const name of [
84
+ "allowReorder",
85
+ "attributeName",
86
+ "attributeType",
87
+ "autoReverse",
88
+ "baseFrequency",
89
+ "baseProfile",
90
+ "calcMode",
91
+ "clipPathUnits",
92
+ "contentScriptType",
93
+ "contentStyleType",
94
+ "diffuseConstant",
95
+ "edgeMode",
96
+ "externalResourcesRequired",
97
+ "filterRes",
98
+ "filterUnits",
99
+ "glyphRef",
100
+ "gradientTransform",
101
+ "gradientUnits",
102
+ "kernelMatrix",
103
+ "kernelUnitLength",
104
+ "keyPoints",
105
+ "keySplines",
106
+ "keyTimes",
107
+ "lengthAdjust",
108
+ "limitingConeAngle",
109
+ "markerHeight",
110
+ "markerUnits",
111
+ "markerWidth",
112
+ "maskContentUnits",
113
+ "maskUnits",
114
+ "numOctaves",
115
+ "pathLength",
116
+ "patternContentUnits",
117
+ "patternTransform",
118
+ "patternUnits",
119
+ "pointsAtX",
120
+ "pointsAtY",
121
+ "pointsAtZ",
122
+ "preserveAlpha",
123
+ "preserveAspectRatio",
124
+ "primitiveUnits",
125
+ "refX",
126
+ "refY",
127
+ "repeatCount",
128
+ "repeatDur",
129
+ "requiredExtensions",
130
+ "requiredFeatures",
131
+ "specularConstant",
132
+ "specularExponent",
133
+ "spreadMethod",
134
+ "startOffset",
135
+ "stdDeviation",
136
+ "stitchTiles",
137
+ "surfaceScale",
138
+ "systemLanguage",
139
+ "tableValues",
140
+ "targetX",
141
+ "targetY",
142
+ "textLength",
143
+ "viewTarget",
144
+ "xChannelSelector",
145
+ "yChannelSelector",
146
+ "zoomAndPan"
147
+ ]) {
148
+ KNOWN_SVG_PROPERTY_SPELLINGS.set(name.toLowerCase(), name);
149
+ }
150
+ function hostPropertyWarning(name, value, tag, isSvg = false) {
151
+ const lower = name.toLowerCase();
152
+ if (name === "for" && tag === "label") return null;
153
+ if (lower === "innerhtml") {
154
+ return "Directly setting property `innerHTML` is not permitted. Use `dangerouslySetInnerHTML={{ __html: value }}` instead.";
155
+ }
156
+ if (lower === "is" && value != null && typeof value !== "string") {
157
+ return `Received a \`${typeof value}\` for a string attribute \`is\`. If this is expected, cast the value to a string.`;
158
+ }
159
+ if (name.length > 2 && name[0] === "o" && name[1] === "n" && typeof value === "string") {
160
+ return `Unknown event handler property \`${name}\`. It will be ignored.`;
161
+ }
162
+ if (name.startsWith("aria-") || /^aria[A-Z]/.test(name) || name.startsWith("data-")) return null;
163
+ const known = KNOWN_PROPERTY_SPELLINGS.get(lower) ?? (isSvg ? KNOWN_SVG_PROPERTY_SPELLINGS.get(lower) : void 0);
164
+ if (known !== void 0) {
165
+ if (isSvg && import_constants.ATTRIBUTE_ALIASES.get(known) === name) return null;
166
+ return name !== known ? `Invalid DOM property \`${name}\`. Did you mean \`${known}\`?` : null;
167
+ }
168
+ if (name !== lower && !name.includes(":")) {
169
+ return `Octane does not recognize the \`${name}\` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase \`${lower}\` instead. If you accidentally passed it from a parent component, remove it from the DOM element.`;
170
+ }
171
+ return null;
172
+ }
173
+ function booleanAttributeStringWarning(name, value) {
174
+ if (value !== "false" && value !== "true" || !import_constants.BOOLEAN_ATTR_PROPS.has(name.toLowerCase())) {
175
+ return null;
176
+ }
177
+ return `Received the string \`${value}\` for the boolean attribute \`${name}\`. ` + (value === "false" ? "The browser will interpret it as a truthy value. " : 'Although this works, it will not work as expected if you pass the string "false". ') + `Did you mean ${name}={${value}}?`;
178
+ }
179
+ function invalidHostPropertiesWarning(names, tag) {
180
+ const quoted = names.map((name) => `\`${name}\``).join(", ");
181
+ return names.length === 1 ? `Invalid value for prop ${quoted} on <${tag}> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM.` : `Invalid values for props ${quoted} on <${tag}> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM.`;
182
+ }
183
+ function emptyResourceUrlWarning(name) {
184
+ return `An empty string was passed to the \`${name}\` attribute. This may cause the browser to download the whole page again. Pass null instead of an empty string.`;
185
+ }
186
+ function unsupportedAttributeCoercionWarning(name, value) {
187
+ const type = typeof value === "symbol" ? "Symbol" : value.constructor?.name || typeof value;
188
+ return `The provided \`${name}\` attribute is an unsupported type ${type}. Coerce it to a string before passing it to a DOM element.`;
189
+ }
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ booleanAttributeStringWarning,
193
+ emptyResourceUrlWarning,
194
+ hostPropertyWarning,
195
+ invalidHostPropertiesWarning,
196
+ unsupportedAttributeCoercionWarning
197
+ });
@@ -19,11 +19,35 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var html_tree_validation_exports = {};
20
20
  __export(html_tree_validation_exports, {
21
21
  invalidHtmlNestingWithAncestor: () => invalidHtmlNestingWithAncestor,
22
- invalidHtmlNestingWithParent: () => invalidHtmlNestingWithParent
22
+ invalidHtmlNestingWithParent: () => invalidHtmlNestingWithParent,
23
+ invalidHtmlTextNesting: () => invalidHtmlTextNesting
23
24
  });
24
25
  module.exports = __toCommonJS(html_tree_validation_exports);
25
26
  const autoclosingChildren = {
26
- li: { direct: ["li"] },
27
+ li: {
28
+ descendant: ["li"],
29
+ resetBy: [
30
+ "article",
31
+ "aside",
32
+ "blockquote",
33
+ "details",
34
+ "dl",
35
+ "fieldset",
36
+ "figcaption",
37
+ "figure",
38
+ "footer",
39
+ "form",
40
+ "header",
41
+ "main",
42
+ "menu",
43
+ "nav",
44
+ "object",
45
+ "ol",
46
+ "section",
47
+ "table",
48
+ "ul"
49
+ ]
50
+ },
27
51
  dt: { descendant: ["dt", "dd"], resetBy: ["dl"] },
28
52
  dd: { descendant: ["dt", "dd"], resetBy: ["dl"] },
29
53
  p: {
@@ -55,7 +79,8 @@ const autoclosingChildren = {
55
79
  "section",
56
80
  "table",
57
81
  "ul"
58
- ]
82
+ ],
83
+ resetBy: ["button", "object", "table", "td", "th", "template"]
59
84
  },
60
85
  rt: { descendant: ["rt", "rp"] },
61
86
  rp: { descendant: ["rt", "rp"] },
@@ -71,8 +96,8 @@ const autoclosingChildren = {
71
96
  const disallowedChildren = {
72
97
  ...autoclosingChildren,
73
98
  form: { descendant: ["form"] },
74
- a: { descendant: ["a"] },
75
- button: { descendant: ["button"] },
99
+ a: { descendant: ["a"], resetBy: ["object", "table", "td", "th", "template"] },
100
+ button: { descendant: ["button"], resetBy: ["object", "table", "td", "th", "template"] },
76
101
  h1: { descendant: ["h1", "h2", "h3", "h4", "h5", "h6"] },
77
102
  h2: { descendant: ["h1", "h2", "h3", "h4", "h5", "h6"] },
78
103
  h3: { descendant: ["h1", "h2", "h3", "h4", "h5", "h6"] },
@@ -80,6 +105,9 @@ const disallowedChildren = {
80
105
  h5: { descendant: ["h1", "h2", "h3", "h4", "h5", "h6"] },
81
106
  h6: { descendant: ["h1", "h2", "h3", "h4", "h5", "h6"] },
82
107
  tr: { only: ["th", "td", "style", "script", "template"] },
108
+ select: { only: ["hr", "option", "optgroup", "script", "template"] },
109
+ optgroup: { only: ["option"] },
110
+ option: { only: [] },
83
111
  tbody: { only: ["tr", "style", "script", "template"] },
84
112
  thead: { only: ["tr", "style", "script", "template"] },
85
113
  tfoot: { only: ["tr", "style", "script", "template"] },
@@ -141,7 +169,14 @@ function invalidHtmlNestingWithParent(childTag, parentTag, childLocation, parent
141
169
  }
142
170
  if ("only" in disallowed && !disallowed.only.includes(childTag)) {
143
171
  const allowed = disallowed.only.map((tag) => `\`<${tag}>\``).join(", ");
144
- return `${child} cannot be a child of ${parent}. \`<${parentTag}>\` only allows these children: ${allowed}`;
172
+ let message = `${child} cannot be a child of ${parent}`;
173
+ if (allowed !== "") {
174
+ message += `. \`<${parentTag}>\` only allows these children: ${allowed}`;
175
+ }
176
+ if (parentTag === "table" && childTag === "tr") {
177
+ message += ". Add a `<tbody>`, `<thead>`, or `<tfoot>` to match the DOM tree generated by the browser";
178
+ }
179
+ return message;
145
180
  }
146
181
  if ("only" in disallowed) return null;
147
182
  }
@@ -168,8 +203,17 @@ function invalidHtmlNestingWithParent(childTag, parentTag, childLocation, parent
168
203
  return null;
169
204
  }
170
205
  }
206
+ function invalidHtmlTextNesting(text, parentTag, parentLocation) {
207
+ if (text === "") return null;
208
+ if (parentTag !== "table" && parentTag !== "tbody" && parentTag !== "thead" && parentTag !== "tfoot" && parentTag !== "tr" && parentTag !== "colgroup" && parentTag !== "head" && parentTag !== "html") {
209
+ return null;
210
+ }
211
+ const whitespace = !/\S/.test(text);
212
+ return (whitespace ? "whitespace text nodes" : "text nodes") + " cannot be a child of " + elementLabel(parentTag, parentLocation) + (whitespace ? ". Make sure you do not have any extra whitespace between tags" : "");
213
+ }
171
214
  // Annotate the CommonJS export names for ESM import in node:
172
215
  0 && (module.exports = {
173
216
  invalidHtmlNestingWithAncestor,
174
- invalidHtmlNestingWithParent
217
+ invalidHtmlNestingWithParent,
218
+ invalidHtmlTextNesting
175
219
  });
@@ -87,6 +87,7 @@ __export(index_exports, {
87
87
  delegateEvents: () => import_runtime.delegateEvents,
88
88
  descriptorChildren: () => import_runtime.descriptorChildren,
89
89
  devEventListener: () => import_runtime.devEventListener,
90
+ devHtmlNesting: () => import_runtime.devHtmlNesting,
90
91
  drainFrag: () => import_runtime.drainFrag,
91
92
  drainPassiveEffects: () => import_runtime.drainPassiveEffects,
92
93
  errorBlock: () => import_runtime.errorBlock,
@@ -145,6 +146,7 @@ __export(index_exports, {
145
146
  puTake2: () => import_runtime.puTake2,
146
147
  puTake3: () => import_runtime.puTake3,
147
148
  puTake4: () => import_runtime.puTake4,
149
+ queueFormAuthoringDiagnostic: () => import_runtime.queueFormAuthoringDiagnostic,
148
150
  queueNativeChangeDiagnostic: () => import_runtime.queueNativeChangeDiagnostic,
149
151
  queueOwnRefDetach: () => import_runtime.queueOwnRefDetach,
150
152
  queueRefAttach: () => import_runtime.queueRefAttach,
@@ -300,6 +302,7 @@ var import_method_dep = require("./method-dep.cjs");
300
302
  delegateEvents,
301
303
  descriptorChildren,
302
304
  devEventListener,
305
+ devHtmlNesting,
303
306
  drainFrag,
304
307
  drainPassiveEffects,
305
308
  errorBlock,
@@ -358,6 +361,7 @@ var import_method_dep = require("./method-dep.cjs");
358
361
  puTake2,
359
362
  puTake3,
360
363
  puTake4,
364
+ queueFormAuthoringDiagnostic,
361
365
  queueNativeChangeDiagnostic,
362
366
  queueOwnRefDetach,
363
367
  queueRefAttach,
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var resource_hint_diagnostics_exports = {};
20
+ __export(resource_hint_diagnostics_exports, {
21
+ resourceHintWarning: () => resourceHintWarning
22
+ });
23
+ module.exports = __toCommonJS(resource_hint_diagnostics_exports);
24
+ function describeHintValue(value) {
25
+ if (value === null) return "`null`";
26
+ if (value === void 0) return "`undefined`";
27
+ if (value === "") return "an empty string";
28
+ if (typeof value === "string") return JSON.stringify(value);
29
+ if (typeof value === "number") return "`" + value + "`";
30
+ return 'a value of type "' + typeof value + '"';
31
+ }
32
+ function resourceHintWarning(name, href, options, hasOptions = false) {
33
+ const invalidHref = typeof href !== "string" || href === "";
34
+ const invalidOptions = options === null || typeof options !== "object";
35
+ if (name === "preload") {
36
+ let encountered = "";
37
+ if (invalidHref) encountered += " The `href` argument was " + describeHintValue(href) + ".";
38
+ if (invalidOptions) {
39
+ encountered += " The `options` argument was " + describeHintValue(options) + ".";
40
+ } else {
41
+ const destination = options.as;
42
+ if (typeof destination !== "string" || destination === "") {
43
+ encountered += " The `as` option was " + describeHintValue(destination) + ".";
44
+ }
45
+ }
46
+ return encountered === "" ? null : "preload(): Expected a non-empty `href` string and an `options` object with a valid `as` destination." + encountered;
47
+ }
48
+ if (name === "preloadModule" || name === "preinitModule") {
49
+ let encountered = "";
50
+ if (invalidHref) encountered += " The `href` argument was " + describeHintValue(href) + ".";
51
+ if (options != null && invalidOptions) {
52
+ encountered += " The `options` argument was " + describeHintValue(options) + ".";
53
+ } else if (options !== null && typeof options === "object" && "as" in options) {
54
+ const destination = options.as;
55
+ if (name === "preloadModule" && typeof destination !== "string" || name === "preinitModule" && destination !== "script") {
56
+ encountered += " The `as` option was " + describeHintValue(destination) + ".";
57
+ }
58
+ }
59
+ if (encountered === "") return null;
60
+ return name + "(): Expected a non-empty `href` string and optional object-shaped `options`" + (name === "preinitModule" ? ' with `as: "script"`.' : " with a string `as` destination.") + encountered;
61
+ }
62
+ if (invalidHref) {
63
+ return name + "(): Expected a non-empty string `href`; received " + describeHintValue(href) + ".";
64
+ }
65
+ if (name === "preinit") {
66
+ if (invalidOptions) {
67
+ return 'preinit(): Expected the `options` argument to be an object with `as: "style"` or `as: "script"`; received ' + describeHintValue(options) + ".";
68
+ }
69
+ const destination = options.as;
70
+ return destination === "style" || destination === "script" ? null : 'preinit(): The `as` option must be "style" or "script"; received ' + describeHintValue(destination) + ". Use preload() for other resource destinations.";
71
+ }
72
+ if (name === "preconnect") {
73
+ if (options != null && typeof options !== "object") {
74
+ return "preconnect(): Expected the optional `options` argument to be an object; received " + describeHintValue(options) + ".";
75
+ }
76
+ if (options !== null && typeof options === "object") {
77
+ const crossOrigin2 = options.crossOrigin;
78
+ if (typeof crossOrigin2 !== "string") {
79
+ return "preconnect(): The `crossOrigin` option must be a string; received " + describeHintValue(crossOrigin2) + ". Remove the option or provide a string value.";
80
+ }
81
+ }
82
+ return null;
83
+ }
84
+ if (!hasOptions) return null;
85
+ const crossOrigin = options !== null && typeof options === "object" && "crossOrigin" in options ? " Browsers never use `crossOrigin` for DNS queries." : "";
86
+ return "prefetchDNS(): Expected only one `href` argument; the second `options` argument is unsupported." + crossOrigin;
87
+ }
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ resourceHintWarning
91
+ });