@heybox/hb-sdk 0.8.0-alpha.3 → 0.8.0

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 (72) hide show
  1. package/CHANGELOG.md +136 -422
  2. package/README.md +28 -18
  3. package/dist/cli-chunks/{build-qWzAbpS7.cjs → build-PYCNacya.cjs} +8 -5
  4. package/dist/cli-chunks/{context-CtS2Thp0.cjs → context-m2W2XbL0.cjs} +42 -59
  5. package/dist/cli-chunks/{create-PV5ua977.cjs → create-BdAg3WGA.cjs} +2 -2
  6. package/dist/cli-chunks/{dev-CwKbAm_H.cjs → dev-CyZuw7Yn.cjs} +76 -64
  7. package/dist/cli-chunks/{doctor-tJUGOYrm.cjs → doctor-DU8rCfUF.cjs} +1 -1
  8. package/dist/cli-chunks/{index-DVuD75Hr.cjs → index-DATObqzK.cjs} +2 -2
  9. package/dist/cli-chunks/{index-De687C6-.cjs → index-MMW2ibQm.cjs} +32 -21
  10. package/dist/cli-chunks/{index.esm-B-4yrLNm.cjs → index.esm-BiAaAUFC.cjs} +8 -8
  11. package/dist/cli-chunks/{login-DolpqD8K.cjs → login-B3TThMss.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-1rvkK-M8.cjs → project-vite-BQj8YLI4.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-rIAQE_G2.cjs → remote-DNvI7tHH.cjs} +57 -25
  14. package/dist/cli-chunks/{runtime-gate-DFjw66kF.cjs → runtime-gate-BEFp1w_s.cjs} +11 -3
  15. package/dist/cli-chunks/{runtime-permission-env-CjsCe5bp.cjs → runtime-permission-env-CtL8rsjB.cjs} +351 -0
  16. package/dist/cli-chunks/{session-CzaM2Cq3.cjs → session-DjBkjaF8.cjs} +1 -1
  17. package/dist/cli-chunks/{skill-CM40_9WH.cjs → skill-cR_wnaw2.cjs} +2 -2
  18. package/dist/cli-chunks/{version-Bz-AfXQU.cjs → version-yEn1E2Bg.cjs} +1 -1
  19. package/dist/cli.cjs +1 -1
  20. package/dist/devtools/browser-dev-host/assets/browser-dev-host-TzYf9L6C.js +99 -0
  21. package/dist/devtools/browser-dev-host/assets/{index-CeP6SLB3.js → index-C5MZZDa5.js} +4 -4
  22. package/dist/devtools/browser-dev-host/assets/index-P-ra4m1y.css +1 -0
  23. package/dist/devtools/browser-dev-host/assets/workbench-state-BwV7bm4n.js +5 -0
  24. package/dist/devtools/browser-dev-host/index.html +3 -3
  25. package/dist/index.cjs.js +100 -2
  26. package/dist/index.esm.js +100 -2
  27. package/dist/protocol.cjs.js +189 -47
  28. package/dist/protocol.esm.js +189 -47
  29. package/dist/templates/{vue3-vite-ts → vanilla-vite-js}/.gitignore.ejs +0 -1
  30. package/dist/templates/vanilla-vite-js/README.md.ejs +14 -0
  31. package/dist/templates/vanilla-vite-js/index.html.ejs +20 -0
  32. package/dist/templates/vanilla-vite-js/package.json.ejs +22 -0
  33. package/dist/templates/vanilla-vite-js/src/assets/heybox-logo.svg +8 -0
  34. package/dist/templates/vanilla-vite-js/src/main.js +39 -0
  35. package/dist/templates/vanilla-vite-js/src/styles.css +155 -0
  36. package/dist/templates/{vue3-vite-ts/vite.config.ts → vanilla-vite-js/vite.config.js} +1 -2
  37. package/dist/vite.cjs.js +281 -13
  38. package/dist/vite.esm.js +281 -13
  39. package/package.json +13 -9
  40. package/skill/SKILL.md +8 -9
  41. package/skill/references/api-protocol.md +1 -3
  42. package/skill/references/api-root.md +65 -21
  43. package/skill/references/cli.md +17 -5
  44. package/skill/references/examples.md +3 -3
  45. package/skill/references/recipes.md +40 -41
  46. package/skill/references/safety-boundaries.md +9 -5
  47. package/skill/skill.json +5 -5
  48. package/types/core/mini-dev-console.d.ts +36 -0
  49. package/types/miniapp-manifest/index.d.ts +1 -0
  50. package/types/miniapp-manifest/node.d.ts +3 -0
  51. package/types/miniapp-manifest/permissions.d.ts +37 -0
  52. package/types/miniapp-manifest/schema.d.ts +5 -0
  53. package/types/modules/share/index.d.ts +1 -1
  54. package/types/modules/share/show-share-menu.d.ts +1 -1
  55. package/types/modules/share/types.d.ts +2 -4
  56. package/types/vite/index.d.ts +3 -1
  57. package/dist/devtools/browser-dev-host/assets/browser-dev-host-uq-Wac6k.js +0 -97
  58. package/dist/devtools/browser-dev-host/assets/index-KD2f3Jdz.css +0 -1
  59. package/dist/devtools/browser-dev-host/assets/workbench-state-D-1U0JRq.js +0 -5
  60. package/dist/templates/vue3-vite-ts/README.md.ejs +0 -47
  61. package/dist/templates/vue3-vite-ts/index.html.ejs +0 -12
  62. package/dist/templates/vue3-vite-ts/package.json.ejs +0 -33
  63. package/dist/templates/vue3-vite-ts/src/App.vue +0 -78
  64. package/dist/templates/vue3-vite-ts/src/__tests__/App.spec.ts +0 -148
  65. package/dist/templates/vue3-vite-ts/src/auth-handoff.ts +0 -46
  66. package/dist/templates/vue3-vite-ts/src/main.ts +0 -5
  67. package/dist/templates/vue3-vite-ts/src/styles.css +0 -60
  68. package/dist/templates/vue3-vite-ts/src/vite-env.d.ts +0 -1
  69. package/dist/templates/vue3-vite-ts/tsconfig.app.json +0 -17
  70. package/dist/templates/vue3-vite-ts/tsconfig.json +0 -11
  71. package/dist/templates/vue3-vite-ts/tsconfig.node.json +0 -11
  72. package/dist/templates/vue3-vite-ts/vitest.config.ts +0 -10
