@doubao-apps/kit 0.0.18 → 0.0.19

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.
@@ -0,0 +1 @@
1
+ c8771ea83a6da3b04fb50acceb68159264fac48100a7d9ec64f0ff34163ac92a security_tasm_codec
@@ -0,0 +1 @@
1
+ 2518aa71074374a0765af9828612b8de2c974053b8969555d7116bac64244d98 security_tasm_codec
@@ -0,0 +1 @@
1
+ 488660973b423f07eb5c64bf08b99e15e803bf05e8292470b7daf2f027bcfe3b security_tasm_codec
@@ -0,0 +1 @@
1
+ ab5e7bff2e42b71692822c8dc90a6a85c8b0bff8f65ab7767a5066f5779ae2cc security_tasm_codec.exe
@@ -1,3 +1,3 @@
1
- import"node:module";import{jsx as e}from"@ast-grep/napi";import t from"magic-string";import"../../../881.js";let o={button:"DoubaoButton",slider:"DoubaoSlider",switch:"DoubaoSwitch",swiper:"DoubaoSwiper","swiper-item":"DoubaoSwiperItem","movable-area":"DoubaoMovableArea","movable-view":"DoubaoMovableView",map:"DoubaoMap","map-marker":"DoubaoMapMarker",view:"DoubaoView",text:"DoubaoText",image:"DoubaoImage",input:"DoubaoInput",textarea:"DoubaoTextArea","scroll-view":"DoubaoScrollView",svg:"DoubaoSvg"};export default function(i){let a=this.async();try{let l=new t(i),r=e.parse(i).root(),n=e.kind("jsx_opening_element"),s=e.kind("jsx_closing_element"),u=e.kind("jsx_self_closing_element"),d=r.findAll(n),m=r.findAll(s),p=r.findAll(u),f=[...d,...m,...p],b=new Set;for(let e of f){let t=e.kind(),i=e.text(),a=e.range();if("jsx_opening_element"===t){let e=i.match(/<([\w-]+)/);if(e){let t=e[1],r=o[t];if(r){let e=i.indexOf(`<${t}`);l.overwrite(a.start.index+e+1,a.start.index+e+1+t.length,r),b.add(r)}}}else if("jsx_closing_element"===t){let e=i.match(/<\/([\w-]+)/);if(e){let t=e[1],r=o[t];if(r){let e=i.indexOf(`</${t}`);l.overwrite(a.start.index+e+2,a.start.index+e+2+t.length,r),b.add(r)}}}else if("jsx_self_closing_element"===t){let e=i.match(/<([\w-]+)/);if(e){let t=e[1],r=o[t];if(r){let e=i.indexOf(`<${t}`);l.overwrite(a.start.index+e+1,a.start.index+e+1+t.length,r),b.add(r)}}}}if(b.size>0){let e=Array.from(b).map(e=>{let t=e.replace("Doubao","");return`${t} as ${e}`}).join(", "),t=`import { ${e} } from '@byted-doubao-apps/components';
2
- `;l.prepend(t)}if(l.hasChanged()){let e=l.toString(),t=l.generateMap({includeContent:!0,hires:!0,source:this.resourcePath,file:this.resourcePath});a(null,e,t)}else a(null,i)}catch(e){a(null,i)}};
1
+ import"node:module";import{jsx as e}from"@ast-grep/napi";import o from"magic-string";import"../../../881.js";let t={button:"DoubaoButton",map:"DoubaoMap","map-marker":"DoubaoMapMarker","movable-area":"DoubaoMovableArea","movable-view":"DoubaoMovableView",popup:"DoubaoPopup",radio:"DoubaoRadio","radio-group":"DoubaoRadioGroup",slider:"DoubaoSlider",switch:"DoubaoSwitch",swiper:"DoubaoSwiper","swiper-item":"DoubaoSwiperItem","picker-column":"DoubaoPickerColumn","picker-view":"DoubaoPickerView","web-view":"DoubaoWebView",image:"DoubaoImage",input:"DoubaoInput",list:"DoubaoList","list-item":"DoubaoListItem","scroll-view":"DoubaoScrollView",svg:"DoubaoSvg",text:"DoubaoText",textarea:"DoubaoTextArea",view:"DoubaoView"};export default function(i){let a=this.async();try{let r=new o(i),l=e.parse(i).root(),n=e.kind("jsx_opening_element"),s=e.kind("jsx_closing_element"),u=e.kind("jsx_self_closing_element"),p=l.findAll(n),d=l.findAll(s),m=l.findAll(u),b=[...p,...d,...m],f=new Set;for(let e of b){let o=e.kind(),i=e.text(),a=e.range();if("jsx_opening_element"===o){let e=i.match(/<([\w-]+)/);if(e){let o=e[1],l=t[o];if(l){let e=i.indexOf(`<${o}`);r.overwrite(a.start.index+e+1,a.start.index+e+1+o.length,l),f.add(l)}}}else if("jsx_closing_element"===o){let e=i.match(/<\/([\w-]+)/);if(e){let o=e[1],l=t[o];if(l){let e=i.indexOf(`</${o}`);r.overwrite(a.start.index+e+2,a.start.index+e+2+o.length,l),f.add(l)}}}else if("jsx_self_closing_element"===o){let e=i.match(/<([\w-]+)/);if(e){let o=e[1],l=t[o];if(l){let e=i.indexOf(`<${o}`);r.overwrite(a.start.index+e+1,a.start.index+e+1+o.length,l),f.add(l)}}}}if(f.size>0){let e=Array.from(f).map(e=>{let o=e.replace("Doubao","");return`${o} as ${e}`}).join(", "),o=`import { ${e} } from '@byted-doubao-apps/framework/components';
2
+ `;r.prepend(o)}if(r.hasChanged()){let e=r.toString(),o=r.generateMap({includeContent:!0,hires:!0,source:this.resourcePath,file:this.resourcePath});a(null,e,o)}else a(null,i)}catch(e){a(null,i)}};
3
3
  //# sourceMappingURL=index.js.map
