@hupu-tech/shaper 0.2.14 → 0.2.16

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -4
  3. package/dist/cli.js +2 -2
  4. package/dist/cloud/client.d.ts +11 -2
  5. package/dist/cloud/service-build.d.ts +4 -3
  6. package/dist/dev-runner.js +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +1 -1
  9. package/dist/project/create.d.ts +4 -10
  10. package/dist/project/templates.d.ts +20 -0
  11. package/dist/shared-UX2SCSGF.js +18 -0
  12. package/dist/{shared-5R34PBDM.js → shared-YWISH7Y2.js} +4 -4
  13. package/package.json +1 -1
  14. package/skills/core/hupu-business/references/runtime.md +3 -4
  15. package/skills/core/shaper-backend/references/deployment.md +3 -3
  16. package/skills/core/shaper-backend/references/node-server.md +4 -4
  17. package/skills/core/shaper-development/SKILL.md +2 -2
  18. package/skills/core/shaper-development/references/project-setup.md +6 -5
  19. package/skills/core/shaper-game-development/SKILL.md +1 -1
  20. package/templates/leaderboard/README.md +1 -1
  21. package/templates/leaderboard/cloud/functions/api/cloud.json +2 -1
  22. package/templates/leaderboard/cloud/gateway/routes.json +4 -2
  23. package/templates/leaderboard/docs/integration.md +1 -1
  24. package/templates/offline-game/README.md +1 -1
  25. package/templates/offline-game/docs/integration.md +1 -1
  26. package/templates/server/README.md +25 -0
  27. package/templates/server/backend/functions/activity/cloud.json +3 -0
  28. package/templates/{cloud-service → server/backend/functions/activity}/package-lock.json +2 -2
  29. package/templates/server/backend/functions/activity/package.json +19 -0
  30. package/templates/server/backend/functions/activity/server.cjs +30 -0
  31. package/templates/server/backend/gateway/routes.json +17 -0
  32. package/templates/server/frontend/index.html +42 -0
  33. package/dist/shared-UKIFY6QO.js +0 -19
  34. package/templates/cloud-service/README.md +0 -7
  35. package/templates/cloud-service/cloud.json +0 -27
  36. package/templates/cloud-service/migrations/202610250001_init.sql +0 -5
  37. package/templates/cloud-service/migrations/202610250002_events.sql +0 -8
  38. package/templates/cloud-service/release.json +0 -11
  39. package/templates/cloud-service/server.cjs +0 -37
