@doubao-dev/kit 0.8.0-rc.0 → 0.8.0-rc.11
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/dist/277~0.js +50 -49
- package/dist/assets/web-sdk-debugger/__doubao_web_sdk_native_modules/applet-bridge-module-core.js +1 -1
- package/dist/assets/web-sdk-debugger/assets/framework/doubao-apps-api.template.js +0 -0
- package/dist/assets/web-sdk-debugger/assets/framework/doubao-apps-framework.template.js +0 -0
- package/dist/assets/web-sdk-debugger/chrome-devtools/entrypoints/devtools_app/devtools_app.js +24 -23
- package/dist/assets/web-sdk-debugger/chrome-devtools/panels/wsd-debug/WsdDebug.js +50 -49
- package/dist/assets/web-sdk-debugger/chrome-devtools/panels/wsd-debug/WsdDebugMeta.js +60 -59
- package/dist/assets/web-sdk-debugger/index.html +1 -1
- package/dist/assets/web-sdk-debugger/static/css/index.97f4984ae7.css +1 -0
- package/dist/assets/web-sdk-debugger/static/js/{148.80681ca28e.js → 204.a1a7cafeaf.js} +31 -31
- package/dist/assets/web-sdk-debugger/static/js/async/{web-elements.98d43e1d95.js → web-elements.262cae995c.js} +1 -1
- package/dist/assets/web-sdk-debugger/static/js/async/xmarkdown-deps.ff739dc3dc.js +5 -0
- package/dist/assets/web-sdk-debugger/static/js/async/xmarkdown-deps.ff739dc3dc.js.LICENSE.txt +5 -0
- package/dist/assets/web-sdk-debugger/static/js/{index.3ccc2f978a.js → index.072c936cc9.js} +8 -7
- package/dist/builder/loader/components-loader/index.js +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/sdk.d.ts +98 -28
- package/dist/sdk.js +35 -34
- package/package.json +1 -1
- package/dist/assets/web-sdk-debugger/static/css/index.c3e710420d.css +0 -1
- package/dist/assets/web-sdk-debugger/static/js/async/xmarkdown-deps.6cec36ed6c.js +0 -5
- package/dist/assets/web-sdk-debugger/static/js/async/xmarkdown-deps.6cec36ed6c.js.LICENSE.txt +0 -3
- /package/dist/assets/web-sdk-debugger/static/js/{148.80681ca28e.js.LICENSE.txt → 204.a1a7cafeaf.js.LICENSE.txt} +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"node:module";import{realpathSync as e}from"node:fs";import t from"node:path";import r from"magic-string";import{parseSync as i,simple as o}from"../../../986~0.js";let n=new Set(["@doubao-dev/template","@byted-doubao-apps/template"]),a=new Set([...n].map(e=>`${e}/primitives`)),s=e=>`${e.ctxt??0}:${e.value}`,l={audio:"DoubaoAudio",button:"DoubaoButton",camera:"DoubaoCamera",canvas:"DoubaoCanvas",map:"DoubaoMap","map-marker":"DoubaoMapMarker",markdown:"DoubaoMarkdown","navigation-bar":"DoubaoNavigationBar","long-image":"DoubaoLongImage","movable-area":"DoubaoMovableArea","movable-view":"DoubaoMovableView",popup:"DoubaoPopup",radio:"DoubaoRadio","radio-group":"DoubaoRadioGroup","rich-text":"DoubaoRichText",slider:"DoubaoSlider",switch:"DoubaoSwitch",swiper:"DoubaoSwiper","swiper-item":"DoubaoSwiperItem","picker-column":"DoubaoPickerColumn","picker-divider":"DoubaoPickerDivider","picker-view":"DoubaoPickerView","theme-provider":"DoubaoThemeProvider",video:"DoubaoVideo","web-view":"DoubaoWebView",image:"DoubaoImage",input:"DoubaoInput",list:"DoubaoList","scroll-view":"DoubaoScrollView",svg:"DoubaoSvg",text:"DoubaoText",textarea:"DoubaoTextArea",view:"DoubaoView"};function p(e){return"Identifier"===e.type&&e.value in l?e.value:null}function u(e,t,r,i,o){if("Identifier"!==t.type)return;let n=o(t.span.start-i),a=o(t.span.end-i);e.overwrite(n,a,r)}function c(r){try{return e(r)}catch{return t.resolve(r)}}export default function(e){let t=this.async();try{let{frameworkPackage:d="@byted-doubao-apps/framework",widgetEntryPaths:f=[]}=this.getOptions(),y=new r(e),m=i(e,{syntax:"typescript",tsx:!0,decorators:!0}),g=function(e){let t=0;for(;t<e.length;){let r=e[t];if(" "===r||" "===r||"\n"===r||"\r"===r||"\f"===r){t+=1;continue}if("/"===r&&"/"===e[t+1]){for(t+=2;t<e.length&&"\n"!==e[t];)t+=1;continue}if("/"===r&&"*"===e[t+1]){for(t+=2;t<e.length&&("*"!==e[t]||"/"!==e[t+1]);)t+=1;t<e.length&&(t+=2);continue}break}return Buffer.byteLength(e.slice(0,t))}(e),b=Math.max(0,m.span.start-g),x=function(e){let t=new Map([[0,0]]),r=0,i=0;for(let o of e)r+=Buffer.byteLength(o),i+=o.length,t.set(r,i);return e=>{let r=t.get(e);if(void 0===r)throw Error(`无法将字节偏移量 ${e} 映射为字符串索引`);return r}}(e),h=[];for(let t of function(e,t={}){let r=new Map,i=new Map,l=new Map,p=[],u=new Set;for(let t of e.body)if("ImportDeclaration"===t.type&&!t.typeOnly)for(let e of t.specifiers)"ImportSpecifier"!==e.type||e.isTypeOnly?"ImportNamespaceSpecifier"===e.type&&i.set(s(e.local),{source:t.source.value,name:"*"}):i.set(s(e.local),{source:t.source.value,name:e.imported?.value??e.local.value});function c(e){"Identifier"===e.type?l.delete(s(e)):"MemberExpression"===e.type&&c(e.object)}function d(e,t=new Set){if(t.has(e))return e;switch(t.add(e),e.type){case"Identifier":{let r=l.get(s(e));return r?d(r,t):e}case"MemberExpression":{let r=e.property,i="Identifier"===r.type?r.value:"Computed"===r.type&&"StringLiteral"===r.expression.type?r.expression.value:void 0;if(void 0===i)return e;let o=d(e.object,t);if("ObjectExpression"!==o.type)return e;let n=b(o).get(i);return n?d(n,t):e}case"ParenthesisExpression":case"TsAsExpression":case"TsSatisfiesExpression":case"TsTypeAssertion":case"TsNonNullExpression":return d(e.expression,t);default:return e}}function f(e,t=new Set){if("Identifier"===e.type){if(t.has(s(e)))return;t.add(s(e));let r=i.get(s(e));if(r)return r;let o=d(e);return o!==e?f(o,t):void 0}if("JSXMemberExpression"===e.type||"MemberExpression"===e.type){let r=f(e.object,t);if(r?.name==="*"&&"Identifier"===e.property.type)return{source:r.source,name:e.property.value}}}function y(e,t,r){if(!("span"in e))return;let i=`${e.span.start}:${t}:${r}`;u.has(i)||(u.add(i),p.push({span:e.span,field:t,message:r}))}o(e,{FunctionDeclaration(e){r.set(s(e.identifier),e)},VariableDeclaration(e){if("const"===e.kind)for(let t of e.declarations)"Identifier"===t.id.type&&t.init&&l.set(s(t.id),t.init)}}),o(e,{AssignmentExpression(e){("Identifier"===e.left.type||"MemberExpression"===e.left.type)&&c(e.left)},UpdateExpression(e){c(e.argument)},CallExpression(e){"MemberExpression"===e.callee.type&&"Identifier"===e.callee.property.type&&["push","pop","shift","unshift","splice","fill","copyWithin","reverse","sort"].includes(e.callee.property.value)&&c(e.callee.object)}});let m=new Set,g=new WeakSet;function b(e,t=new Set){let r=new Map,i=d(e);if(t.has(i)||m.has(i)||"ObjectExpression"!==i.type)return g.add(r),r;for(let e of(m.add(i),t.add(i),i.properties))if("SpreadElement"===e.type){let i=d(e.arguments);if("ObjectExpression"!==i.type)r.clear(),g.add(r);else{let e=b(i,new Set(t));for(let[t,i]of(g.has(e)&&(r.clear(),g.add(r)),e))r.set(t,i)}}else"Identifier"===e.type?r.set(e.value,e):"KeyValueProperty"===e.type&&("Identifier"===e.key.type||"StringLiteral"===e.key.type?r.set(e.key.value,e.value):(r.clear(),g.add(r)));return m.delete(i),r}function x(e,t,r=new Set){let i=d(e);if(r.has(i))return;let o=new Set(r).add(i);"ConditionalExpression"===i.type?(x(i.consequent,t,o),x(i.alternate,t,o)):"BinaryExpression"===i.type&&"&&"===i.operator?x(i.right,t,o):"BinaryExpression"===i.type&&("||"===i.operator||"??"===i.operator)?(x(i.left,t,o),x(i.right,t,o)):t(i)}function h(e,t,r){x(e,e=>{if("NullLiteral"!==e.type&&("BooleanLiteral"!==e.type||e.value)&&("text"!==t||"StringLiteral"!==e.type&&"NumericLiteral"!==e.type)){if("JSXElement"===e.type){let r=e.opening.name,i=f(r),o=e.children.some(e=>"JSXText"!==e.type||e.value.trim()),n=i&&a.has(i.source)&&"text"===t&&["Title","Tag"].includes(i.name),s="image"===t&&"Identifier"===r.type&&["image","svg"].includes(r.value);if(!o&&(n||s))return}else if(!["JSXFragment","ArrayExpression","ObjectExpression","BooleanLiteral","StringLiteral","NumericLiteral"].includes(e.type))return;else if("config"===t&&"JSXFragment"!==e.type&&"ArrayExpression"!==e.type)return;y(e,r,`仅支持 ${"text"===t?"string / number / Tag / Title":"image"===t?"image / svg":"标准配置(price 也支持 string / number)"},不支持业务组件、fragment、包装节点或复合 JSX。`)}})}function v(e,t,r=new Set){x(e,e=>{if(r.has(e))return;let i=new Set(r).add(e);if("ArrayExpression"===e.type)for(let r of e.elements)r&&(r.spread?v(r.expression,t,i):x(r.expression,t));else if("CallExpression"===e.type&&"MemberExpression"===e.callee.type&&"Identifier"===e.callee.property.type&&"map"===e.callee.property.value){let r=e.arguments[0]?.expression;r?.type==="ArrowFunctionExpression"&&"BlockStatement"!==r.body.type&&x(r.body,t)}})}if(o(e,{JSXElement(e){let t=f(e.opening.name);if(!t||!(n.has(t.source)&&["ContentCard","CouponCard","TransitCard","CheckoutCard","CompositeCard","PriceActionCard","AskHumanCard","MapCard"].includes(t.name)||a.has(t.source)&&["Title","Tag","Price","Icon","OptionGroup"].includes(t.name)))return;let r=new Map;for(let t of e.opening.attributes)if("SpreadElement"===t.type){let e=d(t.arguments);if("ObjectExpression"!==e.type)r.clear();else{let t=b(e);for(let[e,i]of(g.has(t)&&r.clear(),t))r.set(e,i)}}else if("Identifier"===t.name.type&&t.value){let e=t.value;"JSXExpressionContainer"===e.type&&"JSXEmptyExpression"!==e.expression.type?r.set(t.name.value,e.expression):"StringLiteral"===e.type&&r.set(t.name.value,e)}!function e(t,r,i=r){var o;let n="CheckoutCard"===r?"productItems":"items",a=t.get(n);a&&(o=`${i}.${n}`,v(a,e=>{for(let[t,i]of b(e)){let e=`${o}[].${t}`;"ContentCard"===r&&["title","subtitle","description"].includes(t)||"TransitCard"===r&&"title"===t?h(i,"text",e):"ContentCard"===r&&"thumbnail"===t||"CheckoutCard"===r&&"image"===t?h(i,"image",e):("ContentCard"===r&&"action"===t||"TransitCard"===r&&"price"===t)&&h(i,"config",e)}})),"CompositeCard"===r&&t.has("sections")&&v(t.get("sections"),t=>{let r=b(t),o=r.get("type"),n=o&&d(o),a=r.get("props");if(n?.type==="StringLiteral"&&a){let t={content:"ContentCard",transit:"TransitCard","option-group":"OptionGroup"}[n.value];t&&e(b(a),t,`${i}.sections[${n.value}].props`)}})}(r,t.name)}}),t.checkWidgetRoot){let t=new Set,i=new Set,o=new Set(["@doubao-dev/framework","@byted-doubao-apps/framework"]),a=new Set(["ContentCard","CouponCard","TransitCard","CheckoutCard","CompositeCard","PriceActionCard","AskHumanCard","MapCard"]);function w(e){if(!t.has(e)&&e.body){if(t.add(e),"BlockStatement"!==e.body.type)return void E(e.body);!function e(t){if(t&&"object"==typeof t){if(Array.isArray(t))return void t.forEach(e);if("ReturnStatement"===t.type){t.argument&&E(t.argument);return}["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","MethodProperty","ClassDeclaration","ClassExpression"].includes(String(t.type))||Object.values(t).forEach(e)}}(e.body)}}function E(e){x(e,e=>{if(!i.has(e)&&(i.add(e),"NullLiteral"!==e.type&&("BooleanLiteral"!==e.type||e.value)))if("FunctionExpression"===e.type||"ArrowFunctionExpression"===e.type)w(e);else if("Identifier"===e.type){let t=r.get(s(e));t&&w(t)}else if("CallExpression"===e.type){if("Super"===e.callee.type||"Import"===e.callee.type)return;let t=f(e.callee);if(t?.name==="defineWidget"&&o.has(t.source)){let t=e.arguments[0]?.expression;t&&function(e){let t=d(e),r=b(t).get("render");if(r&&E(r),"ObjectExpression"===t.type)for(let e of t.properties)"MethodProperty"===e.type&&("Identifier"===e.key.type||"StringLiteral"===e.key.type)&&"render"===e.key.value&&w(e)}(t)}else if(t&&["memo","forwardRef"].includes(t.name)&&(o.has(t.source)||["react","@lynx-js/react"].includes(t.source))){let t=e.arguments[0]?.expression;t&&E(t)}else{let t=d(e.callee);if("FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type)w(t);else if("Identifier"===t.type){let e=r.get(s(t));e&&w(e)}}}else if("JSXElement"===e.type){let t=e.opening.name,i=f(t);if(i&&n.has(i.source)&&a.has(i.name))return;if("Identifier"===t.type&&!/^[a-z]/.test(t.value)){let e=r.get(s(t)),i=d(t);if(e)return void w(e);if("FunctionExpression"===i.type||"ArrowFunctionExpression"===i.type||"CallExpression"===i.type)return void E(i)}y(e,"widget.root","Widget 最外层必须直接渲染模板卡片,不能套 view、scroll-view、fragment 或其他包装节点。")}else["JSXFragment","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral"].includes(e.type)&&y(e,"widget.root","Widget 最外层必须直接渲染一张模板卡片。")})}for(let t of e.body)if("ExportDefaultExpression"===t.type)E(t.expression);else if("ExportDefaultDeclaration"===t.type&&"FunctionExpression"===t.decl.type)w(t.decl);else if("ExportNamedDeclaration"===t.type&&!t.source&&!t.typeOnly)for(let e of t.specifiers)"ExportSpecifier"===e.type&&e.exported?.value==="default"&&"Identifier"===e.orig.type&&E(e.orig)}return p}(m,{checkWidgetRoot:f.some(e=>c(e)===c(this.resourcePath))})){let r=x(t.span.start-b),i=e.slice(0,r),o=i.split("\n").length,n=r-i.lastIndexOf("\n");h.push({rule_id:"widget.root"===t.field?"template.root":"template.content",severity:"warning",file:this.resourcePath,line:o,column:n,field:t.field,message:t.message})}let v=this._module;v?.buildInfo&&(v.buildInfo.cardDiagnostics=h);let w=new Set;if(o(m,{JSXOpeningElement(e){let t=p(e.name);if(!t)return;let r=l[t];u(y,e.name,r,b,x),w.add(r)},JSXClosingElement(e){let t=p(e.name);if(!t)return;let r=l[t];u(y,e.name,r,b,x),w.add(r)}}),w.size>0){let e=Array.from(w).map(e=>{let t=e.replace("Doubao","");return`${t} as ${e}`}).join(", "),t=`import { ${e} } from '${d}/components';
|
|
2
|
-
`;
|
|
1
|
+
import"node:module";import{realpathSync as e}from"node:fs";import t from"node:path";import r from"magic-string";import{parseSync as o,simple as i}from"../../../986~0.js";let n=new Set(["@doubao-dev/template","@byted-doubao-apps/template"]),a=new Set([...n].map(e=>`${e}/primitives`)),s=e=>`${e.ctxt??0}:${e.value}`,l={audio:"DoubaoAudio",button:"DoubaoButton",camera:"DoubaoCamera",canvas:"DoubaoCanvas",map:"DoubaoMap","map-marker":"DoubaoMapMarker",markdown:"DoubaoMarkdown","navigation-bar":"DoubaoNavigationBar","long-image":"DoubaoLongImage","movable-area":"DoubaoMovableArea","movable-view":"DoubaoMovableView",popup:"DoubaoPopup",radio:"DoubaoRadio","radio-group":"DoubaoRadioGroup","rich-text":"DoubaoRichText",slider:"DoubaoSlider",switch:"DoubaoSwitch",swiper:"DoubaoSwiper","swiper-item":"DoubaoSwiperItem","picker-column":"DoubaoPickerColumn","picker-divider":"DoubaoPickerDivider","picker-view":"DoubaoPickerView","theme-provider":"DoubaoThemeProvider",video:"DoubaoVideo","web-view":"DoubaoWebView",image:"DoubaoImage",input:"DoubaoInput",list:"DoubaoList","scroll-view":"DoubaoScrollView",svg:"DoubaoSvg",text:"DoubaoText",textarea:"DoubaoTextArea",view:"DoubaoView"};function p(e){return"Identifier"===e.type&&e.value in l?e.value:null}function u(e,t,r,o,i){if("Identifier"!==t.type)return;let n=i(t.span.start-o),a=i(t.span.end-o);e.overwrite(n,a,r)}function c(r){try{return e(r)}catch{return t.resolve(r)}}export default function(e){let t=this.async();try{let{frameworkPackage:d="@byted-doubao-apps/framework",widgetEntryPaths:f=[]}=this.getOptions(),m=new r(e),y=o(e,{syntax:"typescript",tsx:!0,decorators:!0}),g=function(e){let t=0;for(;t<e.length;){let r=e[t];if(" "===r||" "===r||"\n"===r||"\r"===r||"\f"===r){t+=1;continue}if("/"===r&&"/"===e[t+1]){for(t+=2;t<e.length&&"\n"!==e[t];)t+=1;continue}if("/"===r&&"*"===e[t+1]){for(t+=2;t<e.length&&("*"!==e[t]||"/"!==e[t+1]);)t+=1;t<e.length&&(t+=2);continue}break}return Buffer.byteLength(e.slice(0,t))}(e),b=Math.max(0,y.span.start-g),x=function(e){let t=new Map([[0,0]]),r=0,o=0;for(let i of e)r+=Buffer.byteLength(i),o+=i.length,t.set(r,o);return e=>{let r=t.get(e);if(void 0===r)throw Error(`无法将字节偏移量 ${e} 映射为字符串索引`);return r}}(e),h=[],v=new Set;for(let t of function(e,t={}){let r=new Map,o=new Map,l=new Map,p=[],u=new Set;for(let t of e.body)if("ImportDeclaration"===t.type&&!t.typeOnly)for(let e of t.specifiers)"ImportSpecifier"!==e.type||e.isTypeOnly?"ImportDefaultSpecifier"===e.type?o.set(s(e.local),{source:t.source.value,name:"default"}):"ImportNamespaceSpecifier"===e.type&&o.set(s(e.local),{source:t.source.value,name:"*"}):o.set(s(e.local),{source:t.source.value,name:e.imported?.value??e.local.value});function c(e){"Identifier"===e.type?l.delete(s(e)):"MemberExpression"===e.type&&c(e.object)}function d(e,t=new Set){if(t.has(e))return e;switch(t.add(e),e.type){case"Identifier":{let r=l.get(s(e));return r?d(r,t):e}case"MemberExpression":{let r=e.property,o="Identifier"===r.type?r.value:"Computed"===r.type&&"StringLiteral"===r.expression.type?r.expression.value:void 0;if(void 0===o)return e;let i=d(e.object,t);if("ObjectExpression"!==i.type)return e;let n=b(i).get(o);return n?d(n,t):e}case"ParenthesisExpression":case"TsAsExpression":case"TsSatisfiesExpression":case"TsTypeAssertion":case"TsNonNullExpression":return d(e.expression,t);default:return e}}function f(e,t=new Set){if("Identifier"===e.type){if(t.has(s(e)))return;t.add(s(e));let r=o.get(s(e));if(r)return r;let i=d(e);return i!==e?f(i,t):void 0}if("JSXMemberExpression"===e.type||"MemberExpression"===e.type){let r=f(e.object,t);if(r?.name==="*"&&"Identifier"===e.property.type)return{source:r.source,name:e.property.value}}}function m(e,t,r,o){if(!("span"in e))return;let i=`${e.span.start}:${t}:${r}`;u.has(i)||(u.add(i),p.push({span:e.span,field:t,message:r,...o?{ruleId:o}:{}}))}i(e,{FunctionDeclaration(e){r.set(s(e.identifier),e)},VariableDeclaration(e){if("const"===e.kind)for(let t of e.declarations)"Identifier"===t.id.type&&t.init&&l.set(s(t.id),t.init)}}),i(e,{AssignmentExpression(e){("Identifier"===e.left.type||"MemberExpression"===e.left.type)&&c(e.left)},UpdateExpression(e){c(e.argument)},CallExpression(e){"MemberExpression"===e.callee.type&&"Identifier"===e.callee.property.type&&["push","pop","shift","unshift","splice","fill","copyWithin","reverse","sort"].includes(e.callee.property.value)&&c(e.callee.object)}});let y=new Set,g=new WeakSet;function b(e,t=new Set){let r=new Map,o=d(e);if(t.has(o)||y.has(o)||"ObjectExpression"!==o.type)return g.add(r),r;for(let e of(y.add(o),t.add(o),o.properties))if("SpreadElement"===e.type){let o=d(e.arguments);if("ObjectExpression"!==o.type)r.clear(),g.add(r);else{let e=b(o,new Set(t));for(let[t,o]of(g.has(e)&&(r.clear(),g.add(r)),e))r.set(t,o)}}else"Identifier"===e.type?r.set(e.value,e):"KeyValueProperty"===e.type&&("Identifier"===e.key.type||"StringLiteral"===e.key.type?r.set(e.key.value,e.value):(r.clear(),g.add(r)));return y.delete(o),r}function x(e,t,r=new Set){let o=d(e);if(r.has(o))return;let i=new Set(r).add(o);"ConditionalExpression"===o.type?(x(o.consequent,t,i),x(o.alternate,t,i)):"BinaryExpression"===o.type&&"&&"===o.operator?x(o.right,t,i):"BinaryExpression"===o.type&&("||"===o.operator||"??"===o.operator)?(x(o.left,t,i),x(o.right,t,i)):t(o)}function h(e,t,r){x(e,e=>{if("NullLiteral"!==e.type&&("BooleanLiteral"!==e.type||e.value)&&("text"!==t||"StringLiteral"!==e.type&&"NumericLiteral"!==e.type)){if("JSXElement"===e.type){let r=e.opening.name,o=f(r),i=e.children.some(e=>"JSXText"!==e.type||e.value.trim()),n=o&&a.has(o.source)&&"text"===t&&["Title","Tag"].includes(o.name),s="image"===t&&"Identifier"===r.type&&["image","svg"].includes(r.value);if(!i&&(n||s))return}else if(!["JSXFragment","ArrayExpression","ObjectExpression","BooleanLiteral","StringLiteral","NumericLiteral"].includes(e.type))return;else if("config"===t&&"JSXFragment"!==e.type&&"ArrayExpression"!==e.type)return;m(e,r,`仅支持 ${"text"===t?"string / number / Tag / Title":"image"===t?"image / svg":"标准配置(price 也支持 string / number)"},不支持业务组件、fragment、包装节点或复合 JSX。`)}})}function v(e,t,r=new Set){x(e,e=>{if(r.has(e))return;let o=new Set(r).add(e);if("ArrayExpression"===e.type)for(let r of e.elements)r&&(r.spread?v(r.expression,t,o):x(r.expression,t));else if("CallExpression"===e.type&&"MemberExpression"===e.callee.type&&"Identifier"===e.callee.property.type&&"map"===e.callee.property.value){let r=e.arguments[0]?.expression;r?.type==="ArrowFunctionExpression"&&"BlockStatement"!==r.body.type&&x(r.body,t)}})}if(i(e,{JSXElement(e){let r=f(e.opening.name);if(!r||!(n.has(r.source)&&["ContentCard","CouponCard","TransitCard","CheckoutCard","CompositeCard","PriceActionCard","AskHumanCard","MapCard"].includes(r.name)||a.has(r.source)&&["Title","Tag","Price","Icon","OptionGroup","Checkbox","Agreement"].includes(r.name)))return;let o=new Map;for(let t of e.opening.attributes)if("SpreadElement"===t.type){let e=d(t.arguments);if("ObjectExpression"!==e.type)o.clear();else{let t=b(e);for(let[e,r]of(g.has(t)&&o.clear(),t))o.set(e,r)}}else if("Identifier"===t.name.type&&t.value){let e=t.value;"JSXExpressionContainer"===e.type&&"JSXEmptyExpression"!==e.expression.type?o.set(t.name.value,e.expression):"StringLiteral"===e.type&&o.set(t.name.value,e)}let i=function e(r,o,i=o){var s;let l=!1,p="CheckoutCard"===o?"productItems":"items",u=r.get(p);return u&&(s=`${i}.${p}`,v(u,e=>{for(let[t,r]of b(e)){let e=`${s}[].${t}`;"ContentCard"===o&&["title","subtitle","description"].includes(t)||"TransitCard"===o&&"title"===t?h(r,"text",e):"ContentCard"===o&&"thumbnail"===t||"CheckoutCard"===o&&"image"===t?h(r,"image",e):("ContentCard"===o&&"action"===t||"TransitCard"===o&&"price"===t)&&h(r,"config",e)}})),"CompositeCard"===o&&r.has("sections")&&v(r.get("sections"),r=>{let o=b(r),s=o.get("type"),p=s&&d(s),u=o.get("props");if(p?.type==="StringLiteral"&&"custom"===p.value){l=!0;let e=o.get("content");e&&x(e,e=>{if("JSXElement"===e.type){let r=f(e.opening.name);!r||n.has(r.source)||a.has(r.source)||t.onCustomSectionImport?.(r.source)}})}if(p?.type==="StringLiteral"&&u){let t={content:"ContentCard",transit:"TransitCard","option-group":"OptionGroup"}[p.value];t&&e(b(u),t,`${i}.sections[${p.value}].props`)}}),l}(o,r.name);"CompositeCard"===r.name&&m(e,"CompositeCard",`CompositeCard 支持组合内容模块,构建检查无法自动判断最终效果是否符合豆包卡片设计规范。请在交付前检查整体布局、视觉层级、交互及各状态。${i?"自定义内容及其样式也需符合规范,且不得覆盖模板外壳、Header 和 Footer。":""}`,i?"template.composite.design.custom":"template.composite.design")}}),t.checkWidgetRoot){let t=new Set,o=new Set,i=new Set(["@doubao-dev/framework","@byted-doubao-apps/framework"]),a=new Set(["ContentCard","CouponCard","TransitCard","CheckoutCard","CompositeCard","PriceActionCard","AskHumanCard","MapCard"]);function C(e){if(!t.has(e)&&e.body){if(t.add(e),"BlockStatement"!==e.body.type)return void S(e.body);!function e(t){if(t&&"object"==typeof t){if(Array.isArray(t))return void t.forEach(e);if("ReturnStatement"===t.type){t.argument&&S(t.argument);return}["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","MethodProperty","ClassDeclaration","ClassExpression"].includes(String(t.type))||Object.values(t).forEach(e)}}(e.body)}}function S(e){x(e,e=>{if(!o.has(e)&&(o.add(e),"NullLiteral"!==e.type&&("BooleanLiteral"!==e.type||e.value)))if("FunctionExpression"===e.type||"ArrowFunctionExpression"===e.type)C(e);else if("Identifier"===e.type){let t=r.get(s(e));t&&C(t)}else if("CallExpression"===e.type){if("Super"===e.callee.type||"Import"===e.callee.type)return;let t=f(e.callee);if(t?.name==="defineWidget"&&i.has(t.source)){let t=e.arguments[0]?.expression;t&&function(e){let t=d(e),r=b(t).get("render");if(r&&S(r),"ObjectExpression"===t.type)for(let e of t.properties)"MethodProperty"===e.type&&("Identifier"===e.key.type||"StringLiteral"===e.key.type)&&"render"===e.key.value&&C(e)}(t)}else if(t&&["memo","forwardRef"].includes(t.name)&&(i.has(t.source)||["react","@lynx-js/react"].includes(t.source))){let t=e.arguments[0]?.expression;t&&S(t)}else{let t=d(e.callee);if("FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type)C(t);else if("Identifier"===t.type){let e=r.get(s(t));e&&C(e)}}}else if("JSXElement"===e.type){let t=e.opening.name,o=f(t);if(o&&n.has(o.source)&&a.has(o.name))return;if("Identifier"===t.type&&!/^[a-z]/.test(t.value)){let e=r.get(s(t)),o=d(t);if(e)return void C(e);if("FunctionExpression"===o.type||"ArrowFunctionExpression"===o.type||"CallExpression"===o.type)return void S(o)}m(e,"widget.root","Widget 最外层必须直接渲染模板卡片,不能套 view、scroll-view、fragment 或其他包装节点。")}else["JSXFragment","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral"].includes(e.type)&&m(e,"widget.root","Widget 最外层必须直接渲染一张模板卡片。")})}for(let t of e.body)if("ExportDefaultExpression"===t.type)S(t.expression);else if("ExportDefaultDeclaration"===t.type&&"FunctionExpression"===t.decl.type)C(t.decl);else if("ExportNamedDeclaration"===t.type&&!t.source&&!t.typeOnly)for(let e of t.specifiers)"ExportSpecifier"===e.type&&e.exported?.value==="default"&&"Identifier"===e.orig.type&&S(e.orig)}return p}(y,{onCustomSectionImport:e=>v.add(e),checkWidgetRoot:f.some(e=>c(e)===c(this.resourcePath))})){let r=x(t.span.start-b),o=e.slice(0,r),i=o.split("\n").length,n=r-o.lastIndexOf("\n");h.push({rule_id:t.ruleId??("widget.root"===t.field?"template.root":"template.content"),severity:"warning",file:this.resourcePath,line:i,column:n,field:t.field,message:t.message})}let C=this._module;C?.buildInfo&&(C.buildInfo.cardDiagnostics=h,C.buildInfo.cardCustomSectionImports=[...v]);let S=new Set;if(i(y,{JSXOpeningElement(e){let t=p(e.name);if(!t)return;let r=l[t];u(m,e.name,r,b,x),S.add(r)},JSXClosingElement(e){let t=p(e.name);if(!t)return;let r=l[t];u(m,e.name,r,b,x),S.add(r)}}),S.size>0){let e=Array.from(S).map(e=>{let t=e.replace("Doubao","");return`${t} as ${e}`}).join(", "),t=`import { ${e} } from '${d}/components';
|
|
2
|
+
`;m.prepend(t)}if(m.hasChanged()){let e=m.toString(),r=m.generateMap({includeContent:!0,hires:!0,source:this.resourcePath,file:this.resourcePath});t(null,e,r)}else t(null,e)}catch(r){t(null,e)}};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"node:module";import{logger as
|
|
1
|
+
import"node:module";import{logger as o}from"@rsbuild/core";import e from"chalk";import{Option as a,program as r}from"commander";import{package_namespaceObject as t,dev as n,cliLogger as p,deploy as i,build as c,analyze as s}from"../277~0.js";import{selectDevServerHost as d}from"../427~0.js";function l(){if(!process.env.NODE_ENV){let o=process.argv[2];process.env.NODE_ENV=["build","package","deploy","analyze","perf"].includes(o)?"production":"development"}p.greet(`Doubao Apps SDK v${t.rE}`)}async function m(o){let{devtools:e,host:a,...r}=o,t={...r,host:!0===a?await d():a};return e?{...t,debugDriver:"devtools"}:t}function u(o){return o.option("--app-id <appId>","application ID provided by the platform").option("-c --config <config>","specify the configuration file, can be a relative or absolute path").option("--env-mode <mode>","specify the env mode to load the `.env.[mode]` file"),o}function v(t=process.cwd(),p={},d="0.8.0-rc.11"){r.name("doubao").usage("<command> [options]").version(d),u(r.command("dev")).description("starting the dev server...").option("--host [host]","listen hostname or IP; omit value to select an address interactively").option("--devtools","use DevTools debug driver").action(async e=>{try{await n(await m(e))}catch(e){o.error("Failed to dev"),o.error(e),process.exit(1)}}),u(r.command("build")).description("starting build the applet").option("-a --archive","Archive all package",!1).addOption(Object.assign(new a("--channel <string>","Need channel name"),{short:"-ch",flags:"-ch --channel <string>"})).action(async e=>{try{await c(e)}catch(e){o.error("Failed to build"),o.error(e),process.exit(1)}}),u(r.command("analyze")).description("analyze the applet package").action(async a=>{try{await s(a)}catch(a){o.error(e.red("Failed to analyze")),o.error(a),process.exit(1)}}),u(r.command("deploy")).option("--token <token>","developer open build token for Doubao Apps Platform deploy").option("--app-name, --appName <appName>","app name for Doubao Apps Platform deploy").option("--app-icon, --appIcon <appIcon>","app icon for Doubao Apps Platform deploy").option("--version-tag, --versionTag <versionTag>","version tag for Doubao Apps Platform deploy").description("build and upload the app package").action(async a=>{try{await i({...a,build:!0})}catch(a){o.error(e.red("Failed to deploy")),o.error(a),process.exit(1)}}),r.parse()}export{l as prepareCli,v as runCli};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/sdk.d.ts
CHANGED
|
@@ -575,15 +575,70 @@ declare type PermissionDetail = {
|
|
|
575
575
|
apis: string[];
|
|
576
576
|
};
|
|
577
577
|
|
|
578
|
+
declare type PhysicalDeviceDebugAuthState = {
|
|
579
|
+
revision: number;
|
|
580
|
+
operationId?: string;
|
|
581
|
+
owner?: 'web' | 'terminal';
|
|
582
|
+
phase: PhysicalDeviceDebugPhase;
|
|
583
|
+
connectionMode?: 'qr' | 'existing_client';
|
|
584
|
+
progress?: {
|
|
585
|
+
downloadedBytes?: number;
|
|
586
|
+
totalBytes?: number;
|
|
587
|
+
percentage?: number;
|
|
588
|
+
installStage?: 'verify' | 'extract' | 'install';
|
|
589
|
+
};
|
|
590
|
+
qr?: {
|
|
591
|
+
revision: number;
|
|
592
|
+
modernAvailable: boolean;
|
|
593
|
+
legacyAvailable: boolean;
|
|
594
|
+
};
|
|
595
|
+
deadlineAt?: number;
|
|
596
|
+
canCancel: boolean;
|
|
597
|
+
canRetry: boolean;
|
|
598
|
+
error?: {
|
|
599
|
+
code: PhysicalDeviceDebugErrorCode;
|
|
600
|
+
message: string;
|
|
601
|
+
stage: PhysicalDeviceDebugErrorStage;
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
|
|
578
605
|
declare type PhysicalDeviceDebugCapability = {
|
|
579
|
-
|
|
580
|
-
|
|
606
|
+
deviceStateEndpoint?: string;
|
|
607
|
+
ensureWebDevtoolEndpoint?: string;
|
|
608
|
+
pushPageEndpoint?: string;
|
|
609
|
+
pushCardEndpoint?: string;
|
|
610
|
+
authStateEndpoint: string;
|
|
611
|
+
startAuthEndpoint: string;
|
|
581
612
|
cancelEndpoint: string;
|
|
582
613
|
qrEndpoint: string;
|
|
583
614
|
accessToken: string;
|
|
584
615
|
pollIntervalMs: number;
|
|
585
616
|
};
|
|
586
617
|
|
|
618
|
+
declare interface PhysicalDeviceDebugDeviceState {
|
|
619
|
+
available: boolean;
|
|
620
|
+
error?: string;
|
|
621
|
+
devices: {
|
|
622
|
+
clientId: number;
|
|
623
|
+
deviceId?: string;
|
|
624
|
+
deviceModel?: string;
|
|
625
|
+
network?: string;
|
|
626
|
+
app?: string;
|
|
627
|
+
sessions: (PhysicalDeviceDebugTarget & {
|
|
628
|
+
url: string;
|
|
629
|
+
description: string;
|
|
630
|
+
})[];
|
|
631
|
+
}[];
|
|
632
|
+
pages: {
|
|
633
|
+
id: string;
|
|
634
|
+
label: string;
|
|
635
|
+
}[];
|
|
636
|
+
cards: {
|
|
637
|
+
id: string;
|
|
638
|
+
label: string;
|
|
639
|
+
}[];
|
|
640
|
+
}
|
|
641
|
+
|
|
587
642
|
declare type PhysicalDeviceDebugErrorCode = 'DEV_RUNTIME_UNAVAILABLE' | 'UNSUPPORTED_PLATFORM' | 'TOOL_PREPARE_FAILED' | 'TICKET_FAILED' | 'CONNECTION_TIMEOUT' | 'PACKAGE_INSTALL_FAILED' | 'PACKAGE_INSTALL_TIMEOUT' | 'TOOL_LAUNCH_FAILED' | 'DEVICE_DISCONNECTED' | 'REAL_DEVICE_DEBUG_BUSY' | 'REAL_DEVICE_DEBUG_FAILED';
|
|
588
643
|
|
|
589
644
|
declare type PhysicalDeviceDebugErrorStage = 'runtime' | 'prepare' | 'ticket' | 'connection' | 'package_install' | 'launch' | 'disconnect';
|
|
@@ -604,41 +659,47 @@ declare class PhysicalDeviceDebugGateway {
|
|
|
604
659
|
declare type PhysicalDeviceDebugPhase = 'idle' | 'preparing' | 'downloading' | 'installing_tool' | 'reusing_client' | 'waiting_for_scan' | 'waiting_for_install' | 'launching_tool' | 'connected' | 'failed' | 'timed_out' | 'cancelled';
|
|
605
660
|
|
|
606
661
|
declare type PhysicalDeviceDebugProvider = {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
662
|
+
getDeviceState?(): PhysicalDeviceDebugDeviceState | Promise<PhysicalDeviceDebugDeviceState>;
|
|
663
|
+
ensureWebDevtool?(target: PhysicalDeviceDebugTarget & {
|
|
664
|
+
retry?: boolean;
|
|
665
|
+
}): Promise<PhysicalDeviceDebugWebDevtoolState>;
|
|
666
|
+
pushPage?(request: PhysicalDeviceDebugPushRequest): Promise<PhysicalDeviceDebugPushResult>;
|
|
667
|
+
pushCard?(request: PhysicalDeviceDebugPushRequest): Promise<PhysicalDeviceDebugPushResult>;
|
|
668
|
+
getAuthState(): PhysicalDeviceDebugAuthState | Promise<PhysicalDeviceDebugAuthState>;
|
|
669
|
+
startAuth(): PhysicalDeviceDebugAuthState | Promise<PhysicalDeviceDebugAuthState>;
|
|
670
|
+
cancel(operationId: string): PhysicalDeviceDebugAuthState | Promise<PhysicalDeviceDebugAuthState>;
|
|
610
671
|
getQrImage(operationId: string, kind: 'modern' | 'legacy'): Promise<{
|
|
611
672
|
body: Uint8Array;
|
|
612
673
|
contentType: 'image/png';
|
|
613
674
|
} | undefined>;
|
|
614
675
|
};
|
|
615
676
|
|
|
616
|
-
declare
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
677
|
+
declare interface PhysicalDeviceDebugPushRequest {
|
|
678
|
+
clientId: number;
|
|
679
|
+
sessionId?: number;
|
|
680
|
+
resourceId: string;
|
|
681
|
+
params: Record<string, unknown>;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
declare interface PhysicalDeviceDebugPushResult {
|
|
685
|
+
ok: boolean;
|
|
686
|
+
error?: string;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
declare interface PhysicalDeviceDebugTarget {
|
|
690
|
+
clientId: number;
|
|
691
|
+
sessionId: number;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
declare interface PhysicalDeviceDebugWebDevtoolState {
|
|
695
|
+
status: 'preparing' | 'ready' | 'failed';
|
|
622
696
|
progress?: {
|
|
623
|
-
|
|
624
|
-
totalBytes?: number;
|
|
697
|
+
label: string;
|
|
625
698
|
percentage?: number;
|
|
626
|
-
installStage?: 'verify' | 'extract' | 'install';
|
|
627
|
-
};
|
|
628
|
-
qr?: {
|
|
629
|
-
revision: number;
|
|
630
|
-
modernAvailable: boolean;
|
|
631
|
-
legacyAvailable: boolean;
|
|
632
699
|
};
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
error?: {
|
|
637
|
-
code: PhysicalDeviceDebugErrorCode;
|
|
638
|
-
message: string;
|
|
639
|
-
stage: PhysicalDeviceDebugErrorStage;
|
|
640
|
-
};
|
|
641
|
-
};
|
|
700
|
+
url?: string;
|
|
701
|
+
error?: string;
|
|
702
|
+
}
|
|
642
703
|
|
|
643
704
|
declare type RequestContext = Readonly<{
|
|
644
705
|
request: IncomingMessage;
|
|
@@ -736,6 +797,8 @@ declare class SandboxRuntime {
|
|
|
736
797
|
sandboxCsrPem?: string | undefined;
|
|
737
798
|
fileSystemNamespace: string;
|
|
738
799
|
sandboxSessionAvailable: boolean;
|
|
800
|
+
sandboxSessionError: Pick<SandboxSessionCreationError, "message" | "category" | "logId"> | undefined;
|
|
801
|
+
sandboxAppId: string;
|
|
739
802
|
sandboxCsrRequired: boolean;
|
|
740
803
|
sandboxCsrUploaded: boolean;
|
|
741
804
|
sandboxPhoneNumberUploaded: boolean;
|
|
@@ -785,12 +848,19 @@ declare type SandboxRuntimeState = {
|
|
|
785
848
|
sandboxProjectId: string;
|
|
786
849
|
sandboxSessionAppId?: string;
|
|
787
850
|
sandboxSessionId: string;
|
|
851
|
+
sandboxSessionError?: Pick<SandboxSessionCreationError, 'category' | 'message' | 'logId'>;
|
|
788
852
|
sandboxTargetOrigin?: string;
|
|
789
853
|
simulatorBusinessTemplatesPath?: string;
|
|
790
854
|
simulatorManifestReader?: () => string;
|
|
791
855
|
simulatorManifestPath?: string;
|
|
792
856
|
};
|
|
793
857
|
|
|
858
|
+
declare class SandboxSessionCreationError extends Error {
|
|
859
|
+
readonly category: 'local' | 'network' | 'platform';
|
|
860
|
+
readonly logId?: string | undefined;
|
|
861
|
+
constructor(message: string, category: 'local' | 'network' | 'platform', logId?: string | undefined);
|
|
862
|
+
}
|
|
863
|
+
|
|
794
864
|
declare type SandboxSessionIdentity = {
|
|
795
865
|
appId: string;
|
|
796
866
|
sessionId: string;
|