package/dist/cli/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import"node:module";import{program as e}from"commander";import"../881.js";import{logger as o,chalk_1 as r}from"../971.js";import{dev as a,build as t,analyze as i}from"../938.js";function n(){if(!process.env.NODE_ENV){let e=process.argv[2];process.env.NODE_ENV=["build","package","deploy","analyze","perf"].includes(e)?"production":"development"}o.greet("Doubao Apps SDK v0.0.18")}function c(e){return e.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"),e}function p(n=process.cwd(),d={},s="0.0.18"){e.name("doubao").usage("<command> [options]").version(s),c(e.command("dev")).description("starting the dev server...").action(async e=>{try{await a(e)}catch(e){o.error("Failed to dev"),o.error(e),process.exit(1)}}),c(e.command("build")).description("starting build the applet").option("-a --archive","Archive all package",!1).option("-ch --channel <string>","Need channel name").action(async e=>{try{await t(e)}catch(e){o.error("Failed to build"),o.error(e),process.exit(1)}}),c(e.command("analyze")).description("analyze the applet package").action(async e=>{try{await i(e)}catch(e){o.error(r.red("Failed to analyze")),o.error(e),process.exit(1)}}),e.parse()}export{n as prepareCli,p as runCli};
1
+ import"node:module";import{program as e}from"commander";import"../881.js";import{logger as o,chalk_1 as r}from"../971.js";import{dev as a,build as t,analyze as i}from"../938.js";function n(){if(!process.env.NODE_ENV){let e=process.argv[2];process.env.NODE_ENV=["build","package","deploy","analyze","perf"].includes(e)?"production":"development"}o.greet("Doubao Apps SDK v0.0.19")}function c(e){return e.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"),e}function p(n=process.cwd(),d={},s="0.0.19"){e.name("doubao").usage("<command> [options]").version(s),c(e.command("dev")).description("starting the dev server...").action(async e=>{try{await a(e)}catch(e){o.error("Failed to dev"),o.error(e),process.exit(1)}}),c(e.command("build")).description("starting build the applet").option("-a --archive","Archive all package",!1).option("-ch --channel <string>","Need channel name").action(async e=>{try{await t(e)}catch(e){o.error("Failed to build"),o.error(e),process.exit(1)}}),c(e.command("analyze")).description("analyze the applet package").action(async e=>{try{await i(e)}catch(e){o.error(r.red("Failed to analyze")),o.error(e),process.exit(1)}}),e.parse()}export{n as prepareCli,p as runCli};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
- import"node:module";import"../881.js";export{AI_MANIFEST,AI_MANIFEST_ATTRIBUTE,AI_META_JSON_FILENAME,AI_META_JSON_FILENAME_4_RTS,APPLET_CONFIG_NAME,APPLET_DOCTOR_URL,APPLET_EXTERNAL_MODULE_NAME,APPLET_EXTERNAL_SCRIPT_NAME,APPLET_FOLDER,APPLET_MANIFEST_FILE,APPLET_OUTPUT_FOLDER,APPLET_TOOLS_PLUGIN_NAME,APP_PACKAGE_NAME,AppletLynxPlugin,AppletMainEntryCheckPlugin,AppletMainPlugin,BASE_FOLDER,BuildContext,CONFIG_FILE_EXTENSIONS,CONVENTIONAL_DIR_NAME_MCP_UI,CONVENTIONAL_DIR_NAME_PAGE,CONVENTIONAL_DIR_NAME_TOOLS,CONVENTIONAL_DIR_NAME_WIDGET,CONVENTIONAL_FILE_NAME_APP,CONVENTIONAL_FILE_NAME_APP_4_RTS,Command,DEVELOPMENT_BROWSER_LIST,DOCUMENT_URL,DOUBAO_APPS_SDK_TEMPLATE_FOLDER,DOUBAO_APP_OUTPUT_FOLDER,DevServerLogPlugin,ECommand,ENTRY_FILE_TS,ENTRY_FILE_TSX,EViewEntryType,GECKO,INJECT_GLOBAL_VARIABLES_CONTENT,INTERNAL_FRAMEWORK_PACKAGE,LYNX_APP_SERVICE_JS,LYNX_GLOBAL,LYNX_JS_CODE_INJECT_PLACEHOLDER,LYNX_JS_RENDER_TYPE,LYNX_PROCESSOR_LEPUS,Launcher,MAIN_THREAD_COMPILER_NAME,MAIN_THREAD_COMPILER_NAME_4_RTS,MAIN_THREAD_ENTRY_KEY,MAIN_THREAD_ENTRY_KEY_4_RTS,MAIN_THREAD_VIRTUAL_ENTRY_KEY,MANIFEST_DEFAULT_APPLET_ICON,MANIFEST_DEFAULT_VERSION,MainWorkerConfigBuilder,PAGES,PLUGINS_FOLDER,PRODUCTION_BROWSER_LIST,PUBLIC_FRAMEWORK_PACKAGE,PromiseManager,ROOT_PATH,RUNTIME_DEFAULT_VERSION,SCM_GECKO_FOLDER,SCM_SELF_BUILT_FOLDER,SELF_BUILT,SOURCE_DIRECTORY,TRANSFORM_FOLDER,VIEW_COMPILER_NAME,VIEW_THREAD_VIRTUAL_ENTRY_KEY,ViewConfigBuilder,ViewEntryType,WIDGETS,analyzeMainThreadConvention,analyzeToolEntries,analyzeViewConvention,analyzeViewEntries,collectProperties,collectViewAIMeta,collectWorkerMetadata,createBuilder,createCommonRsbuildConfig,createLaunch,createMainCode,createMainEntryObject,createReactLynxEntries,getAppEntry,getAppletLocalAreaNetworkUrl,getDebugDriver,getFrameworkApiPackage,getKeyName,getLocalAreaNetworkAddress,getViewEntries,isArrayExpression,isBooleanLiteral,isCallExpression,isDebugMode,isFrameworkPackage,isIdentifier,isKeyValueProperty,isNumericLiteral,isObjectExpression,isProd,isSpreadElement,isStringLiteral,parseSync,resolveFrameworkPackage,simple}from"../971.js";
1
+ import"node:module";import"../881.js";class e{_promise=null;_resolve=null;_reject=null;create(){return this._promise=new Promise((e,_)=>{this._resolve=e,this._reject=_}),this._promise}ensure(){return this._promise||this.create(),this._promise}resolve(e){this._resolve&&this._resolve(e)}reject(e){this._reject&&this._reject(e)}getPromise(){return this._promise}reset(){this._promise=null,this._resolve=null,this._reject=null}}export{AI_MANIFEST,AI_MANIFEST_ATTRIBUTE,AI_META_JSON_FILENAME,AI_META_JSON_FILENAME_4_RTS,APPLET_CONFIG_NAME,APPLET_DOCTOR_URL,APPLET_EXTERNAL_MODULE_NAME,APPLET_EXTERNAL_SCRIPT_NAME,APPLET_FOLDER,APPLET_OUTPUT_FOLDER,APPLET_TOOLS_PLUGIN_NAME,APP_PACKAGE_NAME,AppletLynxPlugin,AppletMainEntryCheckPlugin,AppletMainPlugin,BASE_FOLDER,BuildContext,CONFIG_FILE_EXTENSIONS,CONVENTIONAL_DIR_NAME_MCP_UI,CONVENTIONAL_DIR_NAME_PAGE,CONVENTIONAL_DIR_NAME_TOOLS,CONVENTIONAL_DIR_NAME_WIDGET,CONVENTIONAL_FILE_NAME_APP,CONVENTIONAL_FILE_NAME_APP_4_RTS,CONVENTIONAL_FILE_NAME_LOGIN,CONVENTIONAL_FILE_NAME_PRIVACY,Command,DEVELOPMENT_BROWSER_LIST,DOCUMENT_URL,DOUBAO_APPS_SDK_TEMPLATE_FOLDER,DOUBAO_APP_OUTPUT_FOLDER,DevServerLogPlugin,ECommand,ENTRY_FILE_TS,ENTRY_FILE_TSX,GECKO,INJECT_GLOBAL_VARIABLES_CONTENT,INTERNAL_FRAMEWORK_PACKAGE,LOGIN,LYNX_APP_SERVICE_JS,LYNX_GLOBAL,LYNX_JS_CODE_INJECT_PLACEHOLDER,LYNX_JS_RENDER_TYPE,LYNX_PROCESSOR_LEPUS,Launcher,MAIN_THREAD_COMPILER_NAME,MAIN_THREAD_COMPILER_NAME_4_RTS,MAIN_THREAD_ENTRY_KEY,MAIN_THREAD_VIRTUAL_ENTRY_KEY,MANIFEST_DEFAULT_APPLET_ICON,MANIFEST_DEFAULT_VERSION,MANIFEST_FILE,PAGES,PLUGINS_FOLDER,PRIVACY,PRODUCTION_BROWSER_LIST,PUBLIC_FRAMEWORK_PACKAGE,ROOT_PATH,RUNTIME_DEFAULT_VERSION,SCM_GECKO_FOLDER,SCM_SELF_BUILT_FOLDER,SELF_BUILT,SOURCE_DIRECTORY,TRANSFORM_FOLDER,VIEW_COMPILER_NAME,VIEW_THREAD_VIRTUAL_ENTRY_KEY,WIDGETS,WorkerConfigBuilder,analyzeMainThreadConvention,analyzeMcpUIEntries,analyzeToolEntries,analyzeViewConvention,analyzeViewEntries,collectProperties,collectViewAIMeta,collectWorkerMetadata,createBuilder,createCommonRsbuildConfig,createLaunch,createMainCode,createMainEntryObject,createReactLynxEntries,getAppEntry,getAppletLocalAreaNetworkUrl,getDebugDriver,getFrameworkApiPackage,getKeyName,getLocalAreaNetworkAddress,getPreferredLanAddress,getViewEntries,isAppTemplateJsDisabled,isArrayExpression,isBooleanLiteral,isCallExpression,isDebugMode,isExternalBundleDisabled,isFrameworkPackage,isIdentifier,isKeyValueProperty,isNumericLiteral,isObjectExpression,isProd,isSigningEncryptionDisabled,isSpreadElement,isStringLiteral,parseSync,resolveFrameworkPackage,simple}from"../971.js";export{e as PromiseManager};
2
+ //# sourceMappingURL=builder.js.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{node_path as t,fileURLToPath as a,promises as r,node_fs as o,getDebugScenes as i,Launcher as n,executeDebugScene as c,archivePackage as s,getDebugDriver as l}from"./971.js";import"./881.js";let p=t.join("src","app.ts");function u(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}async function d(e,a,o=""){let i,n=t.join(e,p);try{i=await r.readFile(n,"utf8")}catch(e){if(e?.code==="ENOENT")return;throw e}let c=i.replace("<%= appId %>",u(a)).replace("<%= name %>",u(o));c!==i&&await r.writeFile(n,c,"utf8")}let h=new Set(["node_modules","dist",".git"]);async function m(e,a,o={}){let{includeAI:i=!0}=o,n=async(e,a)=>{for(let o of(await r.mkdir(a,{recursive:!0}),await r.readdir(e,{withFileTypes:!0}))){let c=t.join(e,o.name),s=t.join(a,o.name);if(o.isDirectory()){if(h.has(o.name)||".ai"===o.name&&!i)continue;await n(c,s)}else{if("AGENTS.md"===o.name&&!i)continue;await r.copyFile(c,s)}}};await n(e,a)}async function w(e,a){let r=t.join(e,"package.json");if(!o.existsSync(r))throw Error("package.json not found in template");let i=JSON.parse(o.readFileSync(r,"utf-8"));i.name=a,o.writeFileSync(r,`${JSON.stringify(i,null,2)}
2
- `)}let y=["starter","empty"],g=a(import.meta.url),f=t.dirname(g);async function _({template:e,projectDir:a,includeAI:o,appId:i,name:n}){if(!t.isAbsolute(a))throw Error(`Project directory must be an absolute path: ${a}`);if(!y.includes(e))throw Error(`Invalid template: ${e}. Valid options: ${y.join(", ")}`);let c=t.resolve(f,`template-${e}`);try{if(!(await r.stat(c)).isDirectory())throw Error(`Template path is not a directory: ${c}`)}catch(e){if(e?.code==="ENOENT")throw Error(`Template directory not found: ${c}`,{cause:e});throw Error(`Unable to access template directory: ${c}`,{cause:e})}if(await r.stat(a).then(e=>{if(!e.isDirectory())throw Error(`Project path is not a directory: ${a}`);return!0}).catch(e=>{if(e?.code==="ENOENT")return!1;throw Error(`Unable to access project directory: ${a}`,{cause:e})})){if((await r.readdir(a)).length>0)throw Error(`Project directory is not empty: ${a}`)}else await r.mkdir(a,{recursive:!0});await m(c,a,{includeAI:o});let s=t.basename(a).trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z0-9-~._]+/g,"-");await w(a,s),await d(a,i??`com.doubao.${s}`,n??"")}let E=e("fs");function D(e){return[{name:"DoubaoAppsDevPlugin",setup(t){t.onDevCompileDone(()=>{e?.onDevCompileDone?.()})}}]}class v{appDirectory;launcher;constructor(e,t=n){this.appDirectory=e,this.launcher=new t(e)}async dev(e={}){let{compileHooks:t,...a}=e;return await this.launcher.dev({...a,rsbuildPlugins:D(t)})}async build(e={}){process.env.NODE_ENV="production";let{compileHooks:t,...a}=e;await this.launcher.build({...a,skipCleanupRootPath:e.skipCleanupRootPath,rsbuildPlugins:D(t)})}async discoverWidgets(){return Object.values(this.launcher.context.metadata.getData().widgets)}async discoverPages(){return Object.values(this.launcher.context.metadata.getData().pages)}async pushWidget(e,t,a){(await l(a,t)).openWidget(this.launcher.context.metadata.getData().app.package,e)}async openPage(e,t,a){(await l(a,t)).openPage(this.launcher.context.metadata.getData().app.package,e)}async executeDebugScene(e,t,a){await c(e,this.launcher.context.metadata.getData().app.package,await l(a,t))}async getDebugScenes(){return await i(this.appDirectory||process.cwd())}async deploy(e,t,a){process.env.NODE_ENV="production",await this.build({skipCleanupRootPath:!0});let{manifest:r}=this.launcher.context,{packageName:o,versionCode:i}=r,{packageResource:n}=await s({channelName:"doubao_app",manifest:r,rootPath:this.launcher.rootPath});if(!n)throw Error("Failed to archive package");let{resource:c}=n,l=new FormData,p=new Blob([new Uint8Array(E.default.readFileSync(c))],{type:"application/zip"});l.append("applet_file",p,"doubao_app.zip"),l.append("applet_version_code",i.toString());let u=encodeURIComponent(a||o),d=encodeURIComponent(e),h=`https://hello.doubao-dev.com/developer/resource_api/apps/${u}/versions/${d}/package/upload_applet`,m={...process.env.X_TT_ENV?{"x-use-ppe":"1","x-tt-env":process.env.X_TT_ENV}:{},Cookie:t};try{let e=await fetch(h,{method:"POST",body:l,headers:m}),t=e.headers.get("x-tt-logid")||"";if(!e.ok){let a=await e.text(),r=JSON.stringify({code:e.status,message:"HTTP Error",data:a,log_id:t});throw Error(r)}let a=await e.json();if(0!==a.code){let e=JSON.stringify({...a,log_id:t});throw Error(e)}return console.log("Deploy success:",a),a}catch(e){return console.error("Deploy error:",e?.message||e),JSON.parse(e.message)}finally{E.default.rmSync(this.launcher.rootPath,{recursive:!0,force:!0})}}}let b=e=>e;export{analyze,build,dev}from"./938.js";export{v as DoubaoAppsSDK,_ as create,b as defineConfig};
1
+ import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{node_path as t,fileURLToPath as a,promises as r,getPPEEnvironmentHeader as o,node_fs as i,getDebugScenes as n,Launcher as c,executeDebugScene as s,isDebugMode as l,archivePackage as p,getDebugDriver as u}from"./971.js";import"./881.js";let d=t.join("src","app.ts");function h(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}async function g(e,a,o=""){let i,n=t.join(e,d);try{i=await r.readFile(n,"utf8")}catch(e){if(e?.code==="ENOENT")return;throw e}let c=i.replace("<%= appId %>",h(a)).replace("<%= name %>",h(o));c!==i&&await r.writeFile(n,c,"utf8")}let y=new Set(["node_modules","dist",".git"]);async function m(e,a,o={}){let{includeAI:i=!0}=o,n=async(e,a)=>{for(let o of(await r.mkdir(a,{recursive:!0}),await r.readdir(e,{withFileTypes:!0}))){let c=t.join(e,o.name),s=t.join(a,o.name);if(o.isDirectory()){if(y.has(o.name)||".ai"===o.name&&!i)continue;await n(c,s)}else{if("AGENTS.md"===o.name&&!i)continue;await r.copyFile(c,s)}}};await n(e,a)}async function w(e,a){let r=t.join(e,"package.json");if(!i.existsSync(r))throw Error("package.json not found in template");let o=JSON.parse(i.readFileSync(r,"utf-8"));o.name=a,i.writeFileSync(r,`${JSON.stringify(o,null,2)}
2
+ `)}let f=["starter","empty"],E=a(import.meta.url),_=t.dirname(E);async function D({template:e,projectDir:a,includeAI:o,appId:i,name:n,packageName:c,overwrite:s}){if(!t.isAbsolute(a))throw Error(`Project directory must be an absolute path: ${a}`);if(!f.includes(e))throw Error(`Invalid template: ${e}. Valid options: ${f.join(", ")}`);let l=t.resolve(_,`template-${e}`);try{if(!(await r.stat(l)).isDirectory())throw Error(`Template path is not a directory: ${l}`)}catch(e){if(e?.code==="ENOENT")throw Error(`Template directory not found: ${l}`,{cause:e});throw Error(`Unable to access template directory: ${l}`,{cause:e})}if(await r.stat(a).then(e=>{if(!e.isDirectory())throw Error(`Project path is not a directory: ${a}`);return!0}).catch(e=>{if(e?.code==="ENOENT")return!1;throw Error(`Unable to access project directory: ${a}`,{cause:e})})){if((await r.readdir(a)).length>0&&!s)throw Error(`Project directory is not empty: ${a}`)}else await r.mkdir(a,{recursive:!0});await m(l,a,{includeAI:o});let p=c??t.basename(a).trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z0-9-~._]+/g,"-");await w(a,p),await g(a,i??`com.doubao.${p}`,n??"")}let b=e("fs");function S(e){return[{name:"DoubaoAppsDevPlugin",setup(t){t.onDevCompileDone(()=>{e?.onDevCompileDone?.()})}}]}class v{appDirectory;launcher;constructor(e,t=c){this.appDirectory=e,this.launcher=new t(e)}async dev(e={}){let{compileHooks:t,...a}=e;return await this.launcher.dev({...a,rsbuildPlugins:S(t),signingEncryptionOptions:e.signingEncryptionOptions})}async build(e={}){process.env.NODE_ENV="production";let{compileHooks:t,...a}=e;await this.launcher.build({...a,rsbuildPlugins:S(t),signingEncryptionOptions:e.signingEncryptionOptions})}async discoverWidgets(){return Object.values(this.launcher.context.metadata.getData().widgets)}async discoverPages(){return Object.values(this.launcher.context.metadata.getData().pages)}async pushWidget(e){let{widgetId:t,deviceId:a,botId:r,widgetData:o,hdt:i}=e,n=await u({hdt:i,deviceId:a}),c=this.launcher.context.metadata.getData().app.package;n.pushWidget({packageName:c,widgetId:t,widgetData:o,botId:r})}async openPage(e){let{pageId:t,pageData:a,pageSettings:r,mode:o,hdt:i,deviceId:n}=e,c=await u({hdt:i,deviceId:n}),s=this.launcher.context.metadata.getData().app.package;c.openPage({packageName:s,pageId:t,pageData:a,pageSettings:r,mode:o})}async executeDebugScene(e){let{matchedScene:t,deviceId:a,hdt:r}=e,o=this.launcher.context.metadata.getData().app.package,i=await u({hdt:r,deviceId:a});await s({matchedScene:t,packageName:o,driver:i})}async getDebugScenes(){return await n(this.appDirectory||process.cwd())}async deploy(e){let{versionTag:t,cookie:a,appKey:r,signingEncryptionOptions:i}=e;process.env.NODE_ENV="production",await this.launcher.build({skipCleanupRootPath:!0,signingEncryptionOptions:i});let{manifest:n}=this.launcher.context,{packageName:c,versionCode:s}=n,{packageResource:u}=await p({channelName:"doubao_app",manifest:n,rootPath:this.launcher.rootPath});if(!u)throw Error("Failed to archive package");let{resource:d}=u,h=new FormData,g=new Blob([new Uint8Array(b.default.readFileSync(d))],{type:"application/zip"});h.append("applet_file",g,"doubao_app.zip"),h.append("applet_version_code",s.toString());let y=encodeURIComponent(r||c),m=encodeURIComponent(t),w=`https://hello.doubao-dev.com/developer/resource_api/apps/${y}/versions/${m}/package/upload_applet`,f={...o(),Cookie:a};try{let e=await fetch(w,{method:"POST",body:h,headers:f}),t=e.headers.get("x-tt-logid")||"";if(!e.ok){let a=await e.text(),r=JSON.stringify({code:e.status,message:"HTTP Error",data:a,log_id:t});throw Error(r)}let a=await e.json();if(0!==a.code){let e=JSON.stringify({...a,log_id:t});throw Error(e)}return console.log("Deploy success:",a),a}catch(e){return console.error("Deploy error:",e?.message||e),JSON.parse(e.message)}finally{l()||b.default.rmSync(this.launcher.rootPath,{recursive:!0,force:!0})}}}let N=e=>e;export{analyze,build,dev}from"./938.js";export{v as DoubaoAppsSDK,D as create,N as defineConfig};
3
3
  //# sourceMappingURL=index.js.map
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doubao-apps/kit",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "types": "./dist/types.d.ts",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  "@ast-grep/napi": "^0.30.0",
40
40
  "@lynx-js/external-bundle-rsbuild-plugin": "npm:@upupming/external-bundle-rsbuild-plugin-canary@0.0.3-canary-20260308-21e426dc",
41
41
  "@lynx-js/react-alias-rsbuild-plugin": "0.12.7",
42
- "@lynx-js/react-rsbuild-plugin": "npm:@upupming/react-rsbuild-plugin-canary@0.12.10-canary-20260308-21e426dc",
42
+ "@lynx-js/react-rsbuild-plugin": "npm:@lynx-js/react-rsbuild-plugin-canary@0.12.11-canary-20260312-39fdf1ab",
43
43
  "@lynx-js/rspeedy": "0.13.3",
44
44
  "@lynx-js/runtime-wrapper-webpack-plugin": "0.1.3",
45
45
  "@lynx-js/types": "3.6.0",
Binary file