@@ -1,13 +1,13 @@
1
- import{a as z,b as a,c as j,d as J,e as I,f as S}from"./shared-BKIED5AA.js";import{realpath as P,mkdir as G,readdir as M,readFile as _,writeFile as at,lstat as T,appendFile as st}from"node:fs/promises";import{resolve as x,join as h,relative as b,sep as k,isAbsolute as W}from"node:path";import{randomUUID as ct}from"node:crypto";import{spawn as pt}from"node:child_process";import dt from"adm-zip";import{z as f}from"zod";import K from"proper-lockfile";var ut=f.object({schemaVersion:f.literal(1),devCommand:f.string().min(1).max(500),buildCommand:f.string().min(1).max(500),outputDir:f.string().min(1),workingDirectory:f.string().min(1).default("."),devUrl:f.string().default("http://127.0.0.1:{port}")}).passthrough(),lt=f.object({schemaVersion:f.literal(1),appId:f.string().min(1).max(200),server:f.string().url()}).strict();async function E(e){if(!e||!W(e))throw new a("WORKSPACE_REQUIRED","\u8BF7\u6307\u5B9A\u5DE5\u7A0B\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002");return P(x(e))}async function D(e,t){return _(h(e,t),"utf8").catch(r=>{if(r.code!=="ENOENT")throw r})}async function B(e){let t=new Set;for(let r of[".shaper/project.json","shaper.config.json","shaper.project.json",".shaper/config.json","activity.json"]){let n=await D(e,r);if(n===void 0)continue;let i=JSON.parse(n);for(let o of[i?.appId,i?.applicationId,r==="activity.json"?i?.activityId:void 0])typeof o=="string"&&o&&t.add(o)}return t}function H(e,t){if(e.size>1||t&&[...e].some(r=>r!==t))throw new a("APP_ID_CONFLICT","\u539F\u9879\u76EE\u5E94\u7528 ID \u4E0E\u76EE\u6807\u4E0D\u4E00\u81F4\uFF1B\u5DF2\u505C\u6B62\uFF0C\u4E0D\u4F1A\u521B\u5EFA\u6216\u5207\u6362\u5E94\u7528\u3002")}async function N(e,t){let r=await D(e,"activity.json"),n=r===void 0?void 0:JSON.parse(r)?.activityId,i=await D(e,"AGENTS.md"),o=await D(e,"skills/act-cloudbase/SKILL.md");if(!(n===void 0&&!i?.includes("<!-- COLORBOX:START -->")&&o===void 0))throw H(await B(e),t),new a("LEGACY_PROJECT_UPGRADE_REQUIRED","\u8FD9\u662F\u65E7\u7248\u9879\u76EE\uFF0C\u8BF7\u7EE7\u7EED\u4F7F\u7528\u539F\u6709\u6280\u80FD\u548C\u5F00\u53D1\u65B9\u5F0F\u3002\u65B0\u7248\u5DE5\u5177\u672A\u4FEE\u6539\u6B64\u9879\u76EE\uFF0C\u5F53\u524D\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u5347\u7EA7\u3002")}async function O(e){let t=h(e,".shaper");if(await G(t,{recursive:!0,mode:448}),(await T(t)).isSymbolicLink())throw new a("UNSAFE_WORKSPACE",".shaper \u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\u3002");return t}async function R(e){return await N(e),ut.parse(await S(h(e,"shaper.config.json")))}async function C(e,t){await N(e);let r=lt.parse(await S(h(e,".shaper","project.json")));if(r.server!==t)throw new a("SERVER_MISMATCH","\u6B64\u5DE5\u7A0B\u7ED1\u5B9A\u7684 Shaper \u670D\u52A1\u4E0E\u5F53\u524D\u767B\u5F55\u670D\u52A1\u4E0D\u540C\u3002\u8BF7\u663E\u5F0F\u5207\u6362\u670D\u52A1\u6216\u91CD\u65B0\u5173\u8054\u3002");return r}async function Y(e,t,r){let n=await O(e);await I(h(n,"project.json"),{schemaVersion:1,appId:t,server:r})}async function Ut(e,t,r={}){if(r.template)throw new a("USE_CREATE","init \u53EA\u5173\u8054\u5E94\u7528\u3002\u9700\u6C42\u660E\u786E\u540E\u4F7F\u7528 shaper create --template \u521B\u5EFA\u5DE5\u7A0B\u3002");if(!t||!W(t))throw new a("WORKSPACE_REQUIRED","\u8BF7\u6307\u5B9A\u5DE5\u7A0B\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002");await G(t,{recursive:!0});let n=await E(t);await N(n,r.appId);let i=await O(n),o=await K.lock(i,{retries:0});try{let c;try{c=await C(n,e.auth.server)}catch(l){if(l.code!=="ENOENT")throw l}if(c&&r.appId&&r.appId!==c.appId)throw new a("ALREADY_LINKED",`\u5F53\u524D\u76EE\u5F55\u5C5E\u4E8E ${c.appId}\uFF0C\u4E0E\u63D0\u793A\u8BCD\u4E2D\u7684 ${r.appId} \u4E0D\u4E00\u81F4\u3002\u8BF7\u56DE\u5230\u539F\u5E94\u7528\u7EE7\u7EED\uFF0C\u6216\u6362\u4E00\u4E2A\u7A7A\u76EE\u5F55\uFF1Binit \u4E0D\u4F1A\u8986\u76D6\u7ED1\u5B9A\u3002`);let u=await B(n),p=c?.appId??r.appId??[...u][0];H(u,p);let d=h(i,"init.json"),s=c?void 0:await S(d).catch(l=>{if(l.code!=="ENOENT")throw l});if(!c&&s&&(!s.appId||s.server!==e.auth.server||p&&p!==s.appId))throw new a("INIT_CONFLICT","\u5B58\u5728\u672A\u5B8C\u6210\u7684\u521D\u59CB\u5316\uFF0C\u8BF7\u6838\u5BF9 .shaper/init.json \u4E2D\u7684\u539F\u5E94\u7528\u548C\u670D\u52A1\uFF0C\u4E0D\u8981\u53E6\u5EFA\u5E94\u7528\u3002");if(!p&&!s&&await Q(n))throw new a("APP_REQUIRED","\u5DF2\u6709\u9879\u76EE\u5C1A\u672A\u8BC6\u522B\u5230\u5E94\u7528 ID\u3002\u8BF7\u5148\u786E\u8BA4\u539F\u5E94\u7528\uFF0C\u518D\u4F7F\u7528 init --app\uFF1B\u65B0\u4F5C\u54C1\u8BF7\u4ECE\u7F51\u9875\u5F00\u59CB\u521B\u4F5C\u5E76\u643A\u5E26\u9884\u5206\u914D ID\u3002");let w=p??s?.appId??`app_${ct().replaceAll("-","").slice(0,10)}`;!s&&!c&&(s={appId:w,server:e.auth.server},await I(d,s));let v;try{v=await e.project(w)}catch(l){if(!(l instanceof a)||!["AUTH_REQUIRED","INVALID_TOKEN","PROJECT_NOT_AUTHORIZED","INSUFFICIENT_SCOPE","NOT_FOUND"].includes(l.code))throw l;let m=await e.auth.start({appId:w,...r.name?{applicationName:r.name}:{},initialize:!c&&u.size===0,reauthorize:!0});if(m.status==="pending"){if(!r.waitForAuthorization)return{root:n,appId:w,...m,status:"awaiting_confirmation",next:"\u5728\u6D4F\u89C8\u5668\u5B8C\u6210\u767B\u5F55\u548C\u521B\u5EFA/\u5173\u8054\u786E\u8BA4\uFF0C\u6388\u6743\u5B8C\u6210\u540E\u4F7F\u7528\u540C\u4E00\u76EE\u5F55\u548C\u53C2\u6570\u91CD\u8BD5 init\u3002"};process.stderr.write(`\u8BF7\u5728\u6D4F\u89C8\u5668\u786E\u8BA4\u521B\u5EFA\u6216\u5173\u8054\u5E94\u7528\uFF1A${m.authorizationUrl}
2
- `),await e.auth.wait(m.flowId)}v=await e.project(w)}return await X(n),c||await Y(n,w,e.auth.server),{root:n,name:v.name,appId:w,status:"connected",alreadyInitialized:!!c}}finally{await o()}}async function Q(e){let t=new Set([".git",".shaper",".shaper.lock",".DS_Store",".gitignore","AGENTS.md","CLAUDE.md","README.md","docs","node_modules","dist"]);async function r(n,i=!1){for(let o of await M(n,{withFileTypes:!0}))if(!(i&&t.has(o.name))&&(!o.isDirectory()||await r(h(n,o.name))))return!0;return!1}return r(e,!0)}async function Lt(e){await N(e);try{let t=await R(e);return await U(e,t),{status:"configured",config:t}}catch(t){if(t.code!=="ENOENT"&&!(t instanceof f.ZodError))throw t;return{status:await Q(e)?"configuration_required":"not_created"}}}async function U(e,t){let r=await Z(e,t.workingDirectory);if(!(await T(r)).isDirectory())throw new a("INVALID_WORKING_DIRECTORY","workingDirectory \u5FC5\u987B\u662F\u5DE5\u7A0B\u5185\u90E8\u76EE\u5F55\u3002");return r}async function Vt(e,t,r){let n=await E(t);await N(n,r);let i=await K.lock(await O(n),{retries:0});try{let o=await e.project(r);return await Y(n,o.appId,e.auth.server),await X(n),{root:n,appId:o.appId,name:o.name}}finally{await i()}}async function X(e){let t=h(e,".gitignore"),r=await _(t,"utf8").catch(s=>{if(s.code==="ENOENT")return"";throw s}),i=["/.shaper/","/.shaper.lock/","/node_modules/","/dist/","/credentials.json",".env",".env.*","!.env.example"].filter(s=>!r.split(`
1
+ import{a as z,b as a,c as j,d as J,e as I,f as S}from"./shared-BKIED5AA.js";import{realpath as T,mkdir as M,readdir as G,readFile as _,writeFile as at,lstat as P,appendFile as st}from"node:fs/promises";import{resolve as x,join as h,relative as b,sep as k,isAbsolute as W}from"node:path";import{randomUUID as ct}from"node:crypto";import{spawn as pt}from"node:child_process";import dt from"adm-zip";import{z as f}from"zod";import K from"proper-lockfile";var ut=f.object({schemaVersion:f.literal(1),devCommand:f.string().min(1).max(500),buildCommand:f.string().min(1).max(500),outputDir:f.string().min(1),workingDirectory:f.string().min(1).default("."),devUrl:f.string().default("http://127.0.0.1:{port}")}).passthrough(),lt=f.object({schemaVersion:f.literal(1),appId:f.string().min(1).max(200),server:f.string().url()}).strict();async function E(e){if(!e||!W(e))throw new a("WORKSPACE_REQUIRED","\u8BF7\u6307\u5B9A\u5DE5\u7A0B\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002");return T(x(e))}async function D(e,t){return _(h(e,t),"utf8").catch(r=>{if(r.code!=="ENOENT")throw r})}async function B(e){let t=new Set;for(let r of[".shaper/project.json","shaper.config.json","shaper.project.json",".shaper/config.json","activity.json"]){let n=await D(e,r);if(n===void 0)continue;let i=JSON.parse(n);for(let o of[i?.appId,i?.applicationId,r==="activity.json"?i?.activityId:void 0])typeof o=="string"&&o&&t.add(o)}return t}function H(e,t){if(e.size>1||t&&[...e].some(r=>r!==t))throw new a("APP_ID_CONFLICT","\u539F\u9879\u76EE\u5E94\u7528 ID \u4E0E\u76EE\u6807\u4E0D\u4E00\u81F4\uFF1B\u5DF2\u505C\u6B62\uFF0C\u4E0D\u4F1A\u521B\u5EFA\u6216\u5207\u6362\u5E94\u7528\u3002")}async function N(e,t){let r=await D(e,"activity.json"),n=r===void 0?void 0:JSON.parse(r)?.activityId,i=await D(e,"AGENTS.md"),o=await D(e,"skills/act-cloudbase/SKILL.md");if(!(n===void 0&&!i?.includes("<!-- COLORBOX:START -->")&&o===void 0))throw H(await B(e),t),new a("LEGACY_PROJECT_UPGRADE_REQUIRED","\u8FD9\u662F\u65E7\u7248\u9879\u76EE\uFF0C\u8BF7\u7EE7\u7EED\u4F7F\u7528\u539F\u6709\u6280\u80FD\u548C\u5F00\u53D1\u65B9\u5F0F\u3002\u65B0\u7248\u5DE5\u5177\u672A\u4FEE\u6539\u6B64\u9879\u76EE\uFF0C\u5F53\u524D\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u5347\u7EA7\u3002")}async function O(e){let t=h(e,".shaper");if(await M(t,{recursive:!0,mode:448}),(await P(t)).isSymbolicLink())throw new a("UNSAFE_WORKSPACE",".shaper \u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\u3002");return t}async function R(e){return await N(e),ut.parse(await S(h(e,"shaper.config.json")))}async function C(e,t){await N(e);let r=lt.parse(await S(h(e,".shaper","project.json")));if(r.server!==t)throw new a("SERVER_MISMATCH","\u6B64\u5DE5\u7A0B\u7ED1\u5B9A\u7684 Shaper \u670D\u52A1\u4E0E\u5F53\u524D\u767B\u5F55\u670D\u52A1\u4E0D\u540C\u3002\u8BF7\u663E\u5F0F\u5207\u6362\u670D\u52A1\u6216\u91CD\u65B0\u5173\u8054\u3002");return r}async function Y(e,t,r){let n=await O(e);await I(h(n,"project.json"),{schemaVersion:1,appId:t,server:r})}async function Ut(e,t,r={}){if(r.template)throw new a("USE_CREATE","init \u53EA\u5173\u8054\u5E94\u7528\u3002\u9700\u6C42\u660E\u786E\u540E\u4F7F\u7528 shaper create --type \u521B\u5EFA\u5DE5\u7A0B\u3002");if(!t||!W(t))throw new a("WORKSPACE_REQUIRED","\u8BF7\u6307\u5B9A\u5DE5\u7A0B\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002");await M(t,{recursive:!0});let n=await E(t);await N(n,r.appId);let i=await O(n),o=await K.lock(i,{retries:0});try{let c;try{c=await C(n,e.auth.server)}catch(l){if(l.code!=="ENOENT")throw l}if(c&&r.appId&&r.appId!==c.appId)throw new a("ALREADY_LINKED",`\u5F53\u524D\u76EE\u5F55\u5C5E\u4E8E ${c.appId}\uFF0C\u4E0E\u63D0\u793A\u8BCD\u4E2D\u7684 ${r.appId} \u4E0D\u4E00\u81F4\u3002\u8BF7\u56DE\u5230\u539F\u5E94\u7528\u7EE7\u7EED\uFF0C\u6216\u6362\u4E00\u4E2A\u7A7A\u76EE\u5F55\uFF1Binit \u4E0D\u4F1A\u8986\u76D6\u7ED1\u5B9A\u3002`);let u=await B(n),p=c?.appId??r.appId??[...u][0];H(u,p);let d=h(i,"init.json"),s=c?void 0:await S(d).catch(l=>{if(l.code!=="ENOENT")throw l});if(!c&&s&&(!s.appId||s.server!==e.auth.server||p&&p!==s.appId))throw new a("INIT_CONFLICT","\u5B58\u5728\u672A\u5B8C\u6210\u7684\u521D\u59CB\u5316\uFF0C\u8BF7\u6838\u5BF9 .shaper/init.json \u4E2D\u7684\u539F\u5E94\u7528\u548C\u670D\u52A1\uFF0C\u4E0D\u8981\u53E6\u5EFA\u5E94\u7528\u3002");if(!p&&!s&&await Q(n))throw new a("APP_REQUIRED","\u5DF2\u6709\u9879\u76EE\u5C1A\u672A\u8BC6\u522B\u5230\u5E94\u7528 ID\u3002\u8BF7\u5148\u786E\u8BA4\u539F\u5E94\u7528\uFF0C\u518D\u4F7F\u7528 init --app\uFF1B\u65B0\u4F5C\u54C1\u8BF7\u4ECE\u7F51\u9875\u5F00\u59CB\u521B\u4F5C\u5E76\u643A\u5E26\u9884\u5206\u914D ID\u3002");let w=p??s?.appId??`app_${ct().replaceAll("-","").slice(0,10)}`;!s&&!c&&(s={appId:w,server:e.auth.server},await I(d,s));let v;try{v=await e.project(w)}catch(l){if(!(l instanceof a)||!["AUTH_REQUIRED","INVALID_TOKEN","PROJECT_NOT_AUTHORIZED","INSUFFICIENT_SCOPE","NOT_FOUND"].includes(l.code))throw l;let m=await e.auth.start({appId:w,...r.name?{applicationName:r.name}:{},initialize:!c&&u.size===0,reauthorize:!0});if(m.status==="pending"){if(!r.waitForAuthorization)return{root:n,appId:w,...m,status:"awaiting_confirmation",next:"\u5728\u6D4F\u89C8\u5668\u5B8C\u6210\u767B\u5F55\u548C\u521B\u5EFA/\u5173\u8054\u786E\u8BA4\uFF0C\u6388\u6743\u5B8C\u6210\u540E\u4F7F\u7528\u540C\u4E00\u76EE\u5F55\u548C\u53C2\u6570\u91CD\u8BD5 init\u3002"};process.stderr.write(`\u8BF7\u5728\u6D4F\u89C8\u5668\u786E\u8BA4\u521B\u5EFA\u6216\u5173\u8054\u5E94\u7528\uFF1A${m.authorizationUrl}
2
+ `),await e.auth.wait(m.flowId)}v=await e.project(w)}return await X(n),c||await Y(n,w,e.auth.server),{root:n,name:v.name,appId:w,status:"connected",alreadyInitialized:!!c}}finally{await o()}}async function Q(e){let t=new Set([".git",".shaper",".shaper.lock",".DS_Store",".gitignore","AGENTS.md","CLAUDE.md","README.md","docs","templates","node_modules","dist"]);async function r(n,i=!1){for(let o of await G(n,{withFileTypes:!0}))if(!(i&&t.has(o.name))&&(!o.isDirectory()||await r(h(n,o.name))))return!0;return!1}return r(e,!0)}async function Lt(e){await N(e);try{let t=await R(e);return await U(e,t),{status:"configured",config:t}}catch(t){if(t.code!=="ENOENT"&&!(t instanceof f.ZodError))throw t;return{status:await Q(e)?"configuration_required":"not_created"}}}async function U(e,t){let r=await Z(e,t.workingDirectory);if(!(await P(r)).isDirectory())throw new a("INVALID_WORKING_DIRECTORY","workingDirectory \u5FC5\u987B\u662F\u5DE5\u7A0B\u5185\u90E8\u76EE\u5F55\u3002");return r}async function Vt(e,t,r){let n=await E(t);await N(n,r);let i=await K.lock(await O(n),{retries:0});try{let o=await e.project(r);return await Y(n,o.appId,e.auth.server),await X(n),{root:n,appId:o.appId,name:o.name}}finally{await i()}}async function X(e){let t=h(e,".gitignore"),r=await _(t,"utf8").catch(s=>{if(s.code==="ENOENT")return"";throw s}),i=["/.shaper/","/.shaper.lock/","/node_modules/","/dist/","/credentials.json",".env",".env.*","!.env.example"].filter(s=>!r.split(`
3
3
  `).includes(s));i.length&&await st(t,`
4
4
  # Shaper local state and generated files
5
5
  ${i.join(`
6
6
  `)}
7
7
  `);let o=h(e,"AGENTS.md"),c=await _(o,"utf8").catch(s=>{if(s.code==="ENOENT")return"";throw s}),u="<!-- shaper:project -->",p=`
8
8
  ${u}
9
- Read docs/product.md for goals and rules, docs/design.md for experience and implementation decisions, and docs/validation.md for actual evidence when these files exist. Use the globally installed shaper-development skill for local development and shaper-release for web delivery. For Hupu login/share use hupu-business; for functions or databases use shaper-backend. Pass this project's absolute path to project tools. init connects the application only. After the user describes their goal, use shaper_create with an appropriate template if no implementation exists; otherwise preserve the existing stack. Do not choose a template during setup without a creative goal. Read shaper.config.json when present for commands and query shaper_status for live identity. Web publishing belongs to Shaper; cloud functions are deployed separately.
9
+ Read docs/product.md for goals and rules, docs/design.md for experience and implementation decisions, and docs/validation.md for actual evidence when these files exist. Use the globally installed shaper-development skill for local development and shaper-release for web delivery. For Hupu login/share use hupu-business; for functions or databases use shaper-backend. Pass this project's absolute path to project tools. init connects the application only. After the user describes their goal, use shaper_create with type h5/react/phaser to create an empty project. Existing projects keep their stack. For service or feature references, use shaper_template_add; it only extracts into templates/<name>. Read its README and integrate selected code into the actual project before validating. Template extraction is not integration or deployment. Do not choose a template during setup without a creative goal. Read shaper.config.json when present for commands and query shaper_status for live identity. Web publishing belongs to Shaper; cloud functions are deployed separately.
10
10
 
11
11
  \u9762\u5411\u521B\u4F5C\u8005\u8BF4\u660E\u5DF2\u80FD\u4F53\u9A8C\u4EC0\u4E48\uFF0C\u518D\u7ED9\u5F53\u524D\u6700\u76F8\u5173\u7684\u4E0B\u4E00\u6B65\uFF1B\u6280\u672F\u68C0\u67E5\u548C\u547D\u4EE4\u7531 AI \u6267\u884C\uFF0C\u7EC6\u8282\u5728\u7528\u6237\u8BE2\u95EE\u6216\u6392\u67E5\u65F6\u5C55\u5F00\u3002\u9700\u8981\u7528\u6237\u64CD\u4F5C\u65F6\u7ED9\u51FA\u5B9E\u9645\u5165\u53E3\uFF0C\u8BF4\u660E\u786E\u8BA4\u5BF9\u8C61\u548C\u540E\u7EED\u52A8\u4F5C\uFF1B\u6309\u5F00\u53D1\u3001\u540E\u7AEF\u6216\u53D1\u5E03\u6280\u80FD\u7684\u7528\u6237\u5F15\u5BFC\u8854\u63A5\uFF0C\u4E0D\u8981\u6C42\u7528\u6237\u7406\u89E3\u6280\u80FD\u540D\u6216\u5185\u90E8\u72B6\u6001\u3002\u5F15\u5BFC\u4E0D\u6269\u5927\u4EFB\u52A1\u6388\u6743\uFF1B\u521B\u5EFA\u5E94\u7528\u3001\u5F00\u901A\u4E91\u670D\u52A1\u548C\u63D0\u4EA4\u5BA1\u6838\u4ECD\u987B\u5BF9\u5E94\u7684\u7F51\u9875\u786E\u8BA4\u3002
12
12
  <!-- /shaper:project -->
13
- `,d=c.includes(u)?c.replace(/<!-- shaper:project -->[\s\S]*?<!-- \/shaper:project -->\n?/,p.trimStart()):c+p;d!==c&&await at(o,d)}async function wt(e,t){await new Promise((r,n)=>{let i=pt(e,{cwd:t,shell:!0,stdio:["ignore","pipe","pipe"]});i.stdout.on("data",o=>process.stderr.write(o)),i.stderr.on("data",o=>process.stderr.write(o)),i.once("error",n),i.once("exit",o=>o===0?r():n(new a("COMMAND_FAILED",`\u5DE5\u7A0B\u547D\u4EE4\u9000\u51FA\u7801\uFF1A${o??"signal"}`)))})}async function Ft(e){let t=await E(e),r=await R(t);await wt(r.buildCommand,await U(t,r));let n=await Z(t,r.outputDir);return await _(h(n,"index.html")),{root:t,output:n}}async function Z(e,t){let r=await P(x(e,t)),n=b(e,r);if(n===".."||n.startsWith(`..${k}`)||x(e,n)!==r)throw new a("INVALID_OUTPUT","\u8F93\u51FA\u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u5DE5\u7A0B\u5185\u90E8\u3002");return r}async function $t(e,t={files:300,bytes:200*1024*1024}){let r=await P(e),n=new dt,i=0,o=0;async function c(u){for(let p of(await M(u,{withFileTypes:!0})).sort((d,s)=>d.name.localeCompare(s.name))){if(/^(\.git|\.shaper|node_modules|\.DS_Store)$/.test(p.name))continue;if(/^(\.env(?:\..*)?|credentials\.json|.*\.(pem|key))$/i.test(p.name))throw new a("SECRET_FILE_IN_PACKAGE",`\u8F93\u51FA\u76EE\u5F55\u5305\u542B\u654F\u611F\u914D\u7F6E\u6587\u4EF6\uFF1A${p.name}`);let d=h(u,p.name);if(p.isSymbolicLink())throw new a("SYMLINK_IN_PACKAGE",`\u4EA4\u4ED8\u5185\u5BB9\u4E2D\u4E0D\u5141\u8BB8\u7B26\u53F7\u94FE\u63A5\uFF1A${p.name}`);if(p.isDirectory()){await c(d);continue}if(!p.isFile())throw new a("INVALID_PACKAGE_FILE","\u4EA4\u4ED8\u76EE\u5F55\u5305\u542B\u975E\u5E38\u89C4\u6587\u4EF6\u3002");let s=await T(d);if(i+=s.size,o++,o>t.files||i>t.bytes)throw new a("PACKAGE_TOO_LARGE","\u4EA4\u4ED8\u5305\u8D85\u8FC7\u6587\u4EF6\u6570\u6216\u5927\u5C0F\u9650\u5236\u3002");n.addFile(b(r,d).split(k).join("/"),await _(d))}}await c(r);for(let u of n.getEntries())u.header.time=new Date(2e3,0,1);return{content:n.toBuffer(),files:o,bytes:i}}async function zt(e){let t=await E(e),r=await R(t),n=[];await U(t,r);let i=x(t,r.outputDir),o=b(t,i);return(o===".."||o.startsWith(`..${k}`))&&n.push("outputDir \u8D85\u51FA\u5DE5\u7A0B\u76EE\u5F55"),{root:t,passed:n.length===0,findings:n,checks:["project configuration","command directory","output path"],notRun:["application behavior","build","cloud connectivity"]}}import{createHash as et}from"node:crypto";import{join as q}from"node:path";import{mkdir as ft,readFile as ht}from"node:fs/promises";import{z as g}from"zod";var L=8*1024*1024,mt=10080*60*1e3,gt=g.object({protocol:g.literal(1),version:g.string().regex(/^[a-f0-9]{64}$/),sha256:g.string().regex(/^[a-f0-9]{64}$/),payload:g.string().max(L)}).strict(),Et=g.object({shell:g.string().min(1),head:g.string(),body:g.string(),sdk:g.string().min(1)}).strict();function tt(e){let t=gt.parse(e),r=et("sha256").update(t.payload).digest("hex");if(r!==t.sha256||r!==t.version)throw new a("PREVIEW_RUNTIME_INTEGRITY","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u6821\u9A8C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");let n=Et.parse(JSON.parse(t.payload));if(!n.shell.includes("__SHAPER_PREVIEW_ENTRY__"))throw new a("PREVIEW_RUNTIME_INVALID","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u4E0D\u517C\u5BB9\uFF0C\u8BF7\u66F4\u65B0 Shaper\u3002");return{envelope:t,content:n}}async function rt(e){let t=J(e),r=q(j(),"preview-runtime",et("sha256").update(t).digest("hex")),n=q(r,"current.json"),i;try{i=await fetch(`${t}/api/v1/preview-runtime`,{redirect:"error",signal:AbortSignal.timeout(8e3)})}catch{}if(!i||i.status>=500)try{let p=await ht(n);if(p.length>L)throw new Error("Oversized cache");let d=JSON.parse(p.toString()),s=Date.now()-Date.parse(d.fetchedAt);if(!Number.isFinite(s)||s<0||s>mt)throw new Error("Expired cache");return{...tt(d.envelope),source:"cache"}}catch{throw new a("PREVIEW_RUNTIME_UNAVAILABLE","\u65E0\u6CD5\u52A0\u8F7D\u9884\u89C8\u8FD0\u884C\u73AF\u5883\uFF0C\u4E14\u6CA1\u6709\u6709\u6548\u7F13\u5B58\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\uFF1B\u4E0D\u4F1A\u542F\u52A8\u65E0\u58F3\u9884\u89C8\u3002")}if(!i.ok)throw await i.body?.cancel(),new a("PREVIEW_RUNTIME_UNAVAILABLE","\u670D\u52A1\u6682\u4E0D\u652F\u6301\u6B64\u9884\u89C8\u8FD0\u884C\u73AF\u5883\uFF0C\u8BF7\u786E\u8BA4 Shaper \u670D\u52A1\u5DF2\u66F4\u65B0\u3002");let o=[],c=0;for await(let p of i.body){if(c+=p.length,c>L)throw new a("PREVIEW_RUNTIME_INVALID","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u8D85\u8FC7\u5927\u5C0F\u9650\u5236\u3002");o.push(p)}let u;try{u=tt(JSON.parse(Buffer.concat(o).toString()))}catch{throw new a("PREVIEW_RUNTIME_INVALID","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u6821\u9A8C\u5931\u8D25\u6216\u7248\u672C\u4E0D\u517C\u5BB9\uFF0C\u8BF7\u66F4\u65B0 Shaper \u540E\u91CD\u8BD5\u3002")}return await ft(r,{recursive:!0,mode:448}),await I(n,{fetchedAt:new Date().toISOString(),envelope:u.envelope}),{...u,source:"network"}}import{createHash as yt,randomUUID as It}from"node:crypto";import{open as St,mkdir as At,readFile as vt,rm as nt}from"node:fs/promises";import{join as A}from"node:path";import{spawn as _t}from"node:child_process";import{z as y}from"zod";import Nt from"proper-lockfile";var Rt=y.object({id:y.string(),root:y.string(),controlUrl:y.string().url(),token:y.string(),url:y.string().url(),startedAt:y.string(),runtimeVersion:y.string().optional()}).strict();function F(e){return A(j(),"sessions",yt("sha256").update(e).digest("hex"))}async function $(e){let t=Rt.parse(await S(A(F(e),"session.json")));if(t.root!==e||new URL(t.controlUrl).hostname!=="127.0.0.1")throw new a("INVALID_DEV_SESSION","\u672C\u5730\u5F00\u53D1\u4F1A\u8BDD\u8BB0\u5F55\u4E0D\u6B63\u786E\u3002");return t}async function V(e){let t=await E(e),r;try{r=await $(t)}catch(n){if(n.code==="ENOENT")return{running:!1,root:t};throw n}try{let n=await fetch(`${r.controlUrl}/status`,{headers:{Authorization:`Bearer ${r.token}`},redirect:"error",signal:AbortSignal.timeout(1500)}),i=await n.json();if(!n.ok||i.id!==r.id)throw new Error("Session mismatch");return{root:t,running:i.running,ready:i.ready,url:r.url,sessionId:r.id}}catch{return{root:t,running:!1,url:r.url,sessionId:r.id}}}async function oe(e){let t=await E(e);await R(t);let r=F(t);await At(r,{recursive:!0,mode:448});let n=await Nt.lock(r,{retries:0});try{let i=await V(t);if(i.running){if((await $(t)).runtimeVersion)return i;await it(t)}let o=await S(A(t,".shaper","project.json")),c=await C(t,o.server),u=await rt(c.server),p=It(),d=A(r,`runtime-${p}.json`);await I(d,{envelope:u.envelope,appId:c.appId,source:u.source});let s=await St(A(r,"dev.log"),"w",384),w=_t(process.execPath,[A(z,"dist","dev-runner.js"),t,p],{cwd:t,detached:!0,stdio:["ignore",s.fd,s.fd],windowsHide:!0});try{await new Promise((l,m)=>{w.once("spawn",l),w.once("error",m)})}catch(l){throw await nt(d,{force:!0}),l}finally{await s.close()}w.unref();let v=!1;w.once("exit",()=>{v=!0});for(let l=0;l<120;l++){if(await new Promise(ot=>setTimeout(ot,250)),v)throw await nt(d,{force:!0}),new a("DEV_START_FAILED","\u9884\u89C8\u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u67E5\u770B shaper logs\u3002");let m=await V(t);if(m.running&&m.ready)return m}throw await it(t),new a("DEV_NOT_READY","\u5F00\u53D1\u670D\u52A1\u672A\u5728 30 \u79D2\u5185\u5C31\u7EEA\uFF0C\u8BF7\u67E5\u770B shaper logs\u3002\u5DF2\u505C\u6B62\u672C\u6B21\u4F1A\u8BDD\u3002")}finally{await n()}}async function it(e){let t=await E(e);if(!(await V(t)).running)return{stopped:!0,alreadyStopped:!0};let n=await $(t);if(!(await fetch(`${n.controlUrl}/stop`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`},redirect:"error",signal:AbortSignal.timeout(1e4)})).ok)throw new a("DEV_STOP_FAILED","\u5F00\u53D1\u4F1A\u8BDD\u672A\u80FD\u505C\u6B62\u3002");for(let o=0;o<30;o++){await new Promise(c=>setTimeout(c,200));try{await fetch(`${n.controlUrl}/status`,{headers:{Authorization:`Bearer ${n.token}`},redirect:"error",signal:AbortSignal.timeout(500)})}catch{return{stopped:!0,sessionId:n.id}}}throw new a("DEV_STOP_PENDING","\u505C\u6B62\u8BF7\u6C42\u5DF2\u53D1\u9001\uFF0C\u4F46\u4F1A\u8BDD\u4ECD\u672A\u9000\u51FA\uFF0C\u8BF7\u68C0\u67E5\u65E5\u5FD7\u3002")}async function ae(e){let t=await E(e);try{let r=await vt(A(F(t),"dev.log"),"utf8");return{root:t,log:r.slice(-16e3)}}catch(r){if(r.code==="ENOENT")return{root:t,log:"",message:"\u5C1A\u65E0\u672C\u5730\u8FD0\u884C\u65E5\u5FD7"};throw r}}export{E as a,N as b,O as c,R as d,C as e,Ut as f,Q as g,Lt as h,U as i,Vt as j,wt as k,Ft as l,Z as m,$t as n,zt as o,tt as p,F as q,V as r,oe as s,it as t,ae as u};
13
+ `,d=c.includes(u)?c.replace(/<!-- shaper:project -->[\s\S]*?<!-- \/shaper:project -->\n?/,p.trimStart()):c+p;d!==c&&await at(o,d)}async function wt(e,t){await new Promise((r,n)=>{let i=pt(e,{cwd:t,shell:!0,stdio:["ignore","pipe","pipe"]});i.stdout.on("data",o=>process.stderr.write(o)),i.stderr.on("data",o=>process.stderr.write(o)),i.once("error",n),i.once("exit",o=>o===0?r():n(new a("COMMAND_FAILED",`\u5DE5\u7A0B\u547D\u4EE4\u9000\u51FA\u7801\uFF1A${o??"signal"}`)))})}async function Ft(e){let t=await E(e),r=await R(t);await wt(r.buildCommand,await U(t,r));let n=await Z(t,r.outputDir);return await _(h(n,"index.html")),{root:t,output:n}}async function Z(e,t){let r=await T(x(e,t)),n=b(e,r);if(n===".."||n.startsWith(`..${k}`)||x(e,n)!==r)throw new a("INVALID_OUTPUT","\u8F93\u51FA\u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u5DE5\u7A0B\u5185\u90E8\u3002");return r}async function $t(e,t={files:300,bytes:200*1024*1024}){let r=await T(e),n=new dt,i=0,o=0;async function c(u){for(let p of(await G(u,{withFileTypes:!0})).sort((d,s)=>d.name.localeCompare(s.name))){if(/^(\.git|\.shaper|node_modules|\.DS_Store)$/.test(p.name))continue;if(/^(\.env(?:\..*)?|credentials\.json|.*\.(pem|key))$/i.test(p.name))throw new a("SECRET_FILE_IN_PACKAGE",`\u8F93\u51FA\u76EE\u5F55\u5305\u542B\u654F\u611F\u914D\u7F6E\u6587\u4EF6\uFF1A${p.name}`);let d=h(u,p.name);if(p.isSymbolicLink())throw new a("SYMLINK_IN_PACKAGE",`\u4EA4\u4ED8\u5185\u5BB9\u4E2D\u4E0D\u5141\u8BB8\u7B26\u53F7\u94FE\u63A5\uFF1A${p.name}`);if(p.isDirectory()){await c(d);continue}if(!p.isFile())throw new a("INVALID_PACKAGE_FILE","\u4EA4\u4ED8\u76EE\u5F55\u5305\u542B\u975E\u5E38\u89C4\u6587\u4EF6\u3002");let s=await P(d);if(i+=s.size,o++,o>t.files||i>t.bytes)throw new a("PACKAGE_TOO_LARGE","\u4EA4\u4ED8\u5305\u8D85\u8FC7\u6587\u4EF6\u6570\u6216\u5927\u5C0F\u9650\u5236\u3002");n.addFile(b(r,d).split(k).join("/"),await _(d))}}await c(r);for(let u of n.getEntries())u.header.time=new Date(2e3,0,1);return{content:n.toBuffer(),files:o,bytes:i}}async function zt(e){let t=await E(e),r=await R(t),n=[];await U(t,r);let i=x(t,r.outputDir),o=b(t,i);return(o===".."||o.startsWith(`..${k}`))&&n.push("outputDir \u8D85\u51FA\u5DE5\u7A0B\u76EE\u5F55"),{root:t,passed:n.length===0,findings:n,checks:["project configuration","command directory","output path"],notRun:["application behavior","build","cloud connectivity"]}}import{createHash as et}from"node:crypto";import{join as q}from"node:path";import{mkdir as ft,readFile as ht}from"node:fs/promises";import{z as g}from"zod";var L=8*1024*1024,mt=10080*60*1e3,gt=g.object({protocol:g.literal(1),version:g.string().regex(/^[a-f0-9]{64}$/),sha256:g.string().regex(/^[a-f0-9]{64}$/),payload:g.string().max(L)}).strict(),Et=g.object({shell:g.string().min(1),head:g.string(),body:g.string(),sdk:g.string().min(1)}).strict();function tt(e){let t=gt.parse(e),r=et("sha256").update(t.payload).digest("hex");if(r!==t.sha256||r!==t.version)throw new a("PREVIEW_RUNTIME_INTEGRITY","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u6821\u9A8C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");let n=Et.parse(JSON.parse(t.payload));if(!n.shell.includes("__SHAPER_PREVIEW_ENTRY__"))throw new a("PREVIEW_RUNTIME_INVALID","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u4E0D\u517C\u5BB9\uFF0C\u8BF7\u66F4\u65B0 Shaper\u3002");return{envelope:t,content:n}}async function rt(e){let t=J(e),r=q(j(),"preview-runtime",et("sha256").update(t).digest("hex")),n=q(r,"current.json"),i;try{i=await fetch(`${t}/api/v1/preview-runtime`,{redirect:"error",signal:AbortSignal.timeout(8e3)})}catch{}if(!i||i.status>=500)try{let p=await ht(n);if(p.length>L)throw new Error("Oversized cache");let d=JSON.parse(p.toString()),s=Date.now()-Date.parse(d.fetchedAt);if(!Number.isFinite(s)||s<0||s>mt)throw new Error("Expired cache");return{...tt(d.envelope),source:"cache"}}catch{throw new a("PREVIEW_RUNTIME_UNAVAILABLE","\u65E0\u6CD5\u52A0\u8F7D\u9884\u89C8\u8FD0\u884C\u73AF\u5883\uFF0C\u4E14\u6CA1\u6709\u6709\u6548\u7F13\u5B58\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\uFF1B\u4E0D\u4F1A\u542F\u52A8\u65E0\u58F3\u9884\u89C8\u3002")}if(!i.ok)throw await i.body?.cancel(),new a("PREVIEW_RUNTIME_UNAVAILABLE","\u670D\u52A1\u6682\u4E0D\u652F\u6301\u6B64\u9884\u89C8\u8FD0\u884C\u73AF\u5883\uFF0C\u8BF7\u786E\u8BA4 Shaper \u670D\u52A1\u5DF2\u66F4\u65B0\u3002");let o=[],c=0;for await(let p of i.body){if(c+=p.length,c>L)throw new a("PREVIEW_RUNTIME_INVALID","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u8D85\u8FC7\u5927\u5C0F\u9650\u5236\u3002");o.push(p)}let u;try{u=tt(JSON.parse(Buffer.concat(o).toString()))}catch{throw new a("PREVIEW_RUNTIME_INVALID","\u9884\u89C8\u8FD0\u884C\u73AF\u5883\u6821\u9A8C\u5931\u8D25\u6216\u7248\u672C\u4E0D\u517C\u5BB9\uFF0C\u8BF7\u66F4\u65B0 Shaper \u540E\u91CD\u8BD5\u3002")}return await ft(r,{recursive:!0,mode:448}),await I(n,{fetchedAt:new Date().toISOString(),envelope:u.envelope}),{...u,source:"network"}}import{createHash as yt,randomUUID as It}from"node:crypto";import{open as St,mkdir as At,readFile as vt,rm as nt}from"node:fs/promises";import{join as A}from"node:path";import{spawn as _t}from"node:child_process";import{z as y}from"zod";import Nt from"proper-lockfile";var Rt=y.object({id:y.string(),root:y.string(),controlUrl:y.string().url(),token:y.string(),url:y.string().url(),startedAt:y.string(),runtimeVersion:y.string().optional()}).strict();function F(e){return A(j(),"sessions",yt("sha256").update(e).digest("hex"))}async function $(e){let t=Rt.parse(await S(A(F(e),"session.json")));if(t.root!==e||new URL(t.controlUrl).hostname!=="127.0.0.1")throw new a("INVALID_DEV_SESSION","\u672C\u5730\u5F00\u53D1\u4F1A\u8BDD\u8BB0\u5F55\u4E0D\u6B63\u786E\u3002");return t}async function V(e){let t=await E(e),r;try{r=await $(t)}catch(n){if(n.code==="ENOENT")return{running:!1,root:t};throw n}try{let n=await fetch(`${r.controlUrl}/status`,{headers:{Authorization:`Bearer ${r.token}`},redirect:"error",signal:AbortSignal.timeout(1500)}),i=await n.json();if(!n.ok||i.id!==r.id)throw new Error("Session mismatch");return{root:t,running:i.running,ready:i.ready,url:r.url,sessionId:r.id}}catch{return{root:t,running:!1,url:r.url,sessionId:r.id}}}async function oe(e){let t=await E(e);await R(t);let r=F(t);await At(r,{recursive:!0,mode:448});let n=await Nt.lock(r,{retries:0});try{let i=await V(t);if(i.running){if((await $(t)).runtimeVersion)return i;await it(t)}let o=await S(A(t,".shaper","project.json")),c=await C(t,o.server),u=await rt(c.server),p=It(),d=A(r,`runtime-${p}.json`);await I(d,{envelope:u.envelope,appId:c.appId,source:u.source});let s=await St(A(r,"dev.log"),"w",384),w=_t(process.execPath,[A(z,"dist","dev-runner.js"),t,p],{cwd:t,detached:!0,stdio:["ignore",s.fd,s.fd],windowsHide:!0});try{await new Promise((l,m)=>{w.once("spawn",l),w.once("error",m)})}catch(l){throw await nt(d,{force:!0}),l}finally{await s.close()}w.unref();let v=!1;w.once("exit",()=>{v=!0});for(let l=0;l<120;l++){if(await new Promise(ot=>setTimeout(ot,250)),v)throw await nt(d,{force:!0}),new a("DEV_START_FAILED","\u9884\u89C8\u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u67E5\u770B shaper logs\u3002");let m=await V(t);if(m.running&&m.ready)return m}throw await it(t),new a("DEV_NOT_READY","\u5F00\u53D1\u670D\u52A1\u672A\u5728 30 \u79D2\u5185\u5C31\u7EEA\uFF0C\u8BF7\u67E5\u770B shaper logs\u3002\u5DF2\u505C\u6B62\u672C\u6B21\u4F1A\u8BDD\u3002")}finally{await n()}}async function it(e){let t=await E(e);if(!(await V(t)).running)return{stopped:!0,alreadyStopped:!0};let n=await $(t);if(!(await fetch(`${n.controlUrl}/stop`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`},redirect:"error",signal:AbortSignal.timeout(1e4)})).ok)throw new a("DEV_STOP_FAILED","\u5F00\u53D1\u4F1A\u8BDD\u672A\u80FD\u505C\u6B62\u3002");for(let o=0;o<30;o++){await new Promise(c=>setTimeout(c,200));try{await fetch(`${n.controlUrl}/status`,{headers:{Authorization:`Bearer ${n.token}`},redirect:"error",signal:AbortSignal.timeout(500)})}catch{return{stopped:!0,sessionId:n.id}}}throw new a("DEV_STOP_PENDING","\u505C\u6B62\u8BF7\u6C42\u5DF2\u53D1\u9001\uFF0C\u4F46\u4F1A\u8BDD\u4ECD\u672A\u9000\u51FA\uFF0C\u8BF7\u68C0\u67E5\u65E5\u5FD7\u3002")}async function ae(e){let t=await E(e);try{let r=await vt(A(F(t),"dev.log"),"utf8");return{root:t,log:r.slice(-16e3)}}catch(r){if(r.code==="ENOENT")return{root:t,log:"",message:"\u5C1A\u65E0\u672C\u5730\u8FD0\u884C\u65E5\u5FD7"};throw r}}export{E as a,N as b,O as c,R as d,C as e,Ut as f,Q as g,Lt as h,U as i,Vt as j,wt as k,Ft as l,Z as m,$t as n,zt as o,tt as p,F as q,V as r,oe as s,it as t,ae as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hupu-tech/shaper",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Shaper local developer tools, MCP server and Hupu integration skills",
5
5
  "type": "module",
6
6
  "bin": {
@@ -44,15 +44,14 @@ const user = await hupu.user();
44
44
 
45
45
  ```js
46
46
  const response = await window.ShaperAI.cloud.request({
47
- path: '/api/progress',
48
- method: 'POST',
49
- data: { score: 100, submissionId }
47
+ path: '/api/me',
48
+ method: 'POST'
50
49
  });
51
50
  ```
52
51
 
53
52
  只传 path、method、data;支持 GET/POST/PUT/PATCH/DELETE/HEAD。路由的 public/user 决定是否登录。SDK 验证真实虎扑玩家、换取当前应用会话并请求网关;后端从 user.puid 判断归属,不信任 body.puid。预览访问凭证由壳管理,业务不读取或复制。
54
53
 
55
- 先确认 cloud status 就绪、数据库迁移成功、后端和网关部署成功,再在实际虎扑容器验证保存与回读。普通浏览器没有玩家登录态时给出登录提示,不使用开发者 Token 或调试账号冒充真实玩家。检查 statusCode 和业务 code/message/data;失败的写请求先确认结果,不自动重发。日志不记录 Token。
54
+ 先确认 cloud status 就绪、后端和网关部署成功,再在实际虎扑容器验证公开列表和当前用户身份。涉及业务数据库时另行验证迁移与读写;玩家云存档走独立能力。普通浏览器没有玩家登录态时给出登录提示,不使用开发者 Token 或调试账号冒充真实玩家。检查 statusCode 和业务 code/message/data;失败的写请求先确认结果,不自动重发。日志不记录 Token。
56
55
 
57
56
  若返回 CLOUD_NOT_CONFIGURED,说明平台壳尚未接入新版能力,应升级平台 SDK/运行配置;不能自行拼接服务地址或回退旧鉴权。此次测试7已在开发环境验证,正式环境上线状态仍需核对。
58
57
 
@@ -8,8 +8,8 @@
8
8
 
9
9
  1. 用 `hupu_cloud_status` 查询云资源。已就绪则复用;未开通时调用 `hupu_cloud_create` 发起网页确认,展示返回的 confirmationUrl,等待用户亲自确认。已有 Token 或对话同意不能替代网页确认;Agent 不代点确认,也不直接调用确认接口。不因部署失败而自动创建资源。
10
10
  2. 有数据库变更时,先执行迁移并确认 succeeded;无变更则跳过。
11
- 3. 用 `hupu_cloud_deploy` 部署。默认构建 cloud/functions/api 并组合网关声明;旧 functions/api 布局继续支持。已有制品可传 manifestFile 与 bundleFile,两者成对且与 directory 互斥。
12
- 4. 核对部署结果和实际接口。一个应用只有一份活动后端;换源码目录会更新同一服务,不会创建第二个服务。
11
+ 3. 用 `hupu_cloud_deploy` 部署。默认构建 cloud/functions/activity 并组合网关声明;旧 functions/api 布局继续支持。已有制品可传 manifestFile 与 bundleFile,两者成对且与 directory 互斥。
12
+ 4. 函数 cloud.json 必须声明 name。同一应用环境内同名更新,不同名新增;目录名不决定身份。多个函数分别传 directory 部署;网关每条路由通过 function 指向声明名称,不能让不同函数占用同一路径。核对 status.functions 中目标名称的部署结果,再验证实际接口。
13
13
 
14
14
  CLI 对应 `shaper cloud create`、`shaper cloud deploy`、`shaper cloud status`。源码目录、生成文件和 SDK 用法由后端实现参考定义;这里不重复维护模板。
15
15
 
@@ -17,7 +17,7 @@ CLI 对应 `shaper cloud create`、`shaper cloud deploy`、`shaper cloud status`
17
17
 
18
18
  写操作默认等待结果。queued/running 或 pending 表示仍未确认完成;通过 status 的 operations / recentOperations 按原 operationId 查询,不重发写入或换键重试。failed 时说明实际错误;结果未知时先核对原任务。
19
19
 
20
- 开通以资源 ready 为准;部署核对当前 release.digest 与该次操作的 result.digest,再验证公开接口和登录接口。记录版本、操作状态和接口验证范围,不把受理成功当作上线成功。
20
+ 开通以资源 ready 为准;部署核对 status.functions 中目标函数的 digest 与该次操作的 result.digest,再验证公开接口和登录接口。记录版本、操作状态和接口验证范围,不把受理成功当作上线成功。
21
21
 
22
22
  ## 当前边界
23
23
 
@@ -3,7 +3,7 @@
3
3
  先按用户操作定义请求、响应、身份前提和失败行为。业务使用普通 Node HTTP 服务;Express 等框架由项目选择,SDK 只负责玩家鉴权与 PostgreSQL 访问。
4
4
 
5
5
  ```text
6
- cloud/functions/api/
6
+ cloud/functions/activity/
7
7
  server.cjs # HTTP 启动入口,可拆分路由和业务模块
8
8
  cloud.json # manifest v2、SDK 精确版本、运行参数
9
9
  package.json # 依赖与 hupuCloud.entry
@@ -35,10 +35,10 @@ process.once('SIGTERM', () => server.close(() => cloud.close()));
35
35
 
36
36
  每个进程复用一个 client,每次请求单独取得 user;私有接口必须调用 requireUser。按可信 user.puid 限制数据归属,不能采用 body.puid。可匿名接口用 getUser;无凭据返回 null,无效凭据仍报错。运行绑定由平台注入,源码不包含厂商密钥或数据库密码。
37
37
 
38
- 业务路由在 HTTP 服务中;网关声明只描述暴露范围,不映射 JS 函数。新增接口同步声明路径和方法,服务端仍须鉴权。腾讯托管网关负责 CORS 响应,避免重复添加跨域头。
38
+ 函数 cloud.json 的 name 是部署身份,目录重命名不改变身份;代码摘要仅代表版本。网关每条声明用 function 指向该名称,构建时只选择当前函数的路由。它不映射 JavaScript 处理函数。新增接口同步声明路径和方法,服务端仍须鉴权。腾讯托管网关负责 CORS 响应,避免重复添加跨域头。
39
39
 
40
- 按工具包 templates/cloud-service 初始化本地源码;已有工程保留代码。函数目录执行 npm ci,新增依赖后提交锁文件。部署将 SDK 和业务依赖打包,产物在 .shaper/cloud-build/<digest>。旧 handler 项目需显式升级为 HTTP 服务,不能直接换 SDK 版本。
40
+ 需要服务参考时执行 `shaper template add server`,或调用 `shaper_template_add` 并传 name=server。模板只提取到 `templates/server/`,先读其中 README.md,再检查并融合现有前后端、路由和数据库;不要整目录覆盖或直接部署模板。`shaper cloud create` 独立开通远程资源,须用户网页确认;融合后再迁移、部署。函数目录执行 npm ci,新增依赖后提交锁文件。部署将 SDK 和业务依赖打包,产物在 .shaper/cloud-build/<digest>。旧 handler 项目需显式升级为 HTTP 服务,不能直接换 SDK 版本。
41
41
 
42
42
  前端使用 ShaperAI.cloud.request({ path, method, data }),完整玩家接入见 hupu-business。迁移、后端部署和网页预览分别验证;真实登录和云端读写通过才算链路完成。当前已完成腾讯云新版真机验证,阿里云仍待验证。
43
43
 
44
- 需要排行榜时,调用 shaper_templates 找到 leaderboard 项目,先读 docs/integration.md,再参考其前后端与迁移。已有项目复用原身份、积分和服务入口,按业务融合;模板的自报成绩示例不作为可信奖励计分。
44
+ 需要排行榜时,调用 shaper_template_list 找到 leaderboard 项目,先读 docs/integration.md,再参考其前后端与迁移。已有项目复用原身份、积分和服务入口,按业务融合;模板的自报成绩示例不作为可信奖励计分。
@@ -18,7 +18,7 @@ description: 检查新旧 Shaper 项目的归属,初始化或关联应用,
18
18
 
19
19
  ## 开始创作与继续开发
20
20
 
21
- 接入完成且需求尚未明确时,引导用户描述想法,暂不选模板。需求已明确且尚无工程时,由 AI 根据交互特点选择工程模板,调用 `shaper_create(workspace, template)`(CLI:`shaper create --template react`),再实现需求;不要让用户选择技术栈。已有源码沿用原工程,不调用 create 覆盖。`project.engineering.status: not_created` 是正常待创作状态;configuration_required 才需要检查已有工程并补配置。
21
+ 接入完成且需求尚未明确时,引导用户描述想法,暂不选择工程类型。无工程时使用 `shaper_create(workspace, type)`(CLI:`shaper create --type react`)创建可运行工程并安装依赖;已有工程保留原技术栈。功能参考通过 shaper_template_add 获取,读说明后融合。not_created 是待创作状态;configuration_required 才需要检查已有工程并补配置。
22
22
 
23
23
  用 Agent 自带的文件工具编写项目。`shaper_dev_start` 返回就绪 URL 后,在浏览器检查用户实际会用的交互、控制台错误和窄屏布局。开发日志用 `shaper_dev_logs`。停止服务用 `shaper_dev_stop`;状态查询不会重启服务。
24
24
 
@@ -30,7 +30,7 @@ description: 检查新旧 Shaper 项目的归属,初始化或关联应用,
30
30
 
31
31
  ## 复用完整项目模板
32
32
 
33
- 需要排行榜或离线养成时,调用 `shaper_templates`(CLI:`shaper templates`),读取对应目录的 `docs/integration.md`。每个模板包含自己的前端、所需后端、数据库与说明。新空工程可用 `leaderboard` 或 `offline-game` 创建;已有工程先检查现有身份、积分、存档与路由,再按说明增量融合并验证原业务,模板目录只读。后端迁移与部署交由 shaper-backend。
33
+ 需要排行榜或离线养成时,调用 `shaper_template_list` 查看功能模板,调用 `shaper_template_add(workspace, name)` 提取到 templates/<name>,先读 README 和 docs/integration.md。检查现有身份、积分、存档与路由,再增量融合并验证原业务;提取不代表已接入。后端迁移与部署交由 shaper-backend。
34
34
 
35
35
  ## 用户引导
36
36
 
@@ -34,12 +34,13 @@
34
34
  - 接入完成条件:应用存在、权限正确、绑定已保存。没有源码无需构建,接入后按用户需求继续;没有需求则引导描述想法。
35
35
  - 后续工程创建、上传和提审使用同一个 App ID,不再从网页新建应用。
36
36
 
37
- ## 按需求创建工程
37
+ ## 工程创建与功能参考
38
38
 
39
- - 需求明确且尚无业务工程时,使用 `shaper_create(workspace, template)`。轻量页面可选 h5,复杂页面交互可选 react,实时游戏可选 phaser;依据实际需求,不按“游戏”一词强制选引擎。CLI 为 `shaper create --template react`,默认当前目录。
40
- - create 只写本地模板并安装依赖,不登录、不创建应用、不改绑定。已有工程直接沿用;文件冲突时由 AI 检查,不能删除源码或用户文档强行重建。
41
- - 同目录同模板重试会恢复原创建;完成后再次执行不覆盖代码。安装失败先排查后重试同一命令;不要换模板或删除记录。显式跳过安装时返回 dependencies_required,仍需安装依赖后验证。
42
- - 生成后实现需求,执行 shaper_check、shaper_build 和受管预览,检查实际交互后给出试玩入口。not_created 表示还没建立工程,不是接入失败。
39
+ - 无工程且需求明确时,调用 `shaper_create(workspace, type)`,CLI 为 `shaper create --type react`。h5 用于轻量页面,react 用于复杂交互,phaser 用于实时游戏;AI 按需求选择。
40
+ - create 在工程目录生成源码、配置并安装依赖,保留绑定与产品文档;已有业务代码时停止。中断重试同类型;跳过安装返回 dependencies_required,安装后继续验证。
41
+ - 功能参考使用 `shaper_template_add(workspace, name)`,CLI 为 `shaper template add server`。只提取到 templates/<name>,返回 template_ready 和说明路径,不安装依赖或部署。
42
+ - AI 读说明,检查现有工程,再融合代码、依赖和迁移。多个模板可共存,重复获取保留修改;冲突不覆盖。
43
+ - 正式工程完成后执行 shaper_check、shaper_build 和受管预览,检查交互后给试玩入口。
43
44
 
44
45
  ## 工程配置
45
46
 
@@ -18,7 +18,7 @@ description: 实现游戏可玩循环、场景与资源,检查试玩并根据
18
18
 
19
19
  ## 按需协作
20
20
 
21
- - 离线成长、自动产出、离线结算使用 shaper-idle-game;未安装时按需求补充。代码参考通过 shaper_templates 查找 offline-game/docs/integration.md,已有工程融合现有状态和存档,空工程才用 create。
21
+ - 离线成长、自动产出、离线结算使用 shaper-idle-game;未安装时按需求补充。代码参考通过 shaper_template_list 查找 offline-game/docs/integration.md,已有工程融合现有状态和存档,空工程才用 create。
22
22
  - 可信奖励、排行榜及共享数据由 shaper-backend 处理;虎扑身份和分享由 hupu-business 接入。按需使用,平台授权仍走既有流程。
23
23
  - 工程、预览和构建复用 shaper-development;产品、体验及验证仍维护现有三份文档,不建立另一套 GDD、角色体系或任务看板。
24
24
 
@@ -1,3 +1,3 @@
1
1
  # 一起刷新纪录
2
2
 
3
- 完整项目模板;使用方式与已有项目融合见 docs/integration.md。先运行 npm ci,再运行 npm test 与 npm run build。
3
+ 功能参考模板,先读 docs/integration.md,再融合到正式工程。保留原源码和配置,在正式工程中安装依赖、构建并验证。
@@ -6,5 +6,6 @@
6
6
  "serverSdk": {
7
7
  "name": "@hupu-tech/shaper-cloud",
8
8
  "version": "0.3.0"
9
- }
9
+ },
10
+ "name": "ranking"
10
11
  }
@@ -4,12 +4,14 @@
4
4
  {
5
5
  "method": "GET",
6
6
  "path": "/api/leaderboard",
7
- "access": "public"
7
+ "access": "public",
8
+ "function": "ranking"
8
9
  },
9
10
  {
10
11
  "method": "POST",
11
12
  "path": "/api/leaderboard/scores",
12
- "access": "user"
13
+ "access": "user",
14
+ "function": "ranking"
13
15
  }
14
16
  ]
15
17
  }
@@ -1,6 +1,6 @@
1
1
  # 集成排行榜
2
2
 
3
- 新项目:init 后 shaper create --template leaderboard;根目录 npm ci;npm run backend:install 安装后端。已有项目:读取本模板,按下列步骤融合,保留现有主入口和业务。
3
+ 先通过 `shaper template add leaderboard` 获取参考。空工程先用 `shaper create --type h5`(或其他合适类型)创建工程;已有工程保留技术栈。按以下步骤融合,在正式工程中安装依赖和验证。
4
4
 
5
5
  1. 检查已有身份、积分表、成绩产生逻辑和主服务。已有用户/积分能力优先复用;不要复制本模板创建第二套 puid 或分数。
6
6
  2. 参考 cloud/functions/api/leaderboard.cjs,把路由接到现有 Express app;其他框架保持原框架,移植相同身份和SQL规则。SDK 客户端在服务中复用,入口只启动一次。
@@ -1,3 +1,3 @@
1
1
  # 离线小花园
2
2
 
3
- 完整项目模板;使用方式与已有项目融合见 docs/integration.md。先运行 npm ci,再运行 npm test 与 npm run build。
3
+ 功能参考模板,先读 docs/integration.md,再融合到正式工程。保留原源码和配置,在正式工程中安装依赖、构建并验证。
@@ -1,6 +1,6 @@
1
1
  # 集成离线养成
2
2
 
3
- 新项目:先 init 关联应用,再 shaper create --template offline-game。已有工程:只读本模板,保留原入口、技术栈和存档。
3
+ 先通过 `shaper template add offline-game` 获取参考。空工程先用 `shaper create --type h5`(或其他合适类型)创建工程;已有工程保留技术栈。按以下步骤融合,在正式工程中安装依赖和验证。
4
4
 
5
5
  1. 先找现有资源余额、升级规则、计时和存档模块;已有能力直接复用,不新建第二套余额。
6
6
  2. 参考 src/game.js 的 settle/upgrade,映射到现有字段和经济规则。存档 key 用项目自己的名称;已有存档增加版本迁移,不清空。
@@ -0,0 +1,25 @@
1
+ # 服务调用示例
2
+
3
+ 两个按钮演示前后端调用与玩家鉴权,不涉及数据库或存档。
4
+
5
+ | 前端按钮 | 接口 | 网关 access | 返回 |
6
+ | --- | --- | --- | --- |
7
+ | 获取消息 | GET /api/message | public | 服务已连接 |
8
+ | 查看我的身份 | POST /api/me | user | 当前玩家的可信 puid |
9
+
10
+ ## 融合到项目
11
+
12
+ - `frontend/index.html`:单文件示例。将按钮和请求逻辑融合到已有页面,保留原入口与技术栈;空白静态工程可作为首页。通过 Shaper 预览使用壳提供的 SDK,不手动拼接地址或 Token。
13
+ - `backend/functions/activity/` → 项目 `cloud/functions/activity/`:普通 Express 服务。缺失时复制,已有服务则融合接口与依赖,复用服务入口。`cloud.json` 声明函数 name 与运行规格。
14
+ - `backend/gateway/routes.json` → 项目 `cloud/gateway/routes.json`:合并路由,保留原接口与 access。每条 function 对应函数 name,改名时同步引用。package.json 已配置相对网关路径,无需拆分配置。
15
+
16
+ 在正式函数目录安装依赖,完成业务修改后执行 `shaper cloud deploy`。已有云环境先查状态;需开通时执行 `shaper cloud create`,由用户网页确认。模板目录只供参考,不直接部署。
17
+
18
+ 验证消息可匿名读取;未登录调用 me 被拒绝;登录后返回当前玩家,原业务仍正常。将实际结果写入 `docs/validation.md`。
19
+
20
+ 同一应用环境内,同名函数更新、不同名创建,目录名不决定身份。AI 负责融合与验证,用户无需决定如何复制文件。本示例无需数据库迁移;玩家存档使用平台独立云存档能力。
21
+
22
+ ## 第三方依赖
23
+
24
+ - 第三方依赖属于各自函数的 package.json。在正式函数目录执行 `npm install 包名`,同步提交 package.json 与 package-lock.json,然后在 server.cjs 中引入。前端依赖放前端工程,不与函数依赖混用。
25
+ - 部署会打包函数使用的依赖;当前适用于可打包为 Node.js 20 CommonJS 的依赖。原生二进制、运行时动态加载文件等依赖需要额外适配与验证,不能假定任意 npm 包都可直接部署。
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "activity"
3
+ }
@@ -1,10 +1,10 @@
1
1
  {
2
- "name": "hupu-cloud-progress-acceptance",
2
+ "name": "shaper-service-example",
3
3
  "lockfileVersion": 3,
4
4
  "requires": true,
5
5
  "packages": {
6
6
  "": {
7
- "name": "hupu-cloud-progress-acceptance",
7
+ "name": "shaper-service-example",
8
8
  "dependencies": {
9
9
  "@hupu-tech/shaper-cloud": "0.3.0",
10
10
  "express": "5.1.0",
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "shaper-service-example",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "engines": {
6
+ "node": ">=20"
7
+ },
8
+ "dependencies": {
9
+ "@hupu-tech/shaper-cloud": "0.3.0",
10
+ "express": "5.1.0",
11
+ "supports-color": "8.1.1"
12
+ },
13
+ "hupuCloud": {
14
+ "schemaVersion": 1,
15
+ "entry": "server.cjs",
16
+ "manifest": "cloud.json",
17
+ "gateway": "../../gateway/routes.json"
18
+ }
19
+ }
@@ -0,0 +1,30 @@
1
+ const express = require('express');
2
+ const { createClient, ShaperCloudError } = require('@hupu-tech/shaper-cloud');
3
+
4
+ // 运行环境注入当前应用的身份配置,业务代码不写 Token 或云厂商密钥。
5
+ const cloud = createClient();
6
+ const app = express();
7
+ app.use(express.json({ limit: '64kb' }));
8
+
9
+ // 网关 access:public:任何用户都能读取。静态示例无需数据库或迁移。
10
+ app.get('/api/message', (_req, res) => {
11
+ res.json({ message: '服务已连接' });
12
+ });
13
+
14
+ // 网关 access:user:前端由平台 SDK 携带凭据;服务端仍需校验。
15
+ // 身份来自 requireUser,不接受请求 body 传入的 puid。此接口不保存任何数据。
16
+ app.post('/api/me', async (req, res, next) => {
17
+ try {
18
+ const user = await cloud.auth.requireUser({ authorization: req.get('authorization') });
19
+ res.json({ puid: user.puid });
20
+ } catch (error) { next(error); }
21
+ });
22
+
23
+ app.use((error, _req, res, _next) => {
24
+ if (error instanceof ShaperCloudError) {
25
+ return res.status(error.status).json({ code: error.code, message: error.publicMessage });
26
+ }
27
+ res.status(error.status === 400 ? 400 : 500).json({ code: error.status === 400 ? 'INVALID_JSON' : 'INTERNAL_ERROR' });
28
+ });
29
+ const server = app.listen(Number(process.env.PORT ?? 9000), '0.0.0.0');
30
+ process.once('SIGTERM', () => server.close(() => { void cloud.close(); }));
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 1,
3
+ "routes": [
4
+ {
5
+ "method": "GET",
6
+ "path": "/api/message",
7
+ "access": "public",
8
+ "function": "activity"
9
+ },
10
+ {
11
+ "method": "POST",
12
+ "path": "/api/me",
13
+ "access": "user",
14
+ "function": "activity"
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,42 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>服务调用示例</title>
7
+ </head>
8
+ <body>
9
+ <h1>服务调用示例</h1>
10
+ <button type="button" data-path="/api/message" data-method="GET">获取消息</button>
11
+ <button type="button" data-path="/api/me" data-method="POST">查看我的身份</button>
12
+ <pre id="result" role="status" aria-live="polite">点击按钮查看结果</pre>
13
+ <script>
14
+ // 从 Shaper 预览入口打开,壳提供 SDK、应用身份与玩家凭据。
15
+ // 融合到已有页面时保留项目入口,只接入按钮和请求逻辑。
16
+ const result = document.getElementById('result');
17
+ async function request(path, method) {
18
+ const sdk = window.ShaperAI;
19
+ if (!sdk?.cloud?.request) throw new Error('请从 Shaper 预览入口打开');
20
+ const response = await sdk.cloud.request({ path, method });
21
+ if (response.statusCode === 401) throw new Error('请先登录,再查看我的身份');
22
+ if (response.statusCode < 200 || response.statusCode >= 300) {
23
+ throw new Error(response.message || '服务暂不可用,请稍后重试');
24
+ }
25
+ return response.data;
26
+ }
27
+ document.querySelectorAll('button[data-path]').forEach(button => {
28
+ button.addEventListener('click', async () => {
29
+ button.disabled = true;
30
+ result.textContent = '正在请求…';
31
+ try {
32
+ result.textContent = JSON.stringify(await request(button.dataset.path, button.dataset.method), null, 2);
33
+ } catch (error) {
34
+ result.textContent = error.message;
35
+ } finally {
36
+ button.disabled = false;
37
+ }
38
+ });
39
+ });
40
+ </script>
41
+ </body>
42
+ </html>