@wcstack/fetch 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +6 -2
- package/README.md +6 -2
- package/dist/auto.d.ts +2 -0
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +27 -19
- package/dist/index.esm.js +44 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -275,6 +275,7 @@ declare class Fetch extends HTMLElement {
|
|
|
275
275
|
private _connectResolve;
|
|
276
276
|
private _lastFetchedUrl;
|
|
277
277
|
private _toldTriggerWithoutUrl;
|
|
278
|
+
private _toldUndefinedHelper;
|
|
278
279
|
private _internals;
|
|
279
280
|
constructor();
|
|
280
281
|
get debugStates(): string[];
|
|
@@ -347,6 +348,13 @@ declare class Fetch extends HTMLElement {
|
|
|
347
348
|
* (docs/v4-direction-2026-10.md §5.1, the I/O command policy).
|
|
348
349
|
*/
|
|
349
350
|
private _warnTriggerWithoutUrl;
|
|
351
|
+
/**
|
|
352
|
+
* A `<wcs-fetch-header>` / `<wcs-fetch-body>` whose definition never loaded is a plain element, and its
|
|
353
|
+
* header or body was left out of the request without a word: a page that defines the tags itself (an
|
|
354
|
+
* autoloader's wrapper module, a scoped registry) defined `<wcs-fetch>` only (docs/seam-apps.md,
|
|
355
|
+
* fw-inventory). Said once per element.
|
|
356
|
+
*/
|
|
357
|
+
private _warnUndefinedHelper;
|
|
350
358
|
private _warnUnsafeAutoFetch;
|
|
351
359
|
fetch(): Promise<any>;
|
|
352
360
|
attributeChangedCallback(name: string, _oldValue: string | null, _newValue: string | null): void;
|
|
@@ -380,24 +388,6 @@ declare class InfiniteScroll extends HTMLElement {
|
|
|
380
388
|
private _triggerFetch;
|
|
381
389
|
}
|
|
382
390
|
|
|
383
|
-
/**
|
|
384
|
-
* fetchCapabilities.ts
|
|
385
|
-
*
|
|
386
|
-
* fetch node 固有の capability registry と error code。汎用の assess 機構・型は
|
|
387
|
-
* `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
|
|
388
|
-
* import する。node 固有の宣言はこのハンドライトファイルに置き、生成コピーとは分離する。
|
|
389
|
-
*/
|
|
390
|
-
|
|
391
|
-
/** 安定した fetch error code(taxonomy)。値は公開キーとして固定。 */
|
|
392
|
-
declare const WCS_FETCH_ERROR_CODE: {
|
|
393
|
-
readonly CapabilityMissing: "capability-missing";
|
|
394
|
-
readonly InvalidArgument: "invalid-argument";
|
|
395
|
-
readonly Network: "network";
|
|
396
|
-
readonly HttpError: "http-error";
|
|
397
|
-
readonly Timeout: "timeout";
|
|
398
|
-
readonly Aborted: "aborted";
|
|
399
|
-
};
|
|
400
|
-
|
|
401
391
|
/**
|
|
402
392
|
* `<wcs-fetch-header name value>`: one request header of the `<wcs-fetch>` it sits in, read when a
|
|
403
393
|
* request starts. `name` / `value` are properties too, reflected to the attributes (`null` removes
|
|
@@ -426,6 +416,24 @@ declare class FetchBody extends HTMLElement {
|
|
|
426
416
|
get bodyContent(): string;
|
|
427
417
|
}
|
|
428
418
|
|
|
419
|
+
/**
|
|
420
|
+
* fetchCapabilities.ts
|
|
421
|
+
*
|
|
422
|
+
* fetch node 固有の capability registry と error code。汎用の assess 機構・型は
|
|
423
|
+
* `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
|
|
424
|
+
* import する。node 固有の宣言はこのハンドライトファイルに置き、生成コピーとは分離する。
|
|
425
|
+
*/
|
|
426
|
+
|
|
427
|
+
/** 安定した fetch error code(taxonomy)。値は公開キーとして固定。 */
|
|
428
|
+
declare const WCS_FETCH_ERROR_CODE: {
|
|
429
|
+
readonly CapabilityMissing: "capability-missing";
|
|
430
|
+
readonly InvalidArgument: "invalid-argument";
|
|
431
|
+
readonly Network: "network";
|
|
432
|
+
readonly HttpError: "http-error";
|
|
433
|
+
readonly Timeout: "timeout";
|
|
434
|
+
readonly Aborted: "aborted";
|
|
435
|
+
};
|
|
436
|
+
|
|
429
437
|
declare global {
|
|
430
438
|
interface HTMLElementTagNameMap {
|
|
431
439
|
"wcs-fetch": Fetch;
|
|
@@ -435,5 +443,5 @@ declare global {
|
|
|
435
443
|
}
|
|
436
444
|
}
|
|
437
445
|
|
|
438
|
-
export { FetchCore, TRUSTED_TYPES_POLICY_SLOT, WCS_FETCH_ERROR_CODE, Fetch as WcsFetch, InfiniteScroll as WcsInfiniteScroll, bootstrapFetch, getConfig, getTrustedTypesPolicy, setTrustedTypesPolicy };
|
|
446
|
+
export { FetchCore, TRUSTED_TYPES_POLICY_SLOT, WCS_FETCH_ERROR_CODE, Fetch as WcsFetch, FetchBody as WcsFetchBody, FetchHeader as WcsFetchHeader, InfiniteScroll as WcsInfiniteScroll, bootstrapFetch, getConfig, getTrustedTypesPolicy, setTrustedTypesPolicy };
|
|
439
447
|
export type { FetchRequestOptions, IWcsTrustedTypesPolicy, IWritableConfig, IWritableTagNames, WcsFetchCoreValues, WcsFetchHttpError, WcsFetchValues, WcsIoErrorInfo, WcsIoErrorPhase };
|
package/dist/index.esm.js
CHANGED
|
@@ -935,6 +935,21 @@ function hasAccessorOnPrototype(target, name) {
|
|
|
935
935
|
}
|
|
936
936
|
return false;
|
|
937
937
|
}
|
|
938
|
+
// 属性になってしまったオブジェクトの入力(`files="[object File]"`)を、要素ごとに 1 回だけ言う。
|
|
939
|
+
// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も
|
|
940
|
+
// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった
|
|
941
|
+
// (docs/seam-apps.md、fw-inventory)。
|
|
942
|
+
const toldObjectAttribute = new WeakSet();
|
|
943
|
+
function warnObjectAttribute(element, name, value) {
|
|
944
|
+
if (toldObjectAttribute.has(element))
|
|
945
|
+
return;
|
|
946
|
+
toldObjectAttribute.add(element);
|
|
947
|
+
const tag = element.localName ?? "element";
|
|
948
|
+
console.warn(`[wcs/input-as-attribute] <${tag}> has the attribute ${name}="${value}": an object was written as an ` +
|
|
949
|
+
`attribute, so the element did not receive it. A framework does that when the property is set before the ` +
|
|
950
|
+
`element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +
|
|
951
|
+
`or assign the property through a ref (Vue: .prop). (Said once per element.)`, element);
|
|
952
|
+
}
|
|
938
953
|
/**
|
|
939
954
|
* `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
|
|
940
955
|
* accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
|
|
@@ -942,14 +957,19 @@ function hasAccessorOnPrototype(target, name) {
|
|
|
942
957
|
* - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
|
|
943
958
|
* - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
|
|
944
959
|
* - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
|
|
960
|
+
* - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。
|
|
945
961
|
*/
|
|
946
962
|
function upgradeProperties(element) {
|
|
947
963
|
const declaration = element.constructor?.wcBindable;
|
|
948
964
|
const inputs = declaration?.inputs;
|
|
949
965
|
if (inputs === undefined)
|
|
950
966
|
return;
|
|
967
|
+
const getAttribute = element.getAttribute;
|
|
951
968
|
for (const input of inputs) {
|
|
952
969
|
const name = input.name;
|
|
970
|
+
const attribute = typeof getAttribute === "function" ? getAttribute.call(element, name.toLowerCase()) : null;
|
|
971
|
+
if (attribute !== null && attribute.startsWith("[object "))
|
|
972
|
+
warnObjectAttribute(element, name, attribute);
|
|
953
973
|
if (!Object.prototype.hasOwnProperty.call(element, name))
|
|
954
974
|
continue;
|
|
955
975
|
if (!hasAccessorOnPrototype(element, name))
|
|
@@ -1159,6 +1179,7 @@ class Fetch extends HTMLElement {
|
|
|
1159
1179
|
_connectResolve = null;
|
|
1160
1180
|
_lastFetchedUrl = null;
|
|
1161
1181
|
_toldTriggerWithoutUrl = false;
|
|
1182
|
+
_toldUndefinedHelper = false;
|
|
1162
1183
|
_internals = null;
|
|
1163
1184
|
constructor() {
|
|
1164
1185
|
super();
|
|
@@ -1339,6 +1360,10 @@ class Fetch extends HTMLElement {
|
|
|
1339
1360
|
const headers = {};
|
|
1340
1361
|
const headerElements = this.querySelectorAll(config.tagNames.fetchHeader);
|
|
1341
1362
|
for (const el of headerElements) {
|
|
1363
|
+
if (typeof el.hasHeader !== "boolean") {
|
|
1364
|
+
this._warnUndefinedHelper(config.tagNames.fetchHeader, "header");
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1342
1367
|
// a header without a value attribute is not sent (FetchHeader)
|
|
1343
1368
|
if (el.hasHeader) {
|
|
1344
1369
|
headers[el.headerName] = el.headerValue;
|
|
@@ -1375,7 +1400,10 @@ class Fetch extends HTMLElement {
|
|
|
1375
1400
|
}
|
|
1376
1401
|
// サブタグからbodyを取得
|
|
1377
1402
|
const bodyElement = this.querySelector(config.tagNames.fetchBody);
|
|
1378
|
-
if (bodyElement) {
|
|
1403
|
+
if (bodyElement && typeof bodyElement.bodyContent !== "string") {
|
|
1404
|
+
this._warnUndefinedHelper(config.tagNames.fetchBody, "body");
|
|
1405
|
+
}
|
|
1406
|
+
else if (bodyElement) {
|
|
1379
1407
|
return {
|
|
1380
1408
|
body: bodyElement.bodyContent || null,
|
|
1381
1409
|
contentType: bodyElement.contentType,
|
|
@@ -1462,6 +1490,20 @@ class Fetch extends HTMLElement {
|
|
|
1462
1490
|
"Write url before trigger (bindings apply in the order written), and write trigger again once there is one. " +
|
|
1463
1491
|
"(Said once per element.)", this);
|
|
1464
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* A `<wcs-fetch-header>` / `<wcs-fetch-body>` whose definition never loaded is a plain element, and its
|
|
1495
|
+
* header or body was left out of the request without a word: a page that defines the tags itself (an
|
|
1496
|
+
* autoloader's wrapper module, a scoped registry) defined `<wcs-fetch>` only (docs/seam-apps.md,
|
|
1497
|
+
* fw-inventory). Said once per element.
|
|
1498
|
+
*/
|
|
1499
|
+
_warnUndefinedHelper(tag, what) {
|
|
1500
|
+
if (this._toldUndefinedHelper)
|
|
1501
|
+
return;
|
|
1502
|
+
this._toldUndefinedHelper = true;
|
|
1503
|
+
console.warn(`[@wcstack/fetch] [wcs/fetch-helper-undefined] <${tag}> inside this <${config.tagNames.fetch}> is not ` +
|
|
1504
|
+
`defined, so its ${what} is not sent. Load @wcstack/fetch/auto, or define WcsFetchHeader and WcsFetchBody ` +
|
|
1505
|
+
"with WcsFetch when the page defines the tags itself. (Said once per element.)", this);
|
|
1506
|
+
}
|
|
1465
1507
|
_warnUnsafeAutoFetch() {
|
|
1466
1508
|
const method = this.method;
|
|
1467
1509
|
if (method === "GET" || method === "HEAD" || method === "OPTIONS")
|
|
@@ -1777,5 +1819,5 @@ function bootstrapFetch(userConfig, registry) {
|
|
|
1777
1819
|
registerComponents(registry);
|
|
1778
1820
|
}
|
|
1779
1821
|
|
|
1780
|
-
export { FetchCore, TRUSTED_TYPES_POLICY_SLOT, WCS_FETCH_ERROR_CODE, Fetch as WcsFetch, InfiniteScroll as WcsInfiniteScroll, bootstrapFetch, getConfig, getTrustedTypesPolicy, setTrustedTypesPolicy };
|
|
1822
|
+
export { FetchCore, TRUSTED_TYPES_POLICY_SLOT, WCS_FETCH_ERROR_CODE, Fetch as WcsFetch, FetchBody as WcsFetchBody, FetchHeader as WcsFetchHeader, InfiniteScroll as WcsInfiniteScroll, bootstrapFetch, getConfig, getTrustedTypesPolicy, setTrustedTypesPolicy };
|
|
1781
1823
|
//# sourceMappingURL=index.esm.js.map
|