@doubao-apps/create 0.0.23 → 0.0.24
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/36.js +4 -2
- package/dist/cli.js +18 -18
- package/dist/index.d.ts +2 -1
- package/dist/template-empty/.ai/reference/open-api.md +3 -3
- package/dist/template-empty/AGENTS.md +0 -1
- package/dist/template-empty/package.json +3 -3
- package/dist/template-starter/.ai/reference/open-api.md +3 -3
- package/dist/template-starter/AGENTS.md +0 -1
- package/dist/template-starter/README.md +0 -3
- package/dist/template-starter/package.json +3 -3
- package/dist/template-starter/src/mcp-ui/privacy.ts +11 -0
- package/package.json +1 -1
package/dist/36.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import"node:module";import e from"node:path";import t,{promises as r}from"node:fs";import{
|
|
2
|
-
`
|
|
1
|
+
import"node:module";import e from"node:path";import t,{promises as r}from"node:fs";import{execFileSync as a}from"node:child_process";import{fileURLToPath as o}from"node:url";let i=e.join("src","app.ts");function n(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 s(t,a,o=""){let c,l=e.join(t,i);try{c=await r.readFile(l,"utf8")}catch(e){if(e?.code==="ENOENT")return;throw e}let p=c.replace("<%= appId %>",n(a)).replace("<%= name %>",n(o));p!==c&&await r.writeFile(l,p,"utf8")}let c=new Set(["node_modules","dist",".git"]);async function l(t,a,o={}){let{includeAI:i=!0}=o,n=async(t,a)=>{for(let o of(await r.mkdir(a,{recursive:!0}),await r.readdir(t,{withFileTypes:!0}))){let s=e.join(t,o.name),l=e.join(a,o.name);if(o.isDirectory()){if(c.has(o.name)||".ai"===o.name&&!i)continue;await n(s,l)}else{if("AGENTS.md"===o.name&&!i)continue;await r.copyFile(s,l)}}};await n(t,a)}let p=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"]],u=["doubao.config.ts"],f=["@byted-doubao-apps/deploy","@doubao-apps/deploy"],m=["deploy"],y=["pnpm run deploy","doubao.config.ts","部署到豆包平台"];function w(e){let t=e;for(let[e,r]of d)t=t.replace(RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),r);return t}async function h(t,a){for(let i of(await r.readdir(t,{withFileTypes:!0}))){var o;let n=e.join(t,i.name);if(function(e){return u.some(t=>t===e)}(i.name)){await r.rm(n,{recursive:!0,force:!0});continue}if(i.isDirectory()){await h(n,a);continue}if(o=i.name,!p.has(e.extname(o))&&"package.json"!==o&&"tsconfig.json"!==o)continue;let s=await r.readFile(n,"utf-8");await r.writeFile(n,function(e,t,r){if("package.json"===e){let e=JSON.parse(w(t));if(e.scripts&&"object"==typeof e.scripts){for(let t of m)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 a of Object.keys(e[t]))f.some(e=>e===a)?delete e[t][a]:a.startsWith("@doubao-apps/")&&(e[t][a]=`^${r}`);0===Object.keys(e[t]).length&&delete e[t]}return`${JSON.stringify(e,null,2)}
|
|
2
|
+
`}return"README.md"===e||"AGENTS.md"===e?w(t).split("\n").filter(e=>!y.some(t=>e.includes(t))).join("\n"):w(t)}(i.name,s,a))}}function b(e){return e?/[<>:"|?*\x00-\x1F]/.test(e)?{valid:!1,error:"Project name contains invalid characters"}:[".",".."].includes(e)?{valid:!1,error:"Project name is reserved"}:{valid:!0}:{valid:!1,error:"Project name is required"}}function j(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z0-9-~._]+/g,"-")}async function g(r,a){let o=e.join(r,"package.json");if(!t.existsSync(o))throw Error("package.json not found in template");let i=JSON.parse(t.readFileSync(o,"utf-8"));i.name=a,t.writeFileSync(o,`${JSON.stringify(i,null,2)}
|
|
3
|
+
`)}let E=["starter","empty"],N=[{value:"starter",label:"Starter (default)",hint:"Starter template with example pages"},{value:"empty",label:"Empty",hint:"Minimal template without example pages"}];function v(e){return E.includes(e)}let S=o(import.meta.url),$=e.dirname(S),T={".gitignore":["dist","node_modules",".DS_Store"]};async function O(t){for(let[a,o]of Object.entries(T))await r.writeFile(e.join(t,a),`${o.join("\n")}
|
|
4
|
+
`)}async function k(){let t=e.resolve($,"..","package.json");return JSON.parse(await r.readFile(t,"utf-8")).version??"0.0.1"}async function F(t){let o=e.join(t,".git");if(!await r.stat(o).then(e=>e.isDirectory()).catch(e=>{if(e?.code==="ENOENT")return!1;throw e}))try{a("git",["init"],{cwd:t,stdio:"ignore"})}catch(e){if(e?.code==="ENOENT")return;throw Error(`Failed to initialize git repository: ${t}`,{cause:e})}}async function x({template:t,projectDir:a,public:o=!0,includeAI:i,appId:n,name:c,packageName:p,overwrite:d}){if(!e.isAbsolute(a))throw Error(`Project directory must be an absolute path: ${a}`);if(!v(t))throw Error(`Invalid template: ${t}. Valid options: ${E.join(", ")}`);let u=e.resolve($,`template-${t}`);try{if(!(await r.stat(u)).isDirectory())throw Error(`Template path is not a directory: ${u}`)}catch(e){if(e?.code==="ENOENT")throw Error(`Template directory not found: ${u}`,{cause:e});throw Error(`Unable to access template directory: ${u}`,{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&&!d)throw Error(`Project directory is not empty: ${a}`)}else await r.mkdir(a,{recursive:!0});await l(u,a,{includeAI:i}),o&&await h(a,await k()),await O(a),await F(a);let f=p??j(e.basename(a));await g(a,f),await s(a,n??`com.doubao.${f}`,c??"")}export{E as TEMPLATES,N as TEMPLATE_CHOICES,x as create,j as formatProjectName,v as isValidTemplate,t as node_fs,e as node_path,b as validateProjectName};
|
|
3
5
|
//# sourceMappingURL=36.js.map
|
package/dist/cli.js
CHANGED
|
@@ -37,11 +37,11 @@ ${b.gray(Dc+Dl.repeat(s+2)+Dh)}
|
|
|
37
37
|
`)},Df={message:(D="",{symbol:u=b.gray(DC)}={})=>{let e=[`${b.gray(DC)}`];if(D){let[t,...r]=D.split(`
|
|
38
38
|
`);e.push(`${u} ${t}`,...r.map(D=>`${b.gray(DC)} ${D}`))}process.stdout.write(`${e.join(`
|
|
39
39
|
`)}
|
|
40
|
-
`)},info:D=>{Df.message(D,{symbol:b.blue(Dp)})},success:D=>{Df.message(D,{symbol:b.green(DB)})},step:D=>{Df.message(D,{symbol:b.green(DF)})},warn:D=>{Df.message(D,{symbol:b.yellow(Dm)})},warning:D=>{Df.warn(D)},error:D=>{Df.message(D,{symbol:b.red(Dd)})}};async function Dv({packageScope:D}){var
|
|
41
|
-
`)})(b.bgCyan(b.black(" create-doubao-apps "))));let{values:
|
|
40
|
+
`)},info:D=>{Df.message(D,{symbol:b.blue(Dp)})},success:D=>{Df.message(D,{symbol:b.green(DB)})},step:D=>{Df.message(D,{symbol:b.green(DF)})},warn:D=>{Df.message(D,{symbol:b.yellow(Dm)})},warning:D=>{Df.warn(D)},error:D=>{Df.message(D,{symbol:b.red(Dd)})}};async function Dv({packageScope:D,public:e}){var t,F,a,A;let x=process.stdout.isTTY;x&&(console.clear(),((D="")=>{process.stdout.write(`${b.gray(Di)} ${D}
|
|
41
|
+
`)})(b.bgCyan(b.black(" create-doubao-apps "))));let{values:$,positionals:f}=u({args:process.argv.slice(2),options:{template:{type:"string",short:"t"},name:{type:"string"},help:{type:"boolean",short:"h"},yes:{type:"boolean",short:"y"}},allowPositionals:!0}),v=!0===$.yes;$.help&&(t=D,console.log(`
|
|
42
42
|
${b.bold("Usage:")}
|
|
43
|
-
npm create ${
|
|
44
|
-
pnpm create ${
|
|
43
|
+
npm create ${t} [project-directory] [options]
|
|
44
|
+
pnpm create ${t} [project-directory] [options]
|
|
45
45
|
|
|
46
46
|
${b.bold("Options:")}
|
|
47
47
|
-t, --template <name> Template to use (starter, empty) [default: starter]
|
|
@@ -50,32 +50,32 @@ ${b.bold("Options:")}
|
|
|
50
50
|
-h, --help Show this help message
|
|
51
51
|
|
|
52
52
|
${b.bold("Examples:")}
|
|
53
|
-
npm create ${
|
|
54
|
-
npm create ${
|
|
55
|
-
npm create ${
|
|
56
|
-
npm create ${
|
|
57
|
-
pnpm create ${
|
|
58
|
-
`),process.exit(0));let
|
|
59
|
-
${Dg(this.state)} ${
|
|
53
|
+
npm create ${t} my-app
|
|
54
|
+
npm create ${t} my-app --name "My App"
|
|
55
|
+
npm create ${t} my-app --template empty
|
|
56
|
+
npm create ${t} my-app --template empty -y
|
|
57
|
+
pnpm create ${t}
|
|
58
|
+
`),process.exit(0));let y=f[0];if(y){let D=c(y);D.valid||(Df.error(D.error||"Invalid project directory"),process.exit(1))}else{v&&(Df.error("Project directory is required in quick mode. Use: create-doubao-apps <project-directory> [options]"),process.exit(1));let D=await Db({message:"Project directory:",placeholder:"my-doubao-app",validate:D=>{if(!D)return"Project directory is required";let u=c(D);if(!u.valid)return u.error||"Invalid project name"}});D===K&&(D$("Operation cancelled"),process.exit(0)),y=D}let w=E.resolve(process.cwd(),y),_=!1;if(m.existsSync(w)&&m.readdirSync(w).length>0){v&&(Df.error(`Directory ${b.cyan(y)} is not empty. Aborting.`),process.exit(1));let D=await DA({message:`Directory ${b.cyan(y)} is not empty. Continue?`});D!==K&&D||(D$("Operation cancelled"),process.exit(0)),_=!0}let M="starter";if($.template)h($.template)||(Df.error(`Invalid template: ${$.template}. Valid options: ${p.join(", ")}`),process.exit(1)),M=$.template;else if(!v){let D,u=await (F={message:"Select a template:",options:[...B],initialValue:"starter"},D=(D,u)=>{let e=D.label??String(D.value);switch(u){case"selected":return`${b.dim(e)}`;case"active":return`${b.green(Dn)} ${e} ${D.hint?b.dim(`(${D.hint})`):""}`;case"cancelled":return`${b.strikethrough(b.dim(e))}`;default:return`${b.dim(Da)} ${b.dim(e)}`}},new X({options:F.options,initialValue:F.initialValue,render(){let u=`${b.gray(DC)}
|
|
59
|
+
${Dg(this.state)} ${F.message}
|
|
60
60
|
`;switch(this.state){case"submit":return`${u}${b.gray(DC)} ${D(this.options[this.cursor],"selected")}`;case"cancel":return`${u}${b.gray(DC)} ${D(this.options[this.cursor],"cancelled")}
|
|
61
|
-
${b.gray(DC)}`;default:return`${u}${b.cyan(DC)} ${(D=>{let{cursor:u,options:e,style:t}=D,r=D.maxItems??1/0,s=Math.min(Math.max(process.stdout.rows-4,0),Math.max(r,5)),F=0;u>=0+s-3?F=Math.max(Math.min(u-s+3,e.length-s),0):u<F+2&&(F=Math.max(u-2,0));let i=s<e.length&&F>0,C=s<e.length&&F+s<e.length;return e.slice(F,F+s).map((D,e,r)=>{let s=e===r.length-1&&C;return 0===e&&i||s?b.dim("..."):t(D,e+F===u)})})({cursor:this.cursor,options:this.options,maxItems:
|
|
61
|
+
${b.gray(DC)}`;default:return`${u}${b.cyan(DC)} ${(D=>{let{cursor:u,options:e,style:t}=D,r=D.maxItems??1/0,s=Math.min(Math.max(process.stdout.rows-4,0),Math.max(r,5)),F=0;u>=0+s-3?F=Math.max(Math.min(u-s+3,e.length-s),0):u<F+2&&(F=Math.max(u-2,0));let i=s<e.length&&F>0,C=s<e.length&&F+s<e.length;return e.slice(F,F+s).map((D,e,r)=>{let s=e===r.length-1&&C;return 0===e&&i||s?b.dim("..."):t(D,e+F===u)})})({cursor:this.cursor,options:this.options,maxItems:F.maxItems,style:(u,e)=>D(u,e?"active":"inactive")}).join(`
|
|
62
62
|
${b.cyan(DC)} `)}
|
|
63
63
|
${b.cyan(Do)}
|
|
64
|
-
`}}}).prompt());u===K&&(D$("Operation cancelled"),process.exit(0)),
|
|
64
|
+
`}}}).prompt());u===K&&(D$("Operation cancelled"),process.exit(0)),M=u}let S=l(E.basename(w)),T=S;if(!v&&x){let D=await Db({message:`Package name: ${b.dim(`(${S})`)}`,placeholder:S,defaultValue:S,validate:D=>{let u=D||S;if(!/^[@a-z0-9-~][a-z0-9-._~]*$/.test(u))return"Invalid package name"}});D===K&&(D$("Operation cancelled"),process.exit(0)),T=D||S}let j=`com.doubao.${S}`,k=j;if(!v&&x){let D=await Db({message:`appId: ${b.dim(`(${j})`)}`,placeholder:j,defaultValue:j,validate:D=>{let u=D||j;if(!/^[a-z0-9][a-z0-9._-]*$/i.test(u))return"Invalid appId"}});D===K&&(D$("Operation cancelled"),process.exit(0)),k=D||j}let I=!1;if(!v&&x){let D=await DA({message:"Include AI development knowledge base?",initialValue:!1});D===K&&(D$("Operation cancelled"),process.exit(0)),I=D}let R=null;try{x?(R=(({indicator:D="dots"}={})=>{let u=Du?["◒","◐","◓","◑"]:["•","o","O","0"],e=Du?80:120,t="true"===process.env.CI,F,a,l=!1,E="",c,h=performance.now(),p=D=>{l&&x(D>1?"Something went wrong":"Canceled",D)},B=()=>p(2),m=()=>p(1),d=()=>{if(void 0===c)return;t&&process.stdout.write(`
|
|
65
65
|
`);let D=c.split(`
|
|
66
66
|
`);process.stdout.write(g.cursor.move(-999,D.length-1)),process.stdout.write(g.erase.down(D.length))},A=D=>{let u=(performance.now()-D)/1e3,e=Math.floor(u/60),t=Math.floor(u%60);return e>0?`[${e}m ${t}s]`:`[${t}s]`},x=(u="",e=0)=>{l=!1,clearInterval(a),d();let t=0===e?b.green(DF):1===e?b.red(Dr):b.red(Ds);E=(u??E).replace(/\.+$/,""),"timer"===D?process.stdout.write(`${t} ${E} ${A(h)}
|
|
67
67
|
`):process.stdout.write(`${t} ${E}
|
|
68
68
|
`),process.removeListener("uncaughtExceptionMonitor",B),process.removeListener("unhandledRejection",B),process.removeListener("SIGINT",m),process.removeListener("SIGTERM",m),process.removeListener("exit",p),F()};return{start:(x="")=>{l=!0,F=function({input:D=r,output:u=s,overwrite:e=!0,hideCursor:t=!0}={}){let F=C({input:D,output:u,prompt:"",tabSize:1});o(D,F),D.isTTY&&D.setRawMode(!0);let a=(r,{name:s,sequence:F})=>{if(G([String(r),s,F],"cancel")){t&&u.write(g.cursor.show),process.exit(0);return}e&&n(u,"return"===s?0:-1,"return"===s?-1:0,()=>{i(u,1,()=>{D.once("keypress",a)})})};return t&&u.write(g.cursor.hide),D.once("keypress",a),()=>{D.off("keypress",a),t&&u.write(g.cursor.show),D.isTTY&&!z&&D.setRawMode(!1),F.terminal=!1,F.close()}}(),E=x.replace(/\.+$/,""),h=performance.now(),process.stdout.write(`${b.gray(DC)}
|
|
69
|
-
`);let $=0,f=0;process.on("uncaughtExceptionMonitor",B),process.on("unhandledRejection",B),process.on("SIGINT",m),process.on("SIGTERM",m),process.on("exit",p),a=setInterval(()=>{if(t&&E===c)return;d(),c=E;let e=b.magenta(u[$]);if(t)process.stdout.write(`${e} ${E}...`);else if("timer"===D)process.stdout.write(`${e} ${E} ${A(h)}`);else{let D=".".repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${e} ${E}${D}`)}$=$+1<u.length?$+1:0,f=f<u.length?f+.125:0},e)},stop:x,message:(D="")=>{E=(D??E).replace(/\.+$/,"")}}})()).start("Creating project..."):console.log("Creating project..."),await d({template:
|
|
69
|
+
`);let $=0,f=0;process.on("uncaughtExceptionMonitor",B),process.on("unhandledRejection",B),process.on("SIGINT",m),process.on("SIGTERM",m),process.on("exit",p),a=setInterval(()=>{if(t&&E===c)return;d(),c=E;let e=b.magenta(u[$]);if(t)process.stdout.write(`${e} ${E}...`);else if("timer"===D)process.stdout.write(`${e} ${E} ${A(h)}`);else{let D=".".repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${e} ${E}${D}`)}$=$+1<u.length?$+1:0,f=f<u.length?f+.125:0},e)},stop:x,message:(D="")=>{E=(D??E).replace(/\.+$/,"")}}})()).start("Creating project..."):console.log("Creating project..."),await d({template:M,projectDir:w,public:e,includeAI:I,appId:k,name:$.name??"",packageName:T,overwrite:_}),x&&R?(R.stop("Project created successfully!"),Dx(`cd ${y}
|
|
70
70
|
pnpm install
|
|
71
|
-
pnpm dev`,"Next steps"),
|
|
71
|
+
pnpm dev`,"Next steps"),I&&Dx(`📚 AI knowledge base included!
|
|
72
72
|
• Main guide: ${b.cyan("AGENTS.md")}
|
|
73
73
|
• Documentation: ${b.cyan(".ai/")}`,"AI Development Support"),((D="")=>{process.stdout.write(`${b.gray(DC)}
|
|
74
74
|
${b.gray(Do)} ${D}
|
|
75
75
|
|
|
76
|
-
`)})(b.green("Done! Happy coding!"))):(
|
|
76
|
+
`)})(b.green("Done! Happy coding!"))):(a=y,A=I,console.log(b.green("✓ Project created successfully!")),console.log(`
|
|
77
77
|
Next steps:
|
|
78
|
-
cd ${
|
|
78
|
+
cd ${a}
|
|
79
79
|
pnpm install
|
|
80
|
-
pnpm dev`),
|
|
80
|
+
pnpm dev`),A&&console.log("\nAI Development Support:\n \uD83D\uDCDA Main guide: AGENTS.md\n \uD83D\uDCDA Documentation: .ai/"))}catch(D){x&&R?(R.stop("Failed to create project"),Df.error(D instanceof Error?D.message:String(D))):(console.error(b.red("✗ Failed to create project")),console.error(D instanceof Error?D.message:String(D))),process.exit(1)}}b.gray(DC),Dv({packageScope:"@doubao-apps",public:!0}).catch(D=>{console.error(D),process.exit(1)});
|
|
81
81
|
//# sourceMappingURL=cli.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export declare function create({ template, projectDir, includeAI, appId, name, packageName, overwrite }: CreateOptions): Promise<void>;
|
|
1
|
+
export declare function create({ template, projectDir, public: isPublic, includeAI, appId, name, packageName, overwrite }: CreateOptions): Promise<void>;
|
|
2
2
|
|
|
3
3
|
declare interface CreateOptions {
|
|
4
4
|
template: Template;
|
|
5
5
|
projectDir: string;
|
|
6
|
+
public?: boolean;
|
|
6
7
|
includeAI?: boolean;
|
|
7
8
|
appId?: string;
|
|
8
9
|
name?: string;
|
|
@@ -265,7 +265,7 @@ console.log(result.host?.appId, result.enableDebug);
|
|
|
265
265
|
#### Example
|
|
266
266
|
|
|
267
267
|
```typescript
|
|
268
|
-
import { getLocation } from '@
|
|
268
|
+
import { getLocation } from '@doubao-apps/framework';
|
|
269
269
|
|
|
270
270
|
async function fetchLocation() {
|
|
271
271
|
try {
|
|
@@ -305,7 +305,7 @@ fetchLocation();
|
|
|
305
305
|
#### Example
|
|
306
306
|
|
|
307
307
|
```ts
|
|
308
|
-
import { getNetworkType } from '@
|
|
308
|
+
import { getNetworkType } from '@doubao-apps/framework/api';
|
|
309
309
|
|
|
310
310
|
const result = await getNetworkType();
|
|
311
311
|
console.log(result.networkType);
|
|
@@ -1038,7 +1038,7 @@ setStorageSync({
|
|
|
1038
1038
|
#### Example
|
|
1039
1039
|
|
|
1040
1040
|
```typescript
|
|
1041
|
-
import { showToast } from '@
|
|
1041
|
+
import { showToast } from '@doubao-apps/framework';
|
|
1042
1042
|
|
|
1043
1043
|
// 显示一个成功的 Toast
|
|
1044
1044
|
showToast({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
|
-
"name": "
|
|
3
|
+
"name": "doubao-apps-empty-example",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "doubao dev",
|
|
6
6
|
"build": "doubao build"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@doubao-apps/framework": "^0.0.
|
|
9
|
+
"@doubao-apps/framework": "^0.0.24"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@doubao-apps/kit": "^0.0.
|
|
12
|
+
"@doubao-apps/kit": "^0.0.24",
|
|
13
13
|
"typescript": "5.5.3"
|
|
14
14
|
},
|
|
15
15
|
"version": "0.0.16"
|
|
@@ -265,7 +265,7 @@ console.log(result.host?.appId, result.enableDebug);
|
|
|
265
265
|
#### Example
|
|
266
266
|
|
|
267
267
|
```typescript
|
|
268
|
-
import { getLocation } from '@
|
|
268
|
+
import { getLocation } from '@doubao-apps/framework';
|
|
269
269
|
|
|
270
270
|
async function fetchLocation() {
|
|
271
271
|
try {
|
|
@@ -305,7 +305,7 @@ fetchLocation();
|
|
|
305
305
|
#### Example
|
|
306
306
|
|
|
307
307
|
```ts
|
|
308
|
-
import { getNetworkType } from '@
|
|
308
|
+
import { getNetworkType } from '@doubao-apps/framework/api';
|
|
309
309
|
|
|
310
310
|
const result = await getNetworkType();
|
|
311
311
|
console.log(result.networkType);
|
|
@@ -1038,7 +1038,7 @@ setStorageSync({
|
|
|
1038
1038
|
#### Example
|
|
1039
1039
|
|
|
1040
1040
|
```typescript
|
|
1041
|
-
import { showToast } from '@
|
|
1041
|
+
import { showToast } from '@doubao-apps/framework';
|
|
1042
1042
|
|
|
1043
1043
|
// 显示一个成功的 Toast
|
|
1044
1044
|
showToast({
|
|
@@ -31,8 +31,6 @@ pnpm run dev
|
|
|
31
31
|
# 构建项目
|
|
32
32
|
pnpm run build
|
|
33
33
|
|
|
34
|
-
# 部署到豆包平台
|
|
35
|
-
pnpm run deploy
|
|
36
34
|
|
|
37
35
|
# 分析构建产物
|
|
38
36
|
pnpm run analyze
|
|
@@ -44,7 +42,6 @@ pnpm run analyze
|
|
|
44
42
|
|
|
45
43
|
```
|
|
46
44
|
.
|
|
47
|
-
├── doubao.config.ts # 项目配置文件
|
|
48
45
|
├── package.json # 依赖管理
|
|
49
46
|
├── tsconfig.json # TypeScript 配置
|
|
50
47
|
├── src/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
|
-
"name": "
|
|
3
|
+
"name": "doubao-apps-example",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "doubao dev",
|
|
6
6
|
"build": "doubao build"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@doubao-apps/framework": "^0.0.
|
|
9
|
+
"@doubao-apps/framework": "^0.0.24"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@doubao-apps/kit": "^0.0.
|
|
12
|
+
"@doubao-apps/kit": "^0.0.24",
|
|
13
13
|
"typescript": "5.5.3"
|
|
14
14
|
},
|
|
15
15
|
"version": "0.0.16"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { definePrivacyApi, type PrivacyAgreeResult } from '@doubao-apps/framework';
|
|
2
|
+
|
|
3
|
+
export default definePrivacyApi({
|
|
4
|
+
onAgreePrivacy: async (_res: PrivacyAgreeResult) => {
|
|
5
|
+
console.log('onAgreePrivacy', _res);
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
onRefusePrivacy: async () => {
|
|
9
|
+
console.log('onRefusePrivacy');
|
|
10
|
+
}
|
|
11
|
+
});
|