@riebeckite/plugin-share 0.0.27 → 0.0.29
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 +10 -10
- package/dist/components/share-controls.js +1 -8
- package/dist/index.d.ts +1 -15
- package/dist/index.js +19 -15
- package/dist/src/data.d.ts +16 -0
- package/package.json +3 -3
package/README_ja.md
CHANGED
|
@@ -94,16 +94,16 @@ import "@riebeckite/plugin-share/style.css";
|
|
|
94
94
|
|
|
95
95
|
## エクスポート
|
|
96
96
|
|
|
97
|
-
- `share(options?)
|
|
98
|
-
- `sharePlugin
|
|
99
|
-
- `resolveShareOptions(options?)
|
|
100
|
-
- `validateShareOptions(options?)
|
|
101
|
-
- `buildAbsoluteUrl(config, permalink)
|
|
102
|
-
- `normalizeMastodonInstance(value)
|
|
103
|
-
- `buildShareUrl(service, target, instance?)
|
|
104
|
-
- `buildShareLinks(options, target)
|
|
105
|
-
- `renderShareControls(options, target)
|
|
106
|
-
- `initShare()
|
|
97
|
+
- `share(options?)`:プラグインファクトリ
|
|
98
|
+
- `sharePlugin`:`share` のエイリアス
|
|
99
|
+
- `resolveShareOptions(options?)`:オプションの既定値を適用する
|
|
100
|
+
- `validateShareOptions(options?)`:実行時オプションを検証する
|
|
101
|
+
- `buildAbsoluteUrl(config, permalink)`:ノート URL を絶対 URL に解決する
|
|
102
|
+
- `normalizeMastodonInstance(value)`:インスタンスをホスト名に正規化する
|
|
103
|
+
- `buildShareUrl(service, target, instance?)`:1 サービスの URL を組み立てる
|
|
104
|
+
- `buildShareLinks(options, target)`:リンクを持つサービスをすべて組み立てる
|
|
105
|
+
- `renderShareControls(options, target)`:コントロールの HTML を生成する
|
|
106
|
+
- `initShare()`:ブラウザ初期化関数(`@riebeckite/plugin-share/client` からも
|
|
107
107
|
読み込める)
|
|
108
108
|
- 定数: `SHARE_SERVICES`, `SHARE_ATTRIBUTE`, `SHARE_ROOT_CLASS`,
|
|
109
109
|
`DEFAULT_SHARE_SERVICES`, `DEFAULT_SHARE_LABELS`, `DEFAULT_SHARE_PLACEMENT`
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
import { useArticleContext, useSiteContext } from "@riebeckite/ui";
|
|
3
3
|
import { html } from "hono/html";
|
|
4
4
|
|
|
5
|
-
// index.ts
|
|
6
|
-
import {
|
|
7
|
-
createClientEntry,
|
|
8
|
-
createStyleAsset,
|
|
9
|
-
definePlugin
|
|
10
|
-
} from "@riebeckite/core";
|
|
11
|
-
|
|
12
5
|
// src/services.ts
|
|
13
6
|
function buildAbsoluteUrl(config, pathOrUrl) {
|
|
14
7
|
if (!pathOrUrl) return config.site.baseUrl;
|
|
@@ -145,7 +138,7 @@ function normalizeNonEmpty(value, fallback) {
|
|
|
145
138
|
import { escapeHtml, escapeHtmlAttribute } from "@riebeckite/core";
|
|
146
139
|
var SHARE_ROOT_CLASS = "rr-share";
|
|
147
140
|
|
|
148
|
-
//
|
|
141
|
+
// src/data.ts
|
|
149
142
|
var getShareLinks = ({ entry, site, options }) => {
|
|
150
143
|
const resolved = resolveShareOptions(options);
|
|
151
144
|
const url = buildAbsoluteUrl(site, entry.permalink);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
import { type PluginDataHelper, type PublicContentEntry, type ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
1
|
import type { ShareOptions } from "./src/types.js";
|
|
3
2
|
export type { ShareControlsProps } from "./components/share-controls.js";
|
|
4
3
|
export { default as ShareControls } from "./components/share-controls.js";
|
|
5
4
|
export { initShare } from "./src/client.js";
|
|
5
|
+
export { getShareLinks, type ShareLinksData, } from "./src/data.js";
|
|
6
6
|
export { DEFAULT_SHARE_ARIA_LABEL, DEFAULT_SHARE_COPIED_LABEL, DEFAULT_SHARE_COPY_FAILED_LABEL, DEFAULT_SHARE_LABELS, DEFAULT_SHARE_SERVICES, resolveShareOptions, validateShareOptions, } from "./src/options.js";
|
|
7
7
|
export { renderShareControls, SHARE_ATTRIBUTE, SHARE_ROOT_CLASS, } from "./src/render.js";
|
|
8
8
|
export { buildAbsoluteUrl, buildShareLinks, buildShareUrl, normalizeMastodonInstance, type ShareTarget, } from "./src/services.js";
|
|
9
9
|
export type { ResolvedShareOptions, ShareLink, ShareOptions, ShareService, } from "./src/types.js";
|
|
10
10
|
export { SHARE_SERVICES } from "./src/types.js";
|
|
11
|
-
export type ShareLinksData = {
|
|
12
|
-
readonly links: readonly import("./src/types.js").ShareLink[];
|
|
13
|
-
readonly copyUrl?: string;
|
|
14
|
-
readonly ariaLabel: string;
|
|
15
|
-
readonly className: string;
|
|
16
|
-
readonly copyLabel: string;
|
|
17
|
-
readonly copiedLabel: string;
|
|
18
|
-
readonly copyFailedLabel: string;
|
|
19
|
-
};
|
|
20
|
-
export declare const getShareLinks: PluginDataHelper<{
|
|
21
|
-
entry: PublicContentEntry;
|
|
22
|
-
site: Pick<ResolvedRiebeckiteConfig, "site">;
|
|
23
|
-
options?: ShareOptions;
|
|
24
|
-
}, ShareLinksData>;
|
|
25
11
|
export declare const SHARE_PLUGIN_NAME = "share";
|
|
26
12
|
/**
|
|
27
13
|
* Per-article share controls.
|
package/dist/index.js
CHANGED
|
@@ -206,6 +206,10 @@ function normalizeNonEmpty(value, fallback) {
|
|
|
206
206
|
return trimmed === "" ? fallback : trimmed;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
// components/share-controls.tsx
|
|
210
|
+
import { useArticleContext, useSiteContext } from "@riebeckite/ui";
|
|
211
|
+
import { html } from "hono/html";
|
|
212
|
+
|
|
209
213
|
// src/render.ts
|
|
210
214
|
import { escapeHtml, escapeHtmlAttribute } from "@riebeckite/core";
|
|
211
215
|
var SHARE_ATTRIBUTE = "data-rr-share";
|
|
@@ -228,9 +232,22 @@ function renderCopyItem(options, target) {
|
|
|
228
232
|
return `<li class="${SHARE_ROOT_CLASS}__item"><button type="button" class="${SHARE_ROOT_CLASS}__button ${SHARE_ROOT_CLASS}__copy" data-rr-share-copy data-share-url="${escapeHtmlAttribute(target.url)}" data-rr-share-copied="${escapeHtmlAttribute(options.copiedLabel)}" data-rr-share-copy-failed="${escapeHtmlAttribute(options.copyFailedLabel)}" hidden>${escapeHtml(options.labels.copy)}</button></li>`;
|
|
229
233
|
}
|
|
230
234
|
|
|
235
|
+
// src/data.ts
|
|
236
|
+
var getShareLinks = ({ entry, site, options }) => {
|
|
237
|
+
const resolved = resolveShareOptions(options);
|
|
238
|
+
const url = buildAbsoluteUrl(site, entry.permalink);
|
|
239
|
+
return {
|
|
240
|
+
links: buildShareLinks(resolved, { url, title: entry.title }),
|
|
241
|
+
...resolved.services.includes("copy") ? { copyUrl: url } : {},
|
|
242
|
+
ariaLabel: resolved.ariaLabel,
|
|
243
|
+
className: resolved.className || SHARE_ROOT_CLASS,
|
|
244
|
+
copyLabel: resolved.labels.copy,
|
|
245
|
+
copiedLabel: resolved.copiedLabel,
|
|
246
|
+
copyFailedLabel: resolved.copyFailedLabel
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
|
|
231
250
|
// components/share-controls.tsx
|
|
232
|
-
import { useArticleContext, useSiteContext } from "@riebeckite/ui";
|
|
233
|
-
import { html } from "hono/html";
|
|
234
251
|
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
|
|
235
252
|
var ShareControls = (async (props) => {
|
|
236
253
|
const site = useSiteContext();
|
|
@@ -349,19 +366,6 @@ function copyWithExecCommand(value) {
|
|
|
349
366
|
}
|
|
350
367
|
|
|
351
368
|
// index.ts
|
|
352
|
-
var getShareLinks = ({ entry, site, options }) => {
|
|
353
|
-
const resolved = resolveShareOptions(options);
|
|
354
|
-
const url = buildAbsoluteUrl(site, entry.permalink);
|
|
355
|
-
return {
|
|
356
|
-
links: buildShareLinks(resolved, { url, title: entry.title }),
|
|
357
|
-
...resolved.services.includes("copy") ? { copyUrl: url } : {},
|
|
358
|
-
ariaLabel: resolved.ariaLabel,
|
|
359
|
-
className: resolved.className || SHARE_ROOT_CLASS,
|
|
360
|
-
copyLabel: resolved.labels.copy,
|
|
361
|
-
copiedLabel: resolved.copiedLabel,
|
|
362
|
-
copyFailedLabel: resolved.copyFailedLabel
|
|
363
|
-
};
|
|
364
|
-
};
|
|
365
369
|
var SHARE_PLUGIN_NAME = "share";
|
|
366
370
|
function share(options = {}) {
|
|
367
371
|
const _resolved = resolveShareOptions(options);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginDataHelper, PublicContentEntry, ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
|
+
import type { ShareLink, ShareOptions } from "./types.js";
|
|
3
|
+
export type ShareLinksData = {
|
|
4
|
+
readonly links: readonly ShareLink[];
|
|
5
|
+
readonly copyUrl?: string;
|
|
6
|
+
readonly ariaLabel: string;
|
|
7
|
+
readonly className: string;
|
|
8
|
+
readonly copyLabel: string;
|
|
9
|
+
readonly copiedLabel: string;
|
|
10
|
+
readonly copyFailedLabel: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const getShareLinks: PluginDataHelper<{
|
|
13
|
+
entry: PublicContentEntry;
|
|
14
|
+
site: Pick<ResolvedRiebeckiteConfig, "site">;
|
|
15
|
+
options?: ShareOptions;
|
|
16
|
+
}, ShareLinksData>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-share",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"hono": "^4.12.25",
|
|
31
|
-
"@riebeckite/core": "0.0.
|
|
32
|
-
"@riebeckite/ui": "0.0.
|
|
31
|
+
"@riebeckite/core": "0.0.29",
|
|
32
|
+
"@riebeckite/ui": "0.0.29"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"tsx": "^4.22.4"
|