@@ -1,46 +0,0 @@
1
- export interface AuthorizationCodeLoginResult {
2
- code: string;
3
- expiresIn: number;
4
- scopes: string[];
5
- }
6
-
7
- export interface LoginAndExchangeAuthorizationCodeOptions {
8
- exchangeUrl?: string;
9
- login: () => Promise<AuthorizationCodeLoginResult>;
10
- request: (config: {
11
- method: 'POST';
12
- url: string;
13
- data: { code: string };
14
- }) => Promise<unknown>;
15
- }
16
-
17
- export async function loginAndExchangeAuthorizationCode(options: LoginAndExchangeAuthorizationCodeOptions) {
18
- const exchangeUrl = options.exchangeUrl?.trim();
19
- if (!exchangeUrl) {
20
- throw new Error('请先配置 VITE_HEYBOX_AUTH_EXCHANGE_URL');
21
- }
22
- if (!isAllowedExchangeUrl(exchangeUrl)) {
23
- throw new Error('VITE_HEYBOX_AUTH_EXCHANGE_URL 必须使用 HTTPS,本地调试仅允许 localhost');
24
- }
25
-
26
- const { code, expiresIn, scopes } = await options.login();
27
- await options.request({
28
- method: 'POST',
29
- url: exchangeUrl,
30
- data: { code },
31
- });
32
-
33
- return { expiresIn, scopes };
34
- }
35
-
36
- function isAllowedExchangeUrl(value: string) {
37
- try {
38
- const url = new URL(value);
39
- if (url.protocol === 'https:') {
40
- return true;
41
- }
42
- return url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
43
- } catch {
44
- return false;
45
- }
46
- }
@@ -1,5 +0,0 @@
1
- import { createApp } from 'vue';
2
- import App from './App.vue';
3
- import './styles.css';
4
-
5
- createApp(App).mount('#app');
@@ -1,60 +0,0 @@
1
- :root {
2
- color: #1f2933;
3
- background: #f4f6f8;
4
- font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
5
- line-height: 1.5;
6
- }
7
- * {
8
- box-sizing: border-box;
9
- }
10
- body {
11
- margin: 0; min-width: 320px;
12
- }
13
- .page {
14
- width: min(100%, 720px);
15
- margin: 0 auto;
16
- padding: 40px 20px;
17
- }
18
- .card {
19
- border: 1px solid #d8dee6;
20
- border-radius: 8px;
21
- background: #fff;
22
- padding: 24px;
23
- }
24
- .eyebrow {
25
- margin: 0 0 8px;
26
- color: #287a4b;
27
- font-size: 13px;
28
- font-weight: 800;
29
- }
30
- h1 {
31
- margin: 0; font-size: 36px; line-height: 1.1;
32
- }
33
- .intro,
34
- .status {
35
- color: #52616f;
36
- }
37
- button {
38
- width: 100%;
39
- min-height: 42px;
40
- border: 0;
41
- border-radius: 6px;
42
- background: #1f2933;
43
- color: #fff;
44
- cursor: pointer;
45
- font: inherit;
46
- font-weight: 700;
47
- }
48
- button:disabled {
49
- cursor: not-allowed; opacity: 0.6;
50
- }
51
- pre {
52
- margin: 16px 0 0;
53
- overflow: auto;
54
- border-radius: 6px;
55
- background: #101820;
56
- color: #f7fbff;
57
- padding: 14px;
58
- white-space: pre-wrap;
59
- word-break: break-word;
60
- }
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "strict": true,
8
- "jsx": "preserve",
9
- "sourceMap": true,
10
- "resolveJsonModule": true,
11
- "isolatedModules": true,
12
- "noEmit": true,
13
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
14
- "types": ["vite/client"]
15
- },
16
- "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
17
- }
@@ -1,11 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- {
5
- "path": "./tsconfig.app.json"
6
- },
7
- {
8
- "path": "./tsconfig.node.json"
9
- }
10
- ]
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "strict": true,
7
- "noEmit": true,
8
- "types": ["node"]
9
- },
10
- "include": ["vite.config.ts", "vitest.config.ts"]
11
- }
@@ -1,10 +0,0 @@
1
- import vue from '@vitejs/plugin-vue';
2
- import { defineConfig } from 'vitest/config';
3
-
4
- export default defineConfig({
5
- plugins: [vue()],
6
- test: {
7
- environment: 'happy-dom',
8
- include: ['src/**/*.spec.ts'],
9
- },
10
- });