@tunasand/sdk 0.7.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +233 -88
- package/README.md +296 -273
- package/dist/analytics.js +657 -10
- package/dist/app.js +323 -96
- package/dist/apps-DIxAWBSZ.js +318 -0
- package/dist/astro-image.d.ts +1 -0
- package/dist/astro-image.js +33 -0
- package/dist/astro-server-Bwau8F6d.js +99 -0
- package/dist/astro-server.d.ts +1 -0
- package/dist/astro-server.js +1 -0
- package/dist/astro.d.ts +1 -0
- package/dist/astro.js +306 -0
- package/dist/bridge-Dv4NxGZ7.js +81 -0
- package/dist/bridge.js +2 -14
- package/dist/build-file-DNi0PHC5.js +31 -0
- package/dist/cli.js +6214 -9
- package/dist/{client-Derrexwr.js → client-C8STAw9T.js} +43 -24
- package/dist/code-N8pBUDbq.js +30 -0
- package/dist/code.d.ts +1 -0
- package/dist/code.js +1 -0
- package/dist/collection-nUz1RetA.js +264 -0
- package/dist/{declared-C_GvPiGF.js → declared-CE4a61qb.js} +124 -36
- package/dist/delivery.js +124 -132
- package/dist/dev-operations-Tutwi1On.js +46 -0
- package/dist/dev.js +9 -16
- package/dist/embeds-B-Dbn64k.js +29 -0
- package/dist/end-users.d.ts +1 -0
- package/dist/end-users.js +185 -0
- package/dist/{customers-C_vJY2_v.js → endUsers-DODfjnv1.js} +31 -38
- package/dist/{errorLabels-CPKiPabZ.js → errorLabels-aT2bnMsO.js} +593 -460
- package/dist/i18n.js +4 -4
- package/dist/ids-DmtIoqBX.js +109 -0
- package/dist/integrations.js +95 -49
- package/dist/{ja-C6lX0CeJ.js → ja-CrY_72Tn.js} +99 -54
- package/dist/{ja-C1HEWWTQ.js → ja-axQPxMJ-.js} +6 -6
- package/dist/operations-CIB99rIY.js +95 -0
- package/dist/operations.d.ts +1 -0
- package/dist/operations.js +1 -0
- package/dist/{page-E_cYgZx-.js → page-yo1cw1kW.js} +5 -5
- package/dist/preview.js +8 -1
- package/dist/{profile-D6t1QMQh.js → profile-DBsXLvvI.js} +52 -52
- package/dist/rich-text.d.ts +1 -0
- package/dist/{body.js → rich-text.js} +20 -21
- package/dist/schema-Dcg1ajnW.js +1267 -0
- package/dist/schema.js +324 -1
- package/dist/types/access/src/handoff.d.ts +22 -17
- package/dist/types/access/src/index.d.ts +2 -2
- package/dist/types/access/src/jws.d.ts +41 -0
- package/dist/types/access/src/jwt.d.ts +1 -1
- package/dist/types/access/src/oidc.d.ts +11 -3
- package/dist/types/access/src/signed.d.ts +0 -2
- package/dist/types/adapter-cloudflare/src/eventLog/viewSchema.d.ts +11 -0
- package/dist/types/contract/src/accountProfile.d.ts +7 -0
- package/dist/types/{cms-contract → contract}/src/apiKeys.d.ts +7 -3
- package/dist/types/contract/src/app.d.ts +38 -0
- package/dist/types/contract/src/appChannels.d.ts +114 -0
- package/dist/types/contract/src/appDefinition.d.ts +133 -0
- package/dist/types/{cms-contract → contract}/src/appDependencies.d.ts +91 -35
- package/dist/types/contract/src/appIdentities.d.ts +21 -0
- package/dist/types/contract/src/appInbound.d.ts +28 -0
- package/dist/types/contract/src/appMail.d.ts +106 -0
- package/dist/types/contract/src/appSecrets.d.ts +45 -0
- package/dist/types/contract/src/appServer.d.ts +501 -0
- package/dist/types/contract/src/approvalLabels.d.ts +26 -0
- package/dist/types/contract/src/approvals.d.ts +63 -0
- package/dist/types/contract/src/apps.d.ts +295 -0
- package/dist/types/contract/src/auditActions.d.ts +18 -0
- package/dist/types/contract/src/auditLabels.d.ts +223 -0
- package/dist/types/contract/src/authorize.d.ts +133 -0
- package/dist/types/{cms-contract → contract}/src/bridge.d.ts +39 -40
- package/dist/types/{cms-contract → contract}/src/consents.d.ts +32 -25
- package/dist/types/contract/src/deletion.d.ts +18 -0
- package/dist/types/contract/src/embeds.d.ts +105 -0
- package/dist/types/{cms-contract/src/customerLabels.d.ts → contract/src/endUserLabels.d.ts} +6 -9
- package/dist/types/contract/src/endUsers.d.ts +241 -0
- package/dist/types/{cms-contract → contract}/src/errorLabels.d.ts +76 -47
- package/dist/types/{cms-contract → contract}/src/errorLabelsEn.d.ts +52 -36
- package/dist/types/contract/src/errors.d.ts +117 -0
- package/dist/types/contract/src/eventSchemas.d.ts +70 -0
- package/dist/types/contract/src/eventTraces.d.ts +43 -0
- package/dist/types/{cms-contract → contract}/src/failureStatus.d.ts +16 -23
- package/dist/types/contract/src/fieldAccess.d.ts +45 -0
- package/dist/types/contract/src/fieldRules.d.ts +41 -0
- package/dist/types/{cms-contract/src/assets.d.ts → contract/src/files.d.ts} +5 -5
- package/dist/types/contract/src/formLabels.d.ts +3 -0
- package/dist/types/contract/src/forms.d.ts +4 -0
- package/dist/types/{cms-contract → contract}/src/functions.d.ts +3 -3
- package/dist/types/contract/src/grants.d.ts +26 -0
- package/dist/types/contract/src/headers.d.ts +5 -0
- package/dist/types/contract/src/hostingRpc.d.ts +149 -0
- package/dist/types/contract/src/hostnames.d.ts +30 -0
- package/dist/types/contract/src/identifiers.d.ts +148 -0
- package/dist/types/contract/src/ids.d.ts +112 -0
- package/dist/types/{cms-contract → contract}/src/import.d.ts +20 -19
- package/dist/types/contract/src/importLabels.d.ts +3 -0
- package/dist/types/contract/src/index.d.ts +92 -0
- package/dist/types/contract/src/integrationGraph.d.ts +83 -0
- package/dist/types/{cms-contract → contract}/src/issueLabels.d.ts +135 -99
- package/dist/types/{cms-contract → contract}/src/issueLabelsEn.d.ts +70 -52
- package/dist/types/contract/src/labels.d.ts +11 -0
- package/dist/types/contract/src/legacyAuditLabels.d.ts +10 -0
- package/dist/types/contract/src/livePeriods.d.ts +18 -0
- package/dist/types/contract/src/manage.d.ts +51 -0
- package/dist/types/contract/src/manageLabels.d.ts +11 -0
- package/dist/types/contract/src/manifestText.d.ts +66 -0
- package/dist/types/contract/src/mcpAuth.d.ts +139 -0
- package/dist/types/contract/src/mcpLabels.d.ts +5 -0
- package/dist/types/contract/src/messagePort.d.ts +208 -0
- package/dist/types/{cms-contract → contract}/src/migration.d.ts +3 -3
- package/dist/types/contract/src/notices.d.ts +38 -0
- package/dist/types/contract/src/operatorOperations.d.ts +640 -0
- package/dist/types/contract/src/operators.d.ts +33 -0
- package/dist/types/contract/src/outbound.d.ts +29 -0
- package/dist/types/contract/src/paths.d.ts +34 -0
- package/dist/types/contract/src/pending.d.ts +6 -0
- package/dist/types/{cms-contract → contract}/src/permissions.d.ts +9 -11
- package/dist/types/contract/src/perspective.d.ts +26 -0
- package/dist/types/contract/src/powers.d.ts +5 -0
- package/dist/types/contract/src/principal.d.ts +181 -0
- package/dist/types/{cms-contract → contract}/src/problems.d.ts +4 -4
- package/dist/types/contract/src/projectRole.d.ts +6 -0
- package/dist/types/contract/src/recordLabels.d.ts +6 -0
- package/dist/types/{cms-contract → contract}/src/roles.d.ts +10 -6
- package/dist/types/contract/src/ruleLabels.d.ts +16 -0
- package/dist/types/contract/src/ruleProblems.d.ts +16 -0
- package/dist/types/contract/src/schemaLabels.d.ts +8 -0
- package/dist/types/{cms-contract → contract}/src/settingProblems.d.ts +3 -3
- package/dist/types/{cms-contract → contract}/src/settings.d.ts +6 -8
- package/dist/types/contract/src/settingsLabels.d.ts +3 -0
- package/dist/types/{cms-contract → contract}/src/siteDeclaration.d.ts +7 -7
- package/dist/types/contract/src/siteIndex.d.ts +76 -0
- package/dist/types/contract/src/slugs.d.ts +6 -0
- package/dist/types/{cms-contract → contract}/src/transfer.d.ts +4 -4
- package/dist/types/contract/src/trial.d.ts +13 -0
- package/dist/types/contract/src/versions.d.ts +7 -0
- package/dist/types/{analytics/src/view.d.ts → contract/src/viewEvent.d.ts} +0 -9
- package/dist/types/contract/src/webhooks.d.ts +135 -0
- package/dist/types/contract/src/workflow.d.ts +43 -0
- package/dist/types/contract/src/workspaceItems.d.ts +87 -0
- package/dist/types/contract/src/workspacePaths.d.ts +4 -0
- package/dist/types/{body → rich-text}/src/declared.d.ts +2 -2
- package/dist/types/{body → rich-text}/src/embed.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/html.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/index.d.ts +8 -7
- package/dist/types/{body → rich-text}/src/labels/en.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/labels/ja.d.ts +4 -4
- package/dist/types/{body → rich-text}/src/library.d.ts +1 -1
- package/dist/types/rich-text/src/media.d.ts +2 -0
- package/dist/types/{body → rich-text}/src/normalize.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/problems.d.ts +5 -5
- package/dist/types/{body → rich-text}/src/profile.d.ts +11 -11
- package/dist/types/{body → rich-text}/src/render.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/schema.d.ts +2 -2
- package/dist/types/{body → rich-text}/src/standard.d.ts +4 -4
- package/dist/types/{body → rich-text}/src/types.d.ts +2 -2
- package/dist/types/schema/src/audience.d.ts +36 -0
- package/dist/types/schema/src/brand.d.ts +5 -0
- package/dist/types/schema/src/capabilities.d.ts +19 -0
- package/dist/types/{model → schema}/src/changes.d.ts +9 -7
- package/dist/types/{model → schema}/src/check.d.ts +2 -2
- package/dist/types/{model/src/model.d.ts → schema/src/collection.d.ts} +150 -121
- package/dist/types/schema/src/defaultSchema.d.ts +15 -0
- package/dist/types/schema/src/fieldIds.d.ts +18 -0
- package/dist/types/{model/src/asset.d.ts → schema/src/file.d.ts} +36 -25
- package/dist/types/schema/src/fileRefs.d.ts +14 -0
- package/dist/types/schema/src/fileSignature.d.ts +20 -0
- package/dist/types/schema/src/filesCollection.d.ts +7 -0
- package/dist/types/schema/src/forms.d.ts +43 -0
- package/dist/types/{model → schema}/src/image.d.ts +3 -3
- package/dist/types/schema/src/imageMetadata.d.ts +9 -0
- package/dist/types/schema/src/index.d.ts +35 -0
- package/dist/types/{model → schema}/src/input.d.ts +3 -3
- package/dist/types/{model → schema}/src/integrity.d.ts +9 -8
- package/dist/types/schema/src/kinds.d.ts +26 -0
- package/dist/types/{model → schema}/src/labels/en.d.ts +93 -51
- package/dist/types/{model → schema}/src/labels/ja.d.ts +97 -52
- package/dist/types/schema/src/mediaUrl.d.ts +60 -0
- package/dist/types/{model → schema}/src/page.d.ts +6 -6
- package/dist/types/{model → schema}/src/problems.d.ts +95 -53
- package/dist/types/{model → schema}/src/refs.d.ts +1 -10
- package/dist/types/{model → schema}/src/rules.d.ts +2 -2
- package/dist/types/{model → schema}/src/schema.d.ts +25 -20
- package/dist/types/schema/src/selfOps.d.ts +31 -0
- package/dist/types/{model/src/capabilities.d.ts → schema/src/traits.d.ts} +6 -6
- package/dist/types/schema/src/typesSource.d.ts +16 -0
- package/dist/types/{model → schema}/src/values.d.ts +7 -4
- package/dist/types/schema/src/widening.d.ts +3 -0
- package/dist/types/sdk/src/analytics.d.ts +3 -2
- package/dist/types/sdk/src/app.d.ts +70 -16
- package/dist/types/sdk/src/astro-image.d.ts +19 -0
- package/dist/types/sdk/src/astro-response.d.ts +6 -0
- package/dist/types/sdk/src/astro-server.d.ts +16 -0
- package/dist/types/sdk/src/astro.d.ts +19 -0
- package/dist/types/sdk/src/bridge.d.ts +13 -15
- package/dist/types/sdk/src/code.d.ts +61 -0
- package/dist/types/sdk/src/delegation.d.ts +49 -0
- package/dist/types/sdk/src/delivery/changes.d.ts +4 -4
- package/dist/types/sdk/src/delivery/client.d.ts +40 -28
- package/dist/types/sdk/src/delivery/fields.d.ts +5 -5
- package/dist/types/sdk/src/delivery/index.d.ts +3 -3
- package/dist/types/sdk/src/delivery/media.d.ts +8 -11
- package/dist/types/sdk/src/delivery/query.d.ts +16 -12
- package/dist/types/sdk/src/delivery/schema.d.ts +5 -5
- package/dist/types/sdk/src/delivery/values.d.ts +16 -20
- package/dist/types/sdk/src/delivery.d.ts +3 -3
- package/dist/types/sdk/src/dev-operations.d.ts +20 -0
- package/dist/types/sdk/src/dev.d.ts +6 -5
- package/dist/types/sdk/src/end-users.d.ts +190 -0
- package/dist/types/sdk/src/i18n.d.ts +11 -11
- package/dist/types/sdk/src/integrations.d.ts +20 -27
- package/dist/types/sdk/src/operations.d.ts +17 -0
- package/dist/types/sdk/src/preview.d.ts +2 -1
- package/dist/types/sdk/src/rich-text.d.ts +2 -0
- package/dist/types/sdk/src/schema.d.ts +5 -21
- package/dist/types/sdk/src/site/artifact.d.ts +64 -0
- package/dist/types/sdk/src/site/build-file.d.ts +30 -0
- package/dist/types/sdk/src/site/check-code.d.ts +14 -0
- package/dist/types/sdk/src/site/check-text.d.ts +19 -0
- package/dist/types/sdk/src/site/cli.d.ts +52 -0
- package/dist/types/sdk/src/site/content-type.d.ts +2 -0
- package/dist/types/sdk/src/site/labels.d.ts +14 -0
- package/dist/types/sdk/src/site.d.ts +1 -1
- package/dist/types/sdk/src/types.d.ts +21 -0
- package/dist/{schema-BPHL7Qr-.js → types-DkO2N7u2.js} +9 -9
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/dist/typesSource-VJIxtN9b.js +136 -0
- package/dist/workflow-CUpl6hO_.js +148 -0
- package/package.json +42 -16
- package/dist/apps-9u4XMi7E.js +0 -114
- package/dist/body.d.ts +0 -1
- package/dist/bridge-DYAYGV7t.js +0 -74
- package/dist/customers.d.ts +0 -1
- package/dist/customers.js +0 -185
- package/dist/embed-R-OvDYAw.js +0 -90
- package/dist/model-pmXzGX12.js +0 -152
- package/dist/model.d.ts +0 -1
- package/dist/model.js +0 -345
- package/dist/schema-UQJWRyfJ.js +0 -995
- package/dist/src-sazhzYui.js +0 -71
- package/dist/types/analytics/src/index.d.ts +0 -5
- package/dist/types/analytics/src/schedule.d.ts +0 -2
- package/dist/types/analytics/src/shared.d.ts +0 -21
- package/dist/types/analytics/src/source.d.ts +0 -19
- package/dist/types/analytics/src/store.d.ts +0 -24
- package/dist/types/cms-contract/src/app.d.ts +0 -35
- package/dist/types/cms-contract/src/apps.d.ts +0 -195
- package/dist/types/cms-contract/src/authorize.d.ts +0 -146
- package/dist/types/cms-contract/src/customers.d.ts +0 -266
- package/dist/types/cms-contract/src/embeds.d.ts +0 -165
- package/dist/types/cms-contract/src/errors.d.ts +0 -105
- package/dist/types/cms-contract/src/identifiers.d.ts +0 -117
- package/dist/types/cms-contract/src/paths.d.ts +0 -23
- package/dist/types/cms-contract/src/urlLabel.d.ts +0 -13
- package/dist/types/cms-contract/src/webhooks.d.ts +0 -139
- package/dist/types/model/src/audience.d.ts +0 -38
- package/dist/types/model/src/brand.d.ts +0 -25
- package/dist/types/model/src/index.d.ts +0 -26
- package/dist/types/model/src/legacy.d.ts +0 -2
- package/dist/types/model/src/media.d.ts +0 -5
- package/dist/types/model/src/mediaUrl.d.ts +0 -67
- package/dist/types/model/src/selfOps.d.ts +0 -30
- package/dist/types/model/src/typesSource.d.ts +0 -8
- package/dist/types/platform/src/defaultModel.d.ts +0 -8
- package/dist/types/sdk/src/body.d.ts +0 -2
- package/dist/types/sdk/src/customers.d.ts +0 -190
- package/dist/types/sdk/src/model.d.ts +0 -5
- package/dist/typesSource-bO0jFw1I.js +0 -88
- /package/dist/types/{cms-contract → contract}/src/appProblems.d.ts +0 -0
- /package/dist/types/{analytics → contract}/src/day.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/functionLabels.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/permissionLabels.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/siteArtifact.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/views.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/webhookLabels.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/components.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/derive.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/description.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/href.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/inline.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/markdown.d.ts +0 -0
- /package/dist/types/{model → schema}/src/contact.d.ts +0 -0
- /package/dist/types/{model → schema}/src/json.d.ts +0 -0
- /package/dist/types/{model → schema}/src/screens.d.ts +0 -0
- /package/dist/types/{model → schema}/src/time.d.ts +0 -0
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as formatMessage, f as problemText, l as problemFactory, n as CORE_COMPONENT_LABELS, r as RICH_TEXT_PROBLEM_MESSAGES, t as BODY_GUIDE_LABELS } from "./ja-axQPxMJ-.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
// ../
|
|
3
|
+
// ../rich-text/src/problems.ts
|
|
4
|
+
/** 本文の検査の問題を作る */
|
|
5
|
+
const richTextProblem = problemFactory(RICH_TEXT_PROBLEM_MESSAGES);
|
|
6
|
+
/** 問題の英語の既定の文(zod の message と検査の issues に入れ、problemOf で戻す) */
|
|
7
|
+
const richTextProblemText = (code, ...params) => problemText(richTextProblem(code, ...params));
|
|
8
|
+
/** Markdown の説明の文言 */
|
|
9
|
+
const guideText = (key, ...params) => formatMessage(BODY_GUIDE_LABELS[key], params[0]);
|
|
10
|
+
/** 部品の説明の文言(核の部品の説明と、宣言した部品の説明の組み立て) */
|
|
11
|
+
const componentText = (key, ...params) => formatMessage(CORE_COMPONENT_LABELS[key], params[0]);
|
|
12
|
+
// ../rich-text/src/components.ts
|
|
4
13
|
/** 予約の名前(ブロック) */
|
|
5
14
|
const RESERVED_BLOCK_NAMES = /* @__PURE__ */ new Set([
|
|
6
15
|
"block",
|
|
@@ -16,11 +25,90 @@ const RESERVED_INLINE_NAMES = /* @__PURE__ */ new Set([
|
|
|
16
25
|
"u",
|
|
17
26
|
"span"
|
|
18
27
|
]);
|
|
19
|
-
// ../
|
|
28
|
+
// ../rich-text/src/embed.ts
|
|
29
|
+
/** 埋め込めるサービス */
|
|
30
|
+
const EMBED_PROVIDERS = [
|
|
31
|
+
"youtube",
|
|
32
|
+
"vimeo",
|
|
33
|
+
"x",
|
|
34
|
+
"instagram",
|
|
35
|
+
"spotify",
|
|
36
|
+
"apple-podcasts"
|
|
37
|
+
];
|
|
38
|
+
const ID = /^[\w-]{1,64}$/;
|
|
39
|
+
/** 開始の秒(YouTube の t=1m30s・t=90・start=90) */
|
|
40
|
+
function startOf(params) {
|
|
41
|
+
const raw = params.get("t") ?? params.get("start");
|
|
42
|
+
if (!raw) return void 0;
|
|
43
|
+
const m = raw.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/);
|
|
44
|
+
if (!m) return void 0;
|
|
45
|
+
const sec = Number(m[1] ?? 0) * 3600 + Number(m[2] ?? 0) * 60 + Number(m[3] ?? 0);
|
|
46
|
+
return sec > 0 ? sec : void 0;
|
|
47
|
+
}
|
|
48
|
+
/** URL から埋め込み(埋め込めるサービスでなければ null) */
|
|
49
|
+
function embedOfUrl(raw) {
|
|
50
|
+
const url = URL.parse(raw);
|
|
51
|
+
if (!url || url.protocol !== "https:") return null;
|
|
52
|
+
const host = url.hostname.replace(/^(www|m)\./, "");
|
|
53
|
+
const path = url.pathname.split("/").filter(Boolean);
|
|
54
|
+
const pick = (provider, id, start) => id && ID.test(id) ? {
|
|
55
|
+
provider,
|
|
56
|
+
id,
|
|
57
|
+
...start ? { start } : {}
|
|
58
|
+
} : null;
|
|
59
|
+
switch (host) {
|
|
60
|
+
case "youtube.com":
|
|
61
|
+
case "youtube-nocookie.com":
|
|
62
|
+
if (path[0] === "watch") return pick("youtube", url.searchParams.get("v") ?? void 0, startOf(url.searchParams));
|
|
63
|
+
if (path[0] === "embed" || path[0] === "shorts" || path[0] === "live") return pick("youtube", path[1], startOf(url.searchParams));
|
|
64
|
+
return null;
|
|
65
|
+
case "youtu.be": return pick("youtube", path[0], startOf(url.searchParams));
|
|
66
|
+
case "vimeo.com": return pick("vimeo", path.find((p) => /^\d+$/.test(p)));
|
|
67
|
+
case "player.vimeo.com": return path[0] === "video" ? pick("vimeo", path[1]) : null;
|
|
68
|
+
case "twitter.com":
|
|
69
|
+
case "x.com": return path[1] === "status" ? pick("x", path[2]) : null;
|
|
70
|
+
case "instagram.com": return path[0] === "p" || path[0] === "reel" ? pick("instagram", path[1]) : null;
|
|
71
|
+
case "open.spotify.com": {
|
|
72
|
+
const [kind, id] = (path[0] === "embed" ? path.slice(1) : path).filter((p) => !p.startsWith("intl-"));
|
|
73
|
+
return kind && [
|
|
74
|
+
"track",
|
|
75
|
+
"album",
|
|
76
|
+
"playlist",
|
|
77
|
+
"episode",
|
|
78
|
+
"show"
|
|
79
|
+
].includes(kind) && id && ID.test(id) ? {
|
|
80
|
+
provider: "spotify",
|
|
81
|
+
id: `${kind}/${id}`
|
|
82
|
+
} : null;
|
|
83
|
+
}
|
|
84
|
+
case "podcasts.apple.com": {
|
|
85
|
+
const show = path.find((p) => /^id\d+$/.test(p));
|
|
86
|
+
const episode = url.searchParams.get("i");
|
|
87
|
+
return show ? pick("apple-podcasts", episode ? `${show}-${episode}` : show) : null;
|
|
88
|
+
}
|
|
89
|
+
default: return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** 描画の iframe の URL(サービスと ID から組み立てる、X と Instagram は埋め込みのページ) */
|
|
93
|
+
function embedSrcOf(target) {
|
|
94
|
+
const id = encodeURIComponent(target.id).replaceAll("%2F", "/");
|
|
95
|
+
switch (target.provider) {
|
|
96
|
+
case "youtube": return `https://www.youtube-nocookie.com/embed/${id}${target.start ? `?start=${target.start}` : ""}`;
|
|
97
|
+
case "vimeo": return `https://player.vimeo.com/video/${id}${target.start ? `#t=${target.start}s` : ""}`;
|
|
98
|
+
case "x": return `https://platform.twitter.com/embed/Tweet.html?id=${id}`;
|
|
99
|
+
case "instagram": return `https://www.instagram.com/p/${id}/embed`;
|
|
100
|
+
case "spotify": return `https://open.spotify.com/embed/${id}`;
|
|
101
|
+
case "apple-podcasts": {
|
|
102
|
+
const [show, episode] = target.id.split("-");
|
|
103
|
+
return `https://embed.podcasts.apple.com/podcast/${encodeURIComponent(show ?? "")}${episode ? `?i=${encodeURIComponent(episode)}` : ""}`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// ../rich-text/src/library.ts
|
|
20
108
|
/** 注のコンポーネントの名前(本文からの算出 citesOf が参照) */
|
|
21
109
|
const CITE = "cite";
|
|
22
|
-
const https = z.string().regex(/^https:\/\//,
|
|
23
|
-
const caption = z.string().min(1,
|
|
110
|
+
const https = z.string().regex(/^https:\/\//, richTextProblemText("url_https"));
|
|
111
|
+
const caption = z.string().min(1, richTextProblemText("caption_missing"));
|
|
24
112
|
const datum = z.object({
|
|
25
113
|
label: z.string(),
|
|
26
114
|
value: z.number()
|
|
@@ -80,7 +168,7 @@ const CORE_COMPONENTS = [
|
|
|
80
168
|
inline: true,
|
|
81
169
|
description: componentText("citeDescription"),
|
|
82
170
|
example: componentText("citeExample"),
|
|
83
|
-
props: () => z.object({ id: z.string().min(1,
|
|
171
|
+
props: () => z.object({ id: z.string().min(1, richTextProblemText("cite_source_missing")) })
|
|
84
172
|
},
|
|
85
173
|
{
|
|
86
174
|
name: "pending",
|
|
@@ -100,7 +188,7 @@ const CORE_COMPONENTS = [
|
|
|
100
188
|
}] }),
|
|
101
189
|
from: (_, content) => ({ text: content[0]?.type === "paragraph" ? plain(content[0].content) : "" })
|
|
102
190
|
},
|
|
103
|
-
props: () => z.object({ text: z.string().min(1,
|
|
191
|
+
props: () => z.object({ text: z.string().min(1, richTextProblemText("speech_missing")) })
|
|
104
192
|
},
|
|
105
193
|
{
|
|
106
194
|
name: "chart",
|
|
@@ -131,8 +219,8 @@ const CORE_COMPONENTS = [
|
|
|
131
219
|
})
|
|
132
220
|
},
|
|
133
221
|
props: () => z.object({
|
|
134
|
-
source: z.string().min(1,
|
|
135
|
-
alt: z.string().min(1,
|
|
222
|
+
source: z.string().min(1, richTextProblemText("diagram_source_missing")),
|
|
223
|
+
alt: z.string().min(1, richTextProblemText("diagram_alt_missing")),
|
|
136
224
|
caption
|
|
137
225
|
})
|
|
138
226
|
},
|
|
@@ -143,18 +231,18 @@ const CORE_COMPONENTS = [
|
|
|
143
231
|
markdown: {
|
|
144
232
|
to: (p) => ({ content: p.items.map((i) => ({
|
|
145
233
|
type: "image",
|
|
146
|
-
|
|
234
|
+
file: i.file,
|
|
147
235
|
...i.caption ? { caption: i.caption } : {}
|
|
148
236
|
})) }),
|
|
149
237
|
from: (_, content) => ({ items: content.flatMap((b) => b.type === "image" ? [{
|
|
150
|
-
|
|
238
|
+
file: b.file,
|
|
151
239
|
...b.caption ? { caption: b.caption } : {}
|
|
152
240
|
}] : []) })
|
|
153
241
|
},
|
|
154
242
|
props: (media) => z.object({ items: z.array(z.object({
|
|
155
|
-
media,
|
|
243
|
+
file: media,
|
|
156
244
|
caption: z.string().optional()
|
|
157
|
-
})).min(2,
|
|
245
|
+
})).min(2, richTextProblemText("gallery_min")) })
|
|
158
246
|
},
|
|
159
247
|
{
|
|
160
248
|
name: "link-card",
|
|
@@ -174,7 +262,7 @@ const CORE_COMPONENTS = [
|
|
|
174
262
|
}).filter((e) => typeof e[1] === "string" && e[1] !== "")),
|
|
175
263
|
content: image ? [{
|
|
176
264
|
type: "image",
|
|
177
|
-
|
|
265
|
+
file: image
|
|
178
266
|
}] : []
|
|
179
267
|
};
|
|
180
268
|
},
|
|
@@ -187,18 +275,18 @@ const CORE_COMPONENTS = [
|
|
|
187
275
|
"desc"
|
|
188
276
|
]),
|
|
189
277
|
...attrs["fetched-at"] ? { fetchedAt: attrs["fetched-at"] } : {},
|
|
190
|
-
...content[0]?.type === "image" ? { image: content[0].
|
|
278
|
+
...content[0]?.type === "image" ? { image: content[0].file } : {}
|
|
191
279
|
})
|
|
192
280
|
},
|
|
193
281
|
props: (media) => z.union([z.object({
|
|
194
282
|
href: https,
|
|
195
|
-
title: z.string().min(1,
|
|
283
|
+
title: z.string().min(1, richTextProblemText("link_title_missing")),
|
|
196
284
|
site: z.string().optional(),
|
|
197
285
|
desc: z.string().optional(),
|
|
198
286
|
image: media.optional(),
|
|
199
287
|
fetchedAt: z.string().optional()
|
|
200
288
|
}), z.object({
|
|
201
|
-
ref: z.string().regex(/^[\w-]+\/[\w-]+$/,
|
|
289
|
+
ref: z.string().regex(/^[\w-]+\/[\w-]+$/, richTextProblemText("link_ref_format")),
|
|
202
290
|
title: z.string().optional(),
|
|
203
291
|
site: z.string().optional(),
|
|
204
292
|
desc: z.string().optional(),
|
|
@@ -237,7 +325,7 @@ const CORE_COMPONENTS = [
|
|
|
237
325
|
},
|
|
238
326
|
props: () => z.object({
|
|
239
327
|
provider: z.enum(EMBED_PROVIDERS),
|
|
240
|
-
id: z.string().regex(/^[\w-]+(\/[\w-]+)?$/,
|
|
328
|
+
id: z.string().regex(/^[\w-]+(\/[\w-]+)?$/, richTextProblemText("embed_id_invalid")),
|
|
241
329
|
url: https,
|
|
242
330
|
width: z.number().int().positive().optional(),
|
|
243
331
|
height: z.number().int().positive().optional(),
|
|
@@ -280,7 +368,7 @@ const CORE_COMPONENTS = [
|
|
|
280
368
|
label: z.string().optional(),
|
|
281
369
|
items: z.array(z.object({
|
|
282
370
|
href: https,
|
|
283
|
-
title: z.string().min(1,
|
|
371
|
+
title: z.string().min(1, richTextProblemText("link_title_missing")),
|
|
284
372
|
site: z.string().optional()
|
|
285
373
|
}))
|
|
286
374
|
})
|
|
@@ -288,7 +376,7 @@ const CORE_COMPONENTS = [
|
|
|
288
376
|
];
|
|
289
377
|
/** 名前から核のコンポーネント(なければ undefined) */
|
|
290
378
|
const coreComponentOf = (name) => CORE_COMPONENTS.find((c) => c.name === name);
|
|
291
|
-
// ../
|
|
379
|
+
// ../rich-text/src/declared.ts
|
|
292
380
|
const NAME = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
293
381
|
const KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
294
382
|
const propSchema = z.lazy(() => z.object({
|
|
@@ -304,55 +392,55 @@ const propSchema = z.lazy(() => z.object({
|
|
|
304
392
|
description: z.string().optional(),
|
|
305
393
|
enum: z.array(z.string().min(1)).min(1).optional(),
|
|
306
394
|
items: propSchema.optional(),
|
|
307
|
-
properties: z.record(z.string().regex(KEY,
|
|
395
|
+
properties: z.record(z.string().regex(KEY, richTextProblemText("prop_key_format")), propSchema).optional(),
|
|
308
396
|
required: z.array(z.string()).optional()
|
|
309
397
|
}).strict().superRefine((p, ctx) => {
|
|
310
398
|
if (p.enum && p.type !== "string") ctx.addIssue({
|
|
311
399
|
code: "custom",
|
|
312
|
-
message:
|
|
400
|
+
message: richTextProblemText("prop_enum_string"),
|
|
313
401
|
path: ["enum"]
|
|
314
402
|
});
|
|
315
403
|
if (p.type === "array" !== (p.items !== void 0)) ctx.addIssue({
|
|
316
404
|
code: "custom",
|
|
317
|
-
message:
|
|
405
|
+
message: richTextProblemText("prop_items"),
|
|
318
406
|
path: ["items"]
|
|
319
407
|
});
|
|
320
408
|
if ((p.properties || p.required) && p.type !== "object") ctx.addIssue({
|
|
321
409
|
code: "custom",
|
|
322
|
-
message:
|
|
410
|
+
message: richTextProblemText("prop_properties_object"),
|
|
323
411
|
path: ["properties"]
|
|
324
412
|
});
|
|
325
413
|
for (const key of p.required ?? []) if (!p.properties?.[key]) ctx.addIssue({
|
|
326
414
|
code: "custom",
|
|
327
|
-
message:
|
|
415
|
+
message: richTextProblemText("prop_required_missing", { key }),
|
|
328
416
|
path: ["required"]
|
|
329
417
|
});
|
|
330
418
|
}));
|
|
331
419
|
const declaredComponent = z.object({
|
|
332
|
-
name: z.string().regex(NAME,
|
|
333
|
-
label: z.string().min(1,
|
|
420
|
+
name: z.string().regex(NAME, richTextProblemText("component_name_format")),
|
|
421
|
+
label: z.string().min(1, richTextProblemText("component_label_missing")),
|
|
334
422
|
description: z.string().optional(),
|
|
335
423
|
inline: z.boolean().optional(),
|
|
336
424
|
props: z.object({
|
|
337
425
|
type: z.literal("object"),
|
|
338
|
-
properties: z.record(z.string().regex(KEY,
|
|
426
|
+
properties: z.record(z.string().regex(KEY, richTextProblemText("prop_key_format")), propSchema),
|
|
339
427
|
required: z.array(z.string()).optional()
|
|
340
428
|
}).strict()
|
|
341
429
|
}).strict().superRefine((d, ctx) => {
|
|
342
430
|
if (coreComponentOf(d.name) || RESERVED_BLOCK_NAMES.has(d.name) || RESERVED_INLINE_NAMES.has(d.name)) ctx.addIssue({
|
|
343
431
|
code: "custom",
|
|
344
|
-
message:
|
|
432
|
+
message: richTextProblemText("component_name_reserved", { name: d.name }),
|
|
345
433
|
path: ["name"]
|
|
346
434
|
});
|
|
347
435
|
for (const key of d.props.required ?? []) if (!d.props.properties[key]) ctx.addIssue({
|
|
348
436
|
code: "custom",
|
|
349
|
-
message:
|
|
437
|
+
message: richTextProblemText("prop_required_missing", { key }),
|
|
350
438
|
path: ["props", "required"]
|
|
351
439
|
});
|
|
352
440
|
if (d.inline) {
|
|
353
441
|
for (const [key, p] of Object.entries(d.props.properties)) if (p.type !== "string") ctx.addIssue({
|
|
354
442
|
code: "custom",
|
|
355
|
-
message:
|
|
443
|
+
message: richTextProblemText("inline_prop_string", { key }),
|
|
356
444
|
path: [
|
|
357
445
|
"props",
|
|
358
446
|
"properties",
|
|
@@ -367,7 +455,7 @@ const declaredComponentsSchema = z.array(declaredComponent).superRefine((list, c
|
|
|
367
455
|
list.forEach((d, i) => {
|
|
368
456
|
if (seen.has(d.name)) ctx.addIssue({
|
|
369
457
|
code: "custom",
|
|
370
|
-
message:
|
|
458
|
+
message: richTextProblemText("component_name_duplicate", { name: d.name }),
|
|
371
459
|
path: [i, "name"]
|
|
372
460
|
});
|
|
373
461
|
seen.add(d.name);
|
|
@@ -375,11 +463,11 @@ const declaredComponentsSchema = z.array(declaredComponent).superRefine((list, c
|
|
|
375
463
|
});
|
|
376
464
|
/** 1つの引数の検査(label はメッセージの項目名) */
|
|
377
465
|
function propZod(p, label) {
|
|
378
|
-
const wrong = { error: (iss) => iss.input === void 0 ?
|
|
466
|
+
const wrong = { error: (iss) => iss.input === void 0 ? richTextProblemText("prop_missing", { label }) : richTextProblemText("prop_shape", { label }) };
|
|
379
467
|
switch (p.type) {
|
|
380
468
|
case "string": return p.enum ? z.enum(p.enum, wrong) : z.string(wrong);
|
|
381
469
|
case "number": return z.number(wrong);
|
|
382
|
-
case "integer": return z.number(wrong).int(
|
|
470
|
+
case "integer": return z.number(wrong).int(richTextProblemText("prop_integer", { label }));
|
|
383
471
|
case "boolean": return z.boolean(wrong);
|
|
384
472
|
case "array": return z.array(propZod(p.items, label), wrong);
|
|
385
473
|
case "object": return objectZod(p.properties ?? {}, p.required ?? [], wrong);
|
|
@@ -391,7 +479,7 @@ const propsCache = /* @__PURE__ */ new WeakMap();
|
|
|
391
479
|
/** 宣言した部品の引数の検査(宣言ごとに作成を再利用) */
|
|
392
480
|
function declaredPropsZod(d) {
|
|
393
481
|
let schema = propsCache.get(d);
|
|
394
|
-
if (!schema) propsCache.set(d, schema = objectZod(d.props.properties, d.props.required ?? [], { error: () =>
|
|
482
|
+
if (!schema) propsCache.set(d, schema = objectZod(d.props.properties, d.props.required ?? [], { error: () => richTextProblemText("component_props_shape", { label: d.label }) }));
|
|
395
483
|
return schema;
|
|
396
484
|
}
|
|
397
|
-
export { coreComponentOf as a, CORE_COMPONENTS as i, declaredPropsZod as n, CITE as r, declaredComponentsSchema as t };
|
|
485
|
+
export { coreComponentOf as a, embedSrcOf as c, CORE_COMPONENTS as i, richTextProblemText as l, declaredPropsZod as n, EMBED_PROVIDERS as o, CITE as r, embedOfUrl as s, declaredComponentsSchema as t };
|