@doubao-apps/kit 0.0.25 → 0.0.26
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 +51 -43
- package/dist/builder/loader/components-loader/index.js +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/exports/builder.js +1 -1
- package/dist/index.js +4 -4
- package/dist/types.d.ts +171 -10
- package/dist/types.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"node:module";import e from"magic-string";import{parseSync as o,simple as t}from"../../../131.js";let r={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",video:"DoubaoVideo","web-view":"DoubaoWebView",image:"DoubaoImage",input:"DoubaoInput",list:"DoubaoList","scroll-view":"DoubaoScrollView",svg:"DoubaoSvg",text:"DoubaoText",textarea:"DoubaoTextArea",view:"DoubaoView"};function a(e){return"Identifier"===e.type&&e.value in r?e.value:null}function
|
|
2
|
-
`;l.prepend(o)}if(l.hasChanged()){let e=l.toString(),o=l.generateMap({includeContent:!0,hires:!0,source:this.resourcePath,file:this.resourcePath});u(null,e,o)}else u(null,
|
|
1
|
+
import"node:module";import e from"magic-string";import{parseSync as o,simple as t}from"../../../131.js";let r={button:"DoubaoButton",map:"DoubaoMap","map-marker":"DoubaoMapMarker","long-image":"DoubaoLongImage","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-divider":"DoubaoPickerDivider","picker-view":"DoubaoPickerView",video:"DoubaoVideo","web-view":"DoubaoWebView",image:"DoubaoImage",input:"DoubaoInput",list:"DoubaoList","scroll-view":"DoubaoScrollView",svg:"DoubaoSvg",text:"DoubaoText",textarea:"DoubaoTextArea",view:"DoubaoView"};function a(e){return"Identifier"===e.type&&e.value in r?e.value:null}function i(e,o,t,r,a){if("Identifier"!==o.type)return;let i=a(o.span.start-r),n=a(o.span.end-r);e.overwrite(i,n,t)}export default function(n){let u=this.async();try{let l=new e(n),p=o(n,{syntax:"typescript",tsx:!0,decorators:!0}),b=function(e){let o=0;for(;o<e.length;){let t=e[o];if(" "===t||" "===t||"\n"===t||"\r"===t||"\f"===t){o+=1;continue}if("/"===t&&"/"===e[o+1]){for(o+=2;o<e.length&&"\n"!==e[o];)o+=1;continue}if("/"===t&&"*"===e[o+1]){for(o+=2;o<e.length&&("*"!==e[o]||"/"!==e[o+1]);)o+=1;o<e.length&&(o+=2);continue}break}return Buffer.byteLength(e.slice(0,o))}(n),s=Math.max(0,p.span.start-b),f=function(e){let o=new Map([[0,0]]),t=0,r=0;for(let a of e)t+=Buffer.byteLength(a),r+=a.length,o.set(t,r);return e=>{let t=o.get(e);if(void 0===t)throw Error(`Unable to map byte offset ${e} to string index`);return t}}(n),m=new Set;if(t(p,{JSXOpeningElement(e){let o=a(e.name);if(!o)return;let t=r[o];i(l,e.name,t,s,f),m.add(t)},JSXClosingElement(e){let o=a(e.name);if(!o)return;let t=r[o];i(l,e.name,t,s,f),m.add(t)}}),m.size>0){let e=Array.from(m).map(e=>{let o=e.replace("Doubao","");return`${o} as ${e}`}).join(", "),o=`import { ${e} } from '@byted-doubao-apps/framework/components';
|
|
2
|
+
`;l.prepend(o)}if(l.hasChanged()){let e=l.toString(),o=l.generateMap({includeContent:!0,hires:!0,source:this.resourcePath,file:this.resourcePath});u(null,e,o)}else u(null,n)}catch(e){u(null,n)}};
|
|
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"../131.js";import{logger as o,
|
|
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.26")}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.26"){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_PACKAGE_NAME,AppletLynxPlugin,AppletMainEntryCheckPlugin,AppletMainPlugin,BASE_FOLDER,
|
|
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};
|
|
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 r,fileURLToPath as o,promises as i,getPPEEnvironmentHeader as n,node_fs as s,getDebugScenes as c,Launcher as p,executeDebugScene as l,isDebugMode as
|
|
2
|
-
`}return"README.md"===e||"AGENTS.md"===e?
|
|
3
|
-
`)}let
|
|
4
|
-
`)}async function C(){let e=r.resolve(
|
|
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 r,fileURLToPath as o,promises as i,getPPEEnvironmentHeader as n,node_fs as s,getDebugScenes as c,Launcher as p,executeDebugScene as l,isDebugMode as d,archivePackage as u,getDebugDriver as f}from"./971.js";import"./131.js";let y=r.join("src","app.ts");function g(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 h(e,t,a=""){let o,n=r.join(e,y);try{o=await i.readFile(n,"utf8")}catch(e){if(e?.code==="ENOENT")return;throw e}let s=o.replace("<%= appId %>",g(t)).replace("<%= name %>",g(a));s!==o&&await i.writeFile(n,s,"utf8")}let m=new Set(["node_modules","dist",".git"]);async function w(e,t,a={}){let{includeAI:o=!0}=a,n=async(e,t)=>{for(let a of(await i.mkdir(t,{recursive:!0}),await i.readdir(e,{withFileTypes:!0}))){let s=r.join(e,a.name),c=r.join(t,a.name);if(a.isDirectory()){if(m.has(a.name)||".ai"===a.name&&!o)continue;await n(s,c)}else{if("AGENTS.md"===a.name&&!o)continue;await i.copyFile(s,c)}}};await n(e,t)}let b=new Set([".js",".cjs",".mjs",".ts",".tsx",".jsx",".json",".md",".txt",".scss",".css",".less",".html",".yml",".yaml"]),E=[["@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"]],j=["doubao.config.ts"],D=["@byted-doubao-apps/deploy","@doubao-apps/deploy"],_=["deploy"],v=["pnpm run deploy","doubao.config.ts","部署到豆包平台"];function S(e){let t=e;for(let[e,a]of E)t=t.replace(RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),a);return t}async function N(e,t){for(let o of(await i.readdir(e,{withFileTypes:!0}))){var a;let n=r.join(e,o.name);if(function(e){return j.some(t=>t===e)}(o.name)){await i.rm(n,{recursive:!0,force:!0});continue}if(o.isDirectory()){await N(n,t);continue}if(a=o.name,!b.has(r.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(S(t));if(e.scripts&&"object"==typeof e.scripts){for(let t of _)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 r of Object.keys(e[t]))D.some(e=>e===r)?delete e[t][r]:r.startsWith("@doubao-apps/")&&(e[t][r]=`^${a}`);0===Object.keys(e[t]).length&&delete e[t]}return`${JSON.stringify(e,null,2)}
|
|
2
|
+
`}return"README.md"===e||"AGENTS.md"===e?S(t).split("\n").filter(e=>!v.some(t=>e.includes(t))).join("\n"):S(t)}(o.name,s,t))}}async function O(e,t){let a=r.join(e,"package.json");if(!s.existsSync(a))throw Error("package.json not found in template");let o=JSON.parse(s.readFileSync(a,"utf-8"));o.name=t,s.writeFileSync(a,`${JSON.stringify(o,null,2)}
|
|
3
|
+
`)}let T=["starter","empty"],$=o(import.meta.url),k=r.dirname($),x={".gitignore":["dist","node_modules",".DS_Store"]};async function P(e){for(let[t,a]of Object.entries(x))await i.writeFile(r.join(e,t),`${a.join("\n")}
|
|
4
|
+
`)}async function C(){let e=r.resolve(k,"..","package.json");return JSON.parse(await i.readFile(e,"utf-8")).version??"0.0.1"}async function F(e){let a=r.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 A({template:e,projectDir:t,public:a=!0,includeAI:o,appId:n,name:s,packageName:c,overwrite:p}){if(!r.isAbsolute(t))throw Error(`Project directory must be an absolute path: ${t}`);if(!T.includes(e))throw Error(`Invalid template: ${e}. Valid options: ${T.join(", ")}`);let l=r.resolve(k,`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 w(l,t,{includeAI:o}),a&&await N(t,await C()),await P(t),await F(t);let d=c??r.basename(t).trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z0-9-~._]+/g,"-");await O(t,d),await h(t,n??`com.doubao.${d}`,s??"")}let K=e("fs");function R(e){return[{name:"DoubaoAppsDevPlugin",setup(t){t.onDevCompileDone(()=>{e?.onDevCompileDone?.()})}}]}class U{appDirectory;launcher;constructor(e,t=p){this.appDirectory=e,this.launcher=new t(e)}async dev(e={}){let{compileHooks:t,...a}=e;return await this.launcher.dev({...a,rsbuildPlugins:R(t),signingEncryptionOptions:e.signingEncryptionOptions})}async build(e={}){process.env.NODE_ENV="production";let{compileHooks:t,...a}=e;await this.launcher.build({...a,rsbuildPlugins:R(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:r,widgetData:o,hdt:i}=e,n=await f({hdt:i,deviceId:a}),s=this.launcher.context.metadata.getData().app.appId;n.pushWidget({appId:s,widgetId:t,widgetData:o,botId:r})}async openPage(e){let{pageId:t,pageData:a,pageSettings:r,mode:o,hdt:i,deviceId:n}=e,s=await f({hdt:i,deviceId:n}),c=this.launcher.context.metadata.getData().app.appId;s.openPage({appId:c,pageId:t,pageData:a,pageSettings:r,mode:o})}async callTool(e){let{toolId:t,toolData:a,hdt:r,deviceId:o}=e,i=await f({hdt:r,deviceId:o}),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:r}=e,o=this.launcher.context.metadata.getData().app.appId,i=await f({hdt:r,deviceId:a});await l({matchedScene:t,appId:o,driver:i})}async getDebugScenes(){return await c(this.appDirectory||process.cwd())}async deploy(e){let{versionTag:t,cookie:r,appKey:o,signingEncryptionOptions:i}=e;process.env.NODE_ENV="production",await this.launcher.build({skipCleanupRootPath:!0,signingEncryptionOptions:i,versionTag:e.versionTag});let{manifest:s}=this.launcher.context,{appId:c,versionCode:p}=s,{packageResource:l}=await u({channelName:"doubao_app",manifest:s,rootPath:this.launcher.rootPath});if(!l)throw Error("Failed to archive package");let{resource:f}=l,y=new FormData,g=new Blob([new Uint8Array(K.default.readFileSync(f))],{type:"application/zip"});y.append("applet_file",g,"doubao_app.zip"),y.append("applet_version_code",p.toString());let h=encodeURIComponent(t),m=`https://${a(e.internal||!1)}/developer/resource_api/apps/${encodeURIComponent(o||c)}/versions/${h}/package/upload_applet`,w={...n(),Cookie:r};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(),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{d()||K.default.rmSync(this.launcher.rootPath,{recursive:!0,force:!0})}}}let I=e=>e,J=e=>e;export{analyze,build,dev}from"./938.js";export{U as DoubaoAppsSDK,A as create,J as defineAppConfig,I as defineConfig};
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
2
1
|
import type { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check';
|
|
3
2
|
import type { ResolveConfig } from '@rsbuild/core';
|
|
4
3
|
import type { SourceConfig } from '@rsbuild/core';
|
|
5
|
-
import type { ZodType } from 'zod';
|
|
6
4
|
|
|
7
|
-
declare
|
|
5
|
+
declare interface AIAppMetadata {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* 豆包应用 ID
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
appId: string;
|
|
12
|
+
/**
|
|
13
|
+
* 应用名称
|
|
14
|
+
*/
|
|
15
|
+
name?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 应用描述
|
|
18
|
+
*/
|
|
19
|
+
description?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 应用图标
|
|
22
|
+
*
|
|
23
|
+
* 1x, 2x, 3x 分别对应 1x, 2x, 3x 倍的图标
|
|
24
|
+
*/
|
|
25
|
+
icons?: string | Record<'1x' | '2x' | '3x', string>;
|
|
26
|
+
/**
|
|
27
|
+
* 应用关键词
|
|
28
|
+
*/
|
|
29
|
+
keywords?: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare type AIPageMetadata = Omit<PageDefinition, 'entry' | 'renderType' | 'digest'>;
|
|
33
|
+
|
|
34
|
+
declare type AIWidgetMetadata = {
|
|
8
35
|
/**
|
|
9
36
|
* The widget unique identifier
|
|
10
37
|
*/
|
|
@@ -46,6 +73,73 @@ declare type AIWidgetMetadata = FunctionalToolIODefinition & {
|
|
|
46
73
|
titleType?: 'none' | 'normal' | 'float';
|
|
47
74
|
};
|
|
48
75
|
|
|
76
|
+
declare interface BaseDefinition {
|
|
77
|
+
/**
|
|
78
|
+
* Unique identifier
|
|
79
|
+
*/
|
|
80
|
+
id: string;
|
|
81
|
+
/**
|
|
82
|
+
* Basic name
|
|
83
|
+
*/
|
|
84
|
+
name?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Describe the characteristics of things
|
|
87
|
+
*/
|
|
88
|
+
description?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 目前 BaseModuleDefinition 用于 Manifest 中的 Applet、Widget、Page 模块
|
|
93
|
+
*/
|
|
94
|
+
declare interface BaseModuleDefinition extends BaseDefinition {
|
|
95
|
+
/**
|
|
96
|
+
* Keywords of things
|
|
97
|
+
*/
|
|
98
|
+
keywords?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Icons
|
|
101
|
+
*/
|
|
102
|
+
icons?: string | Record<'1x' | '2x' | '3x', string>;
|
|
103
|
+
/**
|
|
104
|
+
* Used to check widget is corrected for this package
|
|
105
|
+
*/
|
|
106
|
+
digest: string;
|
|
107
|
+
/**
|
|
108
|
+
* The applet/widget properties, Used to define some limits for user
|
|
109
|
+
*/
|
|
110
|
+
prop?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Define app/page/widget metadata in src/app.config.ts.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* // src/app.config.ts
|
|
119
|
+
* import { defineAppConfig } from '@doubao-apps/kit';
|
|
120
|
+
*
|
|
121
|
+
* export default defineAppConfig({
|
|
122
|
+
* appId: 'your-app-id',
|
|
123
|
+
* name: 'Demo App',
|
|
124
|
+
* pages: {
|
|
125
|
+
* 'pages/home': {
|
|
126
|
+
* id: 'home-page',
|
|
127
|
+
* title: 'Home',
|
|
128
|
+
* description: 'The home page'
|
|
129
|
+
* }
|
|
130
|
+
* },
|
|
131
|
+
* widgets: {
|
|
132
|
+
* 'widgets/card': {
|
|
133
|
+
* id: 'card-widget',
|
|
134
|
+
* name: 'Card Widget',
|
|
135
|
+
* description: 'Show card content'
|
|
136
|
+
* }
|
|
137
|
+
* }
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare const defineAppConfig: (config: DoubaoAppsMetaConfig) => DoubaoAppsMetaConfig;
|
|
142
|
+
|
|
49
143
|
export declare const defineConfig: (config: DoubaoAppsBuildConfig) => DoubaoAppsBuildConfig;
|
|
50
144
|
|
|
51
145
|
export declare interface DoubaoAppsBuildConfig {
|
|
@@ -69,21 +163,77 @@ export declare interface DoubaoAppsBuildConfig {
|
|
|
69
163
|
}
|
|
70
164
|
|
|
71
165
|
/**
|
|
166
|
+
* Metadata config loaded from src/app.config.ts.
|
|
167
|
+
*
|
|
168
|
+
* Use src/app.config.ts for app/page/widget metadata instead of source-level
|
|
169
|
+
* aiMeta or metadata fields in doubao.config.ts.
|
|
72
170
|
*
|
|
73
|
-
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* // src/app.config.ts
|
|
174
|
+
* import { defineAppConfig } from '@doubao-apps/kit';
|
|
175
|
+
*
|
|
176
|
+
* export default defineAppConfig({
|
|
177
|
+
* appId: 'your-app-id',
|
|
178
|
+
* name: 'Demo App',
|
|
179
|
+
* description: 'Describe what this app can do',
|
|
180
|
+
* pages: {
|
|
181
|
+
* 'pages/home': {
|
|
182
|
+
* id: 'home-page',
|
|
183
|
+
* title: 'Home',
|
|
184
|
+
* description: 'The home page'
|
|
185
|
+
* }
|
|
186
|
+
* },
|
|
187
|
+
* widgets: {
|
|
188
|
+
* 'widgets/card': {
|
|
189
|
+
* id: 'card-widget',
|
|
190
|
+
* name: 'Card Widget',
|
|
191
|
+
* description: 'Show card content',
|
|
192
|
+
* border: true
|
|
193
|
+
* }
|
|
194
|
+
* }
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
74
197
|
*/
|
|
75
|
-
declare interface
|
|
198
|
+
export declare interface DoubaoAppsMetaConfig extends Omit<AIAppMetadata, 'appId'> {
|
|
199
|
+
/**
|
|
200
|
+
* 豆包应用 ID
|
|
201
|
+
*/
|
|
202
|
+
appId?: string;
|
|
76
203
|
/**
|
|
77
|
-
*
|
|
204
|
+
* Page 配置
|
|
78
205
|
*/
|
|
79
|
-
|
|
206
|
+
pages?: Record<string, DoubaoAppsPageMetaConfig>;
|
|
80
207
|
/**
|
|
81
|
-
*
|
|
208
|
+
* Widget 配置
|
|
82
209
|
*/
|
|
83
|
-
|
|
210
|
+
widgets?: Record<string, DoubaoAppsWidgetMetaConfig>;
|
|
84
211
|
}
|
|
85
212
|
|
|
86
|
-
declare type
|
|
213
|
+
export declare type DoubaoAppsPageMetaConfig = Omit<AIPageMetadata, 'id' | 'path'> & {
|
|
214
|
+
/**
|
|
215
|
+
* Page ID。不配置时默认以目录名为 ID,例如 pages/account/demo 默认为 demo。
|
|
216
|
+
*/
|
|
217
|
+
id?: string;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export declare type DoubaoAppsWidgetMetaConfig = Omit<AIWidgetMetadata, 'id'> & {
|
|
221
|
+
/**
|
|
222
|
+
* Widget ID。不配置时默认以目录名为 ID,例如 widgets/api/demo 默认为 demo。
|
|
223
|
+
*/
|
|
224
|
+
id?: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
declare interface PageDefinition extends UIModuleDefinition {
|
|
228
|
+
/**
|
|
229
|
+
* The page navbar title
|
|
230
|
+
*/
|
|
231
|
+
title?: string;
|
|
232
|
+
/**
|
|
233
|
+
* The page path
|
|
234
|
+
*/
|
|
235
|
+
path: string;
|
|
236
|
+
}
|
|
87
237
|
|
|
88
238
|
export declare interface TaroPluginOptions {
|
|
89
239
|
/**
|
|
@@ -106,4 +256,15 @@ export declare interface TaroPluginOptions {
|
|
|
106
256
|
|
|
107
257
|
declare type TaroWidgetOptions = Omit<AIWidgetMetadata, 'id'>;
|
|
108
258
|
|
|
259
|
+
declare interface UIModuleDefinition extends BaseModuleDefinition {
|
|
260
|
+
/**
|
|
261
|
+
* The applet/widget render type, used to choose the render engine
|
|
262
|
+
*/
|
|
263
|
+
renderType?: 'lynx';
|
|
264
|
+
/**
|
|
265
|
+
* The view entry
|
|
266
|
+
*/
|
|
267
|
+
entry: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
109
270
|
export { }
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=e=>e;export{e as defineConfig};
|
|
1
|
+
let e=e=>e,f=e=>e;export{f as defineAppConfig,e as defineConfig};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|