@doubao-apps/kit 0.0.26 → 0.0.27
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/971.js +54 -37
- package/dist/cli/index.js +1 -1
- package/dist/exports/builder.js +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"node:module";import{program as e}from"commander";import"../131.js";import{logger as o,chalk_0 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.
|
|
1
|
+
import"node:module";import{program as e}from"commander";import"../131.js";import{logger as o,chalk_0 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.27")}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.27"){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
|
package/dist/exports/builder.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"node:module";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_CONFIG_NAME,APP_PACKAGE_NAME,AppletLynxPlugin,AppletMainEntryCheckPlugin,AppletMainPlugin,BASE_FOLDER,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,ViewConfigCreator,WIDGETS,WorkerConfigCreator,analyzeMainThreadConvention,analyzeMcpUIEntries,analyzeToolEntries,analyzeViewConvention,analyzeViewEntries,collectProperties,collectViewMetadata,collectWorkerMetadata,createBuilder,createLaunch,createMainCode,createMainEntryObject,createReactLynxEntries,getAppEntry,getDebugDriver,getExternalBundleExternals,getFrameworkApiPackage,getFrameworkPackageJSONRequests,getKeyName,getLocalAreaNetworkAddress,getLocalAreaNetworkUrl,getPreferredLanAddress,getViewEntries,isAppTemplateJsDisabled,isArrayExpression,isBooleanLiteral,isCallExpression,isDebugMode,isExternalBundleDisabled,isFrameworkPackage,isGenerateLoginCardDisabled,isIdentifier,isKeyValueProperty,isLegacyFrameworkEnabled,isNewContainerDisabled,isNumericLiteral,isObjectExpression,isProd,isRspeedyDebugMode,isSigningEncryptionDisabled,isSpreadElement,isStringLiteral,resolveComponentsLoader,resolveFrameworkPackage,resolveRequest}from"../971.js";export{parseSync,simple}from"../131.js";export{e as PromiseManager};
|
|
1
|
+
import"node:module";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_CONFIG_NAME,APP_PACKAGE_NAME,AppletLynxPlugin,AppletMainEntryCheckPlugin,AppletMainPlugin,BASE_FOLDER,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,ViewConfigCreator,WIDGETS,WorkerConfigCreator,analyzeMainThreadConvention,analyzeMcpUIEntries,analyzeToolEntries,analyzeViewConvention,analyzeViewEntries,collectProperties,collectViewMetadata,collectWorkerMetadata,createBuilder,createExpiredWidgetEntries,createLaunch,createMainCode,createMainEntryObject,createMcpUIEntries,createReactLynxEntries,getAppEntry,getDebugDriver,getExternalBundleExternals,getFrameworkApiPackage,getFrameworkPackageJSONRequests,getKeyName,getLocalAreaNetworkAddress,getLocalAreaNetworkUrl,getPreferredLanAddress,getViewEntries,isAppTemplateJsDisabled,isArrayExpression,isBooleanLiteral,isCallExpression,isDebugMode,isExternalBundleDisabled,isFrameworkPackage,isGenerateLoginCardDisabled,isIdentifier,isKeyValueProperty,isLegacyFrameworkEnabled,isNewContainerDisabled,isNumericLiteral,isObjectExpression,isProd,isRspeedyDebugMode,isSigningEncryptionDisabled,isSpreadElement,isStringLiteral,resolveComponentsLoader,resolveFrameworkPackage,resolveRequest}from"../971.js";export{parseSync,simple}from"../131.js";export{e as PromiseManager};
|
|
2
2
|
//# sourceMappingURL=builder.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{execFileSync as t}from"node:child_process";import{getDoubaoAppsDomain as a,node_path as
|
|
2
|
-
`}return"README.md"===e||"AGENTS.md"===e?
|
|
3
|
-
`)}let
|
|
4
|
-
`)}async function
|
|
1
|
+
import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{execFileSync as t}from"node:child_process";import{getDoubaoAppsDomain as a,node_path as o,fileURLToPath as r,promises as i,getPPEEnvironmentHeader as n,isDebugMode as s,node_fs as c,getDebugScenes as p,Launcher as l,executeDebugScene as d,loadDebugScene as u,archivePackage as f,getDebugDriver as y}from"./971.js";import"./131.js";let g=o.join("src","app.config.ts"),h=o.join("src","app.ts");function m(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 w(e,t,a=""){for(let r of[g,h].map(t=>o.join(e,t))){let e;try{e=await i.readFile(r,"utf8")}catch(e){if(e?.code==="ENOENT")continue;throw e}let o=e.replace("<%= appId %>",m(t)).replace("<%= name %>",m(a));o!==e&&await i.writeFile(r,o,"utf8")}}let b=new Set(["node_modules","dist",".git"]);async function E(e,t,a={}){let{includeAI:r=!0}=a,n=async(e,t)=>{for(let a of(await i.mkdir(t,{recursive:!0}),await i.readdir(e,{withFileTypes:!0}))){let s=o.join(e,a.name),c=o.join(t,a.name);if(a.isDirectory()){if(b.has(a.name)||".ai"===a.name&&!r)continue;await n(s,c)}else{if("AGENTS.md"===a.name&&!r)continue;await i.copyFile(s,c)}}};await n(e,t)}let j=new Set([".js",".cjs",".mjs",".ts",".tsx",".jsx",".json",".md",".txt",".scss",".css",".less",".html",".yml",".yaml"]),D=[["@byted-doubao-apps/framework","@doubao-apps/framework"],["@byted-doubao-apps/kit","@doubao-apps/kit"],["@byted-doubao-apps/ai","@doubao-apps/ai"],["@byted-doubao-apps/create","@doubao-apps/create"],["@byted-doubao-apps/taro-runtime","@doubao-apps/taro-runtime"]],_=["doubao.config.ts"],v=["@byted-doubao-apps/deploy","@doubao-apps/deploy"],S=["deploy"],N=["pnpm run deploy","doubao.config.ts","部署到豆包平台"];function O(e){let t=e;for(let[e,a]of D)t=t.replace(RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),a);return t}async function T(e,t){for(let r of(await i.readdir(e,{withFileTypes:!0}))){var a;let n=o.join(e,r.name);if(function(e){return _.some(t=>t===e)}(r.name)){await i.rm(n,{recursive:!0,force:!0});continue}if(r.isDirectory()){await T(n,t);continue}if(a=r.name,!j.has(o.extname(a))&&"package.json"!==a&&"tsconfig.json"!==a)continue;let s=await i.readFile(n,"utf-8");await i.writeFile(n,function(e,t,a){if("package.json"===e){let e=JSON.parse(O(t));if(e.scripts&&"object"==typeof e.scripts){for(let t of S)delete e.scripts[t];0===Object.keys(e.scripts).length&&delete e.scripts}for(let t of["dependencies","devDependencies","peerDependencies"])if(e[t]&&"object"==typeof e[t]){for(let o of Object.keys(e[t]))v.some(e=>e===o)?delete e[t][o]:o.startsWith("@doubao-apps/")&&(e[t][o]=`^${a}`);0===Object.keys(e[t]).length&&delete e[t]}return`${JSON.stringify(e,null,2)}
|
|
2
|
+
`}return"README.md"===e||"AGENTS.md"===e?O(t).split("\n").filter(e=>!N.some(t=>e.includes(t))).join("\n"):O(t)}(r.name,s,t))}}async function $(e,t){let a=o.join(e,"package.json");if(!c.existsSync(a))throw Error("package.json not found in template");let r=JSON.parse(c.readFileSync(a,"utf-8"));r.name=t,c.writeFileSync(a,`${JSON.stringify(r,null,2)}
|
|
3
|
+
`)}let P=["starter","empty"],k=r(import.meta.url),x=o.dirname(k),C={".gitignore":["dist","node_modules",".DS_Store"]};async function F(e){for(let[t,a]of Object.entries(C))await i.writeFile(o.join(e,t),`${a.join("\n")}
|
|
4
|
+
`)}async function A(){let e=o.resolve(x,"..","package.json");return JSON.parse(await i.readFile(e,"utf-8")).version??"0.0.1"}async function K(e){let a=o.join(e,".git");if(!await i.stat(a).then(e=>e.isDirectory()).catch(e=>{if(e?.code==="ENOENT")return!1;throw e}))try{t("git",["init"],{cwd:e,stdio:"ignore"})}catch(t){if(t?.code==="ENOENT")return;throw Error(`Failed to initialize git repository: ${e}`,{cause:t})}}async function R({template:e,projectDir:t,public:a=!0,includeAI:r,appId:n,name:s,packageName:c,overwrite:p}){if(!o.isAbsolute(t))throw Error(`Project directory must be an absolute path: ${t}`);if(!P.includes(e))throw Error(`Invalid template: ${e}. Valid options: ${P.join(", ")}`);let l=o.resolve(x,`template-${e}`);try{if(!(await i.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 i.stat(t).then(e=>{if(!e.isDirectory())throw Error(`Project path is not a directory: ${t}`);return!0}).catch(e=>{if(e?.code==="ENOENT")return!1;throw Error(`Unable to access project directory: ${t}`,{cause:e})})){if((await i.readdir(t)).length>0&&!p)throw Error(`Project directory is not empty: ${t}`)}else await i.mkdir(t,{recursive:!0});await E(l,t,{includeAI:r}),a&&await T(t,await A()),await F(t),await K(t);let d=c??o.basename(t).trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z0-9-~._]+/g,"-");await $(t,d),await w(t,n??`com.doubao.${d}`,s??"")}let U=e("fs");function I(e){return[{name:"DoubaoAppsDevPlugin",setup(t){t.onDevCompileDone(()=>{e?.onDevCompileDone?.()})}}]}class J{appDirectory;launcher;constructor(e,t=l){this.appDirectory=e,this.launcher=new t(e)}async dev(e={}){let{compileHooks:t,...a}=e;return await this.launcher.dev({...a,rsbuildPlugins:I(t),signingEncryptionOptions:e.signingEncryptionOptions})}async build(e={}){process.env.NODE_ENV="production";let{compileHooks:t,...a}=e;await this.launcher.build({...a,rsbuildPlugins:I(t),signingEncryptionOptions:e.signingEncryptionOptions,versionTag:e.versionTag})}async discoverWidgets(){return Object.values(this.launcher.context.metadata.getData().widgets)}async discoverPages(){return Object.values(this.launcher.context.metadata.getData().pages)}async discoverTools(){return Object.values(this.launcher.context.metadata.getData().tools)}async pushWidget(e){let{widgetId:t,deviceId:a,botId:o,widgetData:r,hdt:i}=e,n=await y({hdt:i,deviceId:a}),s=this.launcher.context.metadata.getData().app.appId;n.pushWidget({appId:s,widgetId:t,widgetData:r,botId:o})}async openPage(e){let{pageId:t,pageData:a,pageSettings:o,mode:r,hdt:i,deviceId:n}=e,s=await y({hdt:i,deviceId:n}),c=this.launcher.context.metadata.getData().app.appId;s.openPage({appId:c,pageId:t,pageData:a,pageSettings:o,mode:r})}async callTool(e){let{toolId:t,toolData:a,hdt:o,deviceId:r}=e,i=await y({hdt:o,deviceId:r}),n=this.launcher.context.metadata.getData().app.appId;i.callTool({appId:n,toolId:t,toolData:a})}async executeDebugScene(e){let{matchedScene:t,deviceId:a,hdt:o}=e,r=this.launcher.context.metadata.getData().app.appId,i=await y({hdt:o,deviceId:a});await d({matchedScene:t,appId:r,driver:i})}async getDebugScenes(){let e=await p(this.appDirectory||process.cwd());return await Promise.all(e.map(async e=>({...e,content:await u(e.path)})))}async deploy(e){let{versionTag:t,cookie:o,appKey:r,signingEncryptionOptions:i}=e;process.env.NODE_ENV="production",await this.launcher.build({skipCleanupRootPath:!0,signingEncryptionOptions:i,versionTag:e.versionTag});let{manifest:c}=this.launcher.context,{appId:p,versionCode:l}=c,{packageResource:d}=await f({channelName:"doubao_app",manifest:c,rootPath:this.launcher.rootPath});if(!d)throw Error("Failed to archive package");let{resource:u}=d,y=new FormData,g=new Blob([new Uint8Array(U.default.readFileSync(u))],{type:"application/zip"});y.append("applet_file",g,"doubao_app.zip"),y.append("applet_version_code",l.toString());let h=encodeURIComponent(t),m=`https://${a(e.internal||!1)}/developer/resource_api/apps/${encodeURIComponent(r||p)}/versions/${h}/package/upload_applet`,w={...n(),Cookie:o};try{let e=await fetch(m,{method:"POST",body:y,headers:w}),t=e.headers.get("x-tt-logid")||"";if(!e.ok){let a=await e.text(),o=JSON.stringify({code:e.status,message:"HTTP Error",data:a,log_id:t});throw Error(o)}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{s()||U.default.rmSync(this.launcher.rootPath,{recursive:!0,force:!0})}}}let z=e=>e,H=e=>e;export{analyze,build,dev}from"./938.js";export{J as DoubaoAppsSDK,R as create,H as defineAppConfig,z as defineConfig};
|
|
5
5
|
//# sourceMappingURL=index.js.map
|