@smartdoca/doca-easy-qrcode-plugin 0.1.0 → 0.1.1
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.md +2 -2
- package/dist/server.js +2 -2
- package/manifest.json +2 -2
- package/package.json +1 -1
- package/web/index.js +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
npm 包:`@smartdoca/doca-easy-qrcode-plugin`。入口使用二维码 SVG 图标。
|
|
4
4
|
|
|
5
|
-
插件 ID:`doca.
|
|
5
|
+
插件 ID:`doca.easy.qrcode`。主页入口卡片、全局更多菜单、文档工具栏均点击后打开二维码弹框卡片。
|
|
6
6
|
|
|
7
7
|
弹框打开时读取当前完整页面 URL,包括查询参数和 Doca 哈希路由。编辑链接后自动实时更新二维码,无需点击生成按钮;输入期间保留上一张预览,并禁用旧结果的复制/下载。输入不完整或无效时明确提示,修正后自动更新。
|
|
8
8
|
|
|
@@ -12,6 +12,6 @@ npm 包:`@smartdoca/doca-easy-qrcode-plugin`。入口使用二维码 SVG 图
|
|
|
12
12
|
|
|
13
13
|
使用 SDK 的 `host.ui.openView` 打开弹框。主页入口与弹框内容是独立视图;没有业务持久化、外部 API 或文件库写入,卸载为空操作。
|
|
14
14
|
|
|
15
|
-
版本 0.1.
|
|
15
|
+
版本 0.1.1,`sdkRange: "^0.1.9"`、`doca.storage: "host"`、`dataVersion: "2"`。随包提供服务端和 Web 入口 `.d.ts`。
|
|
16
16
|
|
|
17
17
|
在仓库根目录执行 `npm run build --workspace qrcode`、`node scripts/release.mjs qrcode`。发布脚本拒绝覆盖同版本归档,旧 2.0.0 包保持不变。
|
package/dist/server.js
CHANGED
|
@@ -425,8 +425,8 @@ function definePlugin(plugin) {
|
|
|
425
425
|
// qrcode/manifest.json
|
|
426
426
|
var manifest_default = {
|
|
427
427
|
schemaVersion: 1,
|
|
428
|
-
id: "doca.
|
|
429
|
-
version: "0.1.
|
|
428
|
+
id: "doca.easy.qrcode",
|
|
429
|
+
version: "0.1.1",
|
|
430
430
|
displayName: "QR code / \u4E8C\u7EF4\u7801",
|
|
431
431
|
sdkRange: "^0.1.9"
|
|
432
432
|
};
|
package/manifest.json
CHANGED
package/package.json
CHANGED
package/web/index.js
CHANGED
|
@@ -12,7 +12,7 @@ Minimum version required to store current data is: `+i+`.
|
|
|
12
12
|
@container (max-width:420px){.ep-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.ep-head{align-items:flex-start}.ep-root h1{font-size:24px}}
|
|
13
13
|
@media(max-width:600px){.ep-root{padding:18px;border-radius:15px}.ep-page{margin:12px;padding:20px}.ep-search{flex-wrap:wrap}.ep-search input{min-width:160px}}
|
|
14
14
|
@media(prefers-reduced-motion:reduce){.ep-root *{animation:none!important;transition:none!important}}
|
|
15
|
-
`;var oe=(r,e,t)=>r==="zh"?e:t;function Ot(r,e){let t=r.React;function n({children:i,className:s=""}){let a=r.useEnvironment();return t.createElement("section",{className:`ep-root ${s}`,"data-theme":a.theme,lang:a.locale==="zh"?"zh-CN":"en"},t.createElement("style",null,Jt),i)}function o(i,s,a){let l=r.useEnvironment().locale,[u,c]=t.useState(s),[m,d]=t.useState(!1),[B,x]=t.useState(""),C=t.useRef({value:s,revision:0}),A=t.useRef(!1),b=t.useRef(!1),R=t.useRef(async()=>{}),P=t.useRef(null),M=t.useRef(""),v=t.useRef(null),E=w=>{if(!Number.isInteger(w.revision)||w.revision<0||(w.revision===0?w.value!==null:!a(w.value)))throw Error(oe(l,"\u4FDD\u5B58\u7684\u8BBE\u7F6E\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002","Saved settings could not be read. Contact your administrator."));let h=w.revision===0?s:w.value;JSON.stringify(C.current.value)!==JSON.stringify(h)&&c(h),C.current={value:h,revision:w.revision}};return t.useEffect(()=>{b.current=!0;let w,h=null,N=async(Y=!1)=>{if(A.current||!b.current)return;v.current?.abort();let ie=new AbortController;v.current=ie;try{let we=await r.request(`/preferences?name=${encodeURIComponent(i)}`,{signal:ie.signal});!ie.signal.aborted&&b.current&&(E(we),d(!0),Y||x(""))}catch(we){!ie.signal.aborted&&b.current&&(d(!1),x(we.message))}};R.current=N;let I=Y=>{Y.detail===M.current&&N()},L=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("doca.everyday.preference",I),document.addEventListener("visibilitychange",L),r.platform.users.me().then(async Y=>{b.current&&(M.current=`${e}:${Y.id}:${i}`,typeof BroadcastChannel<"u"&&(h=new BroadcastChannel(`doca.everyday.${M.current}`),P.current=h,h.onmessage=()=>{N()}),await N(),b.current&&(w=window.setInterval(L,15e3)))}).catch(()=>{b.current&&x(oe(l,"\u65E0\u6CD5\u8F7D\u5165\u5F53\u524D\u7528\u6237\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u540E\u91CD\u8BD5\u3002","Could not load your settings. Sign in again."))}),()=>{b.current=!1,v.current?.abort(),clearInterval(w),h?.close(),P.current=null,window.removeEventListener("doca.everyday.preference",I),document.removeEventListener("visibilitychange",L)}},[i]),[u,async w=>{if(!m||A.current||!b.current)return!1;let h=typeof w=="function"?w(C.current.value):w;if(!a(h))throw Error("Invalid preference");if(JSON.stringify(h)===JSON.stringify(C.current.value))return!0;A.current=!0,d(!1),v.current?.abort();let N=new AbortController;v.current=N;let I=!1;try{let L=await r.request("/preferences",{method:"POST",signal:N.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,value:h,revision:C.current.revision})});b.current&&!N.signal.aborted&&(E(L),x(""),I=!0)}catch(L){b.current&&!N.signal.aborted&&x(L.message)}finally{A.current=!1,b.current&&(I?(d(!0),window.dispatchEvent(new CustomEvent("doca.everyday.preference",{detail:M.current})),P.current?.postMessage("reload")):await R.current(!0))}return I},m,B]}return{Frame:n,usePreference:o}}function Kt(r){let e=r.trim();if(!e||e.length>1800)throw Error("\u8BF7\u8F93\u5165\u4E0D\u8D85\u8FC7 1800 \u4E2A\u5B57\u7B26\u7684\u94FE\u63A5\u3002");let t;try{t=new URL(e)}catch{throw Error("\u8BF7\u8F93\u5165\u5B8C\u6574\u94FE\u63A5\uFF0C\u4EE5 https:// \u6216 http:// \u5F00\u5934\u3002")}if(!["https:","http:"].includes(t.protocol)||!t.hostname||t.username||t.password)throw Error("\u4EC5\u652F\u6301\u4E0D\u542B\u8D26\u53F7\u5BC6\u7801\u7684 HTTP / HTTPS \u94FE\u63A5\u3002");let n=t.href;if(new TextEncoder().encode(n).byteLength>2200)throw Error("\u94FE\u63A5\u8FC7\u957F\uFF0C\u65E0\u6CD5\u751F\u6210\u6613\u626B\u63CF\u7684\u4E8C\u7EF4\u7801\u3002");return n}var T={schemaVersion:1,id:"doca.
|
|
15
|
+
`;var oe=(r,e,t)=>r==="zh"?e:t;function Ot(r,e){let t=r.React;function n({children:i,className:s=""}){let a=r.useEnvironment();return t.createElement("section",{className:`ep-root ${s}`,"data-theme":a.theme,lang:a.locale==="zh"?"zh-CN":"en"},t.createElement("style",null,Jt),i)}function o(i,s,a){let l=r.useEnvironment().locale,[u,c]=t.useState(s),[m,d]=t.useState(!1),[B,x]=t.useState(""),C=t.useRef({value:s,revision:0}),A=t.useRef(!1),b=t.useRef(!1),R=t.useRef(async()=>{}),P=t.useRef(null),M=t.useRef(""),v=t.useRef(null),E=w=>{if(!Number.isInteger(w.revision)||w.revision<0||(w.revision===0?w.value!==null:!a(w.value)))throw Error(oe(l,"\u4FDD\u5B58\u7684\u8BBE\u7F6E\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002","Saved settings could not be read. Contact your administrator."));let h=w.revision===0?s:w.value;JSON.stringify(C.current.value)!==JSON.stringify(h)&&c(h),C.current={value:h,revision:w.revision}};return t.useEffect(()=>{b.current=!0;let w,h=null,N=async(Y=!1)=>{if(A.current||!b.current)return;v.current?.abort();let ie=new AbortController;v.current=ie;try{let we=await r.request(`/preferences?name=${encodeURIComponent(i)}`,{signal:ie.signal});!ie.signal.aborted&&b.current&&(E(we),d(!0),Y||x(""))}catch(we){!ie.signal.aborted&&b.current&&(d(!1),x(we.message))}};R.current=N;let I=Y=>{Y.detail===M.current&&N()},L=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("doca.everyday.preference",I),document.addEventListener("visibilitychange",L),r.platform.users.me().then(async Y=>{b.current&&(M.current=`${e}:${Y.id}:${i}`,typeof BroadcastChannel<"u"&&(h=new BroadcastChannel(`doca.everyday.${M.current}`),P.current=h,h.onmessage=()=>{N()}),await N(),b.current&&(w=window.setInterval(L,15e3)))}).catch(()=>{b.current&&x(oe(l,"\u65E0\u6CD5\u8F7D\u5165\u5F53\u524D\u7528\u6237\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u540E\u91CD\u8BD5\u3002","Could not load your settings. Sign in again."))}),()=>{b.current=!1,v.current?.abort(),clearInterval(w),h?.close(),P.current=null,window.removeEventListener("doca.everyday.preference",I),document.removeEventListener("visibilitychange",L)}},[i]),[u,async w=>{if(!m||A.current||!b.current)return!1;let h=typeof w=="function"?w(C.current.value):w;if(!a(h))throw Error("Invalid preference");if(JSON.stringify(h)===JSON.stringify(C.current.value))return!0;A.current=!0,d(!1),v.current?.abort();let N=new AbortController;v.current=N;let I=!1;try{let L=await r.request("/preferences",{method:"POST",signal:N.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,value:h,revision:C.current.revision})});b.current&&!N.signal.aborted&&(E(L),x(""),I=!0)}catch(L){b.current&&!N.signal.aborted&&x(L.message)}finally{A.current=!1,b.current&&(I?(d(!0),window.dispatchEvent(new CustomEvent("doca.everyday.preference",{detail:M.current})),P.current?.postMessage("reload")):await R.current(!0))}return I},m,B]}return{Frame:n,usePreference:o}}function Kt(r){let e=r.trim();if(!e||e.length>1800)throw Error("\u8BF7\u8F93\u5165\u4E0D\u8D85\u8FC7 1800 \u4E2A\u5B57\u7B26\u7684\u94FE\u63A5\u3002");let t;try{t=new URL(e)}catch{throw Error("\u8BF7\u8F93\u5165\u5B8C\u6574\u94FE\u63A5\uFF0C\u4EE5 https:// \u6216 http:// \u5F00\u5934\u3002")}if(!["https:","http:"].includes(t.protocol)||!t.hostname||t.username||t.password)throw Error("\u4EC5\u652F\u6301\u4E0D\u542B\u8D26\u53F7\u5BC6\u7801\u7684 HTTP / HTTPS \u94FE\u63A5\u3002");let n=t.href;if(new TextEncoder().encode(n).byteLength>2200)throw Error("\u94FE\u63A5\u8FC7\u957F\uFF0C\u65E0\u6CD5\u751F\u6210\u6613\u626B\u63CF\u7684\u4E8C\u7EF4\u7801\u3002");return n}var T={schemaVersion:1,id:"doca.easy.qrcode",version:"0.1.1",displayName:"QR code / \u4E8C\u7EF4\u7801",sdkRange:"^0.1.9"};var He=`.qrcode-card{max-width:510px}.qrcode-actions{margin-top:15px;justify-content:center}.qrcode-actions a{text-decoration:none;color:white}.qrcode-image{margin:22px auto 12px;padding:14px;border:1px solid var(--ep-line);border-radius:16px;width:270px;max-width:100%;background:white}.qrcode-image img{display:block;width:100%;height:auto;image-rendering:pixelated}.qrcode-url{font-size:11px;color:var(--ep-muted);word-break:break-all;text-align:center;max-height:65px;overflow:auto}
|
|
16
16
|
.qrcode-entry-symbol{display:grid;place-items:center;width:54px;height:54px;flex-shrink:0;border-radius:17px;background:var(--ep-tint);color:var(--ep-accent)}.qrcode-entry-symbol svg{display:block;width:32px;height:32px}.qrcode-placeholder svg{display:block;width:64px;height:64px}.qrcode-entry .ep-button{width:100%}
|
|
17
17
|
.qrcode-input-row{display:flex;gap:8px;align-items:center}.qrcode-input-row input{flex:1;width:0}.qrcode-input-row .qrcode-refresh{width:42px;height:42px;padding:0;display:flex;align-items:center;justify-content:center;flex:0 0 42px}.qrcode-refresh svg{display:block;width:20px;height:20px;flex:0 0 20px}.qrcode-refresh:active{transform:rotate(25deg)}.qrcode-feedback{min-height:26px;padding-top:5px}.qrcode-feedback .ep-error{margin:0}.qrcode-image{margin-top:10px}.qrcode-image[data-pending=true]{opacity:.65}.qrcode-actions a[aria-disabled=true]{opacity:.5;pointer-events:none}.qrcode-placeholder{width:270px;height:270px;max-width:100%;margin:10px auto 12px;display:grid;place-items:center;font-size:64px;color:var(--ep-line);border:1px solid var(--ep-line);border-radius:16px}
|
|
18
18
|
|