@theaiplatform/miniapp-sdk 0.0.1 → 0.1.0-dev.5264044
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/README.md +2 -58
- package/THIRD_PARTY_NOTICES.md +14 -40
- package/dist/index.d.ts +0 -74
- package/dist/rspack/index.js +0 -119
- package/dist/sdk.d.ts +0 -74
- package/dist/web.d.ts +0 -93
- package/dist/web.js +1 -37
- package/package.json +44 -48
- package/dist/ui/styles.css +0 -3694
- package/dist/ui/tailwind.css +0 -112
- package/dist/ui/theme.css +0 -335
- package/dist/ui.d.ts +0 -826
- package/dist/ui.js +0 -1852
- package/ui-components.json +0 -59
package/dist/web.js
CHANGED
|
@@ -101,14 +101,10 @@ async function openEditorProject(options) {
|
|
|
101
101
|
if ("u" < typeof window) throw new Error('The miniapp host is unavailable.');
|
|
102
102
|
await requestHostAction(OPEN_EDITOR_PROJECT_ACTION, options);
|
|
103
103
|
}
|
|
104
|
-
const MINIAPP_UI_SCALE_MIN = 12;
|
|
105
|
-
const MINIAPP_UI_SCALE_MAX = 20;
|
|
106
|
-
const MINIAPP_UI_SCALE_DEFAULT = 16;
|
|
107
104
|
const MINIAPP_THEME_CHANGED_EVENTS = new Set([
|
|
108
105
|
'zephyr-app-theme-changed',
|
|
109
106
|
'tap-miniapp-theme-changed'
|
|
110
107
|
]);
|
|
111
|
-
const MINIAPP_UI_SCALE_CHANGED_EVENT = 'zephyr-app-ui-scale-changed';
|
|
112
108
|
function isMiniAppTheme(value) {
|
|
113
109
|
return 'light' === value || 'dark' === value;
|
|
114
110
|
}
|
|
@@ -127,21 +123,6 @@ function applyMiniAppTheme(theme) {
|
|
|
127
123
|
document.documentElement.classList.toggle('light', 'light' === theme);
|
|
128
124
|
document.documentElement.style.colorScheme = theme;
|
|
129
125
|
}
|
|
130
|
-
function isMiniAppUiScale(value) {
|
|
131
|
-
return 'number' == typeof value && Number.isInteger(value) && value >= MINIAPP_UI_SCALE_MIN && value <= MINIAPP_UI_SCALE_MAX;
|
|
132
|
-
}
|
|
133
|
-
function getMiniAppUiScaleFromSearch(search = "u" < typeof window ? '' : window.location.search) {
|
|
134
|
-
const params = 'string' == typeof search ? new URLSearchParams(search.startsWith('?') ? search.slice(1) : search) : search;
|
|
135
|
-
const rawScale = params.get('appUiScale');
|
|
136
|
-
if (null === rawScale || '' === rawScale.trim()) return MINIAPP_UI_SCALE_DEFAULT;
|
|
137
|
-
const scale = Number(rawScale);
|
|
138
|
-
return isMiniAppUiScale(scale) ? scale : MINIAPP_UI_SCALE_DEFAULT;
|
|
139
|
-
}
|
|
140
|
-
function applyMiniAppUiScale(scale) {
|
|
141
|
-
if ("u" < typeof document || !isMiniAppUiScale(scale)) return;
|
|
142
|
-
document.documentElement.dataset.uiScale = String(scale);
|
|
143
|
-
document.documentElement.style.setProperty('--app-font-size', `${scale}px`);
|
|
144
|
-
}
|
|
145
126
|
function installMiniAppThemeSync({ applyTheme = applyMiniAppTheme, search } = {}) {
|
|
146
127
|
applyTheme(getMiniAppThemeFromSearch(search));
|
|
147
128
|
if ("u" < typeof window) return ()=>void 0;
|
|
@@ -161,22 +142,5 @@ function installMiniAppThemeSync({ applyTheme = applyMiniAppTheme, search } = {}
|
|
|
161
142
|
window.removeEventListener('message', handleMessage);
|
|
162
143
|
};
|
|
163
144
|
}
|
|
164
|
-
function installMiniAppAppearanceSync({ applyTheme = applyMiniAppTheme, applyUiScale = applyMiniAppUiScale, search } = {}) {
|
|
165
|
-
applyTheme(getMiniAppThemeFromSearch(search));
|
|
166
|
-
applyUiScale(getMiniAppUiScaleFromSearch(search));
|
|
167
|
-
if ("u" < typeof window) return ()=>void 0;
|
|
168
|
-
const hostOrigin = getHostOrigin();
|
|
169
|
-
const parent = window.parent;
|
|
170
|
-
if (!hostOrigin || !parent || parent === window) return ()=>void 0;
|
|
171
|
-
const handleMessage = (event)=>{
|
|
172
|
-
if (event.source !== parent || event.origin !== hostOrigin) return;
|
|
173
|
-
if ('object' != typeof event.data || null === event.data) return;
|
|
174
|
-
const record = event.data;
|
|
175
|
-
if ('string' == typeof record.type && MINIAPP_THEME_CHANGED_EVENTS.has(record.type) && isMiniAppTheme(record.appTheme)) return void applyTheme(record.appTheme);
|
|
176
|
-
if (record.type === MINIAPP_UI_SCALE_CHANGED_EVENT && isMiniAppUiScale(record.appUiScale)) applyUiScale(record.appUiScale);
|
|
177
|
-
};
|
|
178
|
-
window.addEventListener('message', handleMessage);
|
|
179
|
-
return ()=>window.removeEventListener('message', handleMessage);
|
|
180
|
-
}
|
|
181
145
|
export { sdk as app } from "./sdk.js";
|
|
182
|
-
export {
|
|
146
|
+
export { applyMiniAppTheme, getMiniAppThemeFromSearch, getPlatform, installMiniAppThemeSync, openEditorProject, platformSatisfiesApp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theaiplatform/miniapp-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-dev.5264044",
|
|
4
4
|
"description": "Public SDK for building portable miniapps that run in The AI Platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -27,13 +27,6 @@
|
|
|
27
27
|
"types": "./dist/web.d.ts",
|
|
28
28
|
"import": "./dist/web.js"
|
|
29
29
|
},
|
|
30
|
-
"./ui": {
|
|
31
|
-
"types": "./dist/ui.d.ts",
|
|
32
|
-
"import": "./dist/ui.js"
|
|
33
|
-
},
|
|
34
|
-
"./ui/styles.css": "./dist/ui/styles.css",
|
|
35
|
-
"./ui/tailwind.css": "./dist/ui/tailwind.css",
|
|
36
|
-
"./ui-components.json": "./ui-components.json",
|
|
37
30
|
"./surface": {
|
|
38
31
|
"types": "./dist/surface.d.ts",
|
|
39
32
|
"import": "./dist/surface.js"
|
|
@@ -53,14 +46,49 @@
|
|
|
53
46
|
"files": [
|
|
54
47
|
"dist",
|
|
55
48
|
"config-schema.json",
|
|
56
|
-
"ui-components.json",
|
|
57
49
|
"README.md",
|
|
58
50
|
"LICENSE.md",
|
|
59
51
|
"THIRD_PARTY_NOTICES.md"
|
|
60
52
|
],
|
|
53
|
+
"scripts": {
|
|
54
|
+
"prepack": "pnpm run build",
|
|
55
|
+
"build": "rm -rf dist && rslib build && node scripts/copy-rspack-loaders.mjs",
|
|
56
|
+
"test": "rstest run",
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
|
+
},
|
|
61
59
|
"publishConfig": {
|
|
62
60
|
"registry": "https://registry.npmjs.org",
|
|
63
|
-
"access": "public"
|
|
61
|
+
"access": "public",
|
|
62
|
+
"main": "./dist/index.js",
|
|
63
|
+
"module": "./dist/index.js",
|
|
64
|
+
"types": "./dist/index.d.ts",
|
|
65
|
+
"exports": {
|
|
66
|
+
".": {
|
|
67
|
+
"types": "./dist/index.d.ts",
|
|
68
|
+
"import": "./dist/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./sdk": {
|
|
71
|
+
"types": "./dist/sdk.d.ts",
|
|
72
|
+
"import": "./dist/sdk.js"
|
|
73
|
+
},
|
|
74
|
+
"./web": {
|
|
75
|
+
"types": "./dist/web.d.ts",
|
|
76
|
+
"import": "./dist/web.js"
|
|
77
|
+
},
|
|
78
|
+
"./surface": {
|
|
79
|
+
"types": "./dist/surface.d.ts",
|
|
80
|
+
"import": "./dist/surface.js"
|
|
81
|
+
},
|
|
82
|
+
"./config": {
|
|
83
|
+
"types": "./dist/config.d.ts",
|
|
84
|
+
"import": "./dist/config.js"
|
|
85
|
+
},
|
|
86
|
+
"./rspack": {
|
|
87
|
+
"types": "./dist/rspack/index.d.ts",
|
|
88
|
+
"import": "./dist/rspack/index.js"
|
|
89
|
+
},
|
|
90
|
+
"./config-schema.json": "./config-schema.json"
|
|
91
|
+
}
|
|
64
92
|
},
|
|
65
93
|
"peerDependencies": {
|
|
66
94
|
"@module-federation/rsbuild-plugin": "2.8.0",
|
|
@@ -104,44 +132,12 @@
|
|
|
104
132
|
"@module-federation/runtime-tools": "2.8.0",
|
|
105
133
|
"@rsbuild/core": "^2.1.4",
|
|
106
134
|
"@rslib/core": "^0.23.2",
|
|
107
|
-
"@rstest/core": "
|
|
108
|
-
"@
|
|
109
|
-
"
|
|
110
|
-
"postcss": "^8.5.6",
|
|
111
|
-
"tailwindcss": "^4.3.0",
|
|
112
|
-
"tw-animate-css": "^1.4.0",
|
|
113
|
-
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
135
|
+
"@rstest/core": "catalog:rstest",
|
|
136
|
+
"@types/node": "catalog:node",
|
|
137
|
+
"typescript": "catalog:typescript"
|
|
114
138
|
},
|
|
115
139
|
"dependencies": {
|
|
116
|
-
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
117
|
-
"@radix-ui/react-checkbox": "^1.3.3",
|
|
118
|
-
"@radix-ui/react-compose-refs": "^1.1.2",
|
|
119
|
-
"@radix-ui/react-dialog": "^1.1.15",
|
|
120
|
-
"@radix-ui/react-label": "^2.1.8",
|
|
121
|
-
"@radix-ui/react-progress": "^1.1.8",
|
|
122
|
-
"@radix-ui/react-radio-group": "^1.3.8",
|
|
123
|
-
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
124
|
-
"@radix-ui/react-select": "^2.2.6",
|
|
125
|
-
"@radix-ui/react-separator": "^1.1.8",
|
|
126
|
-
"@radix-ui/react-slider": "^1.3.6",
|
|
127
|
-
"@radix-ui/react-slot": "^1.2.4",
|
|
128
|
-
"@radix-ui/react-tabs": "^1.1.13",
|
|
129
|
-
"@radix-ui/react-toggle": "^1.1.10",
|
|
130
|
-
"@radix-ui/react-toggle-group": "^1.1.11",
|
|
131
|
-
"@radix-ui/react-tooltip": "^1.2.8",
|
|
132
140
|
"ajv": "^8.20.0",
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"prism-react-renderer": "^2.4.1",
|
|
137
|
-
"react-resizable-panels": "^4.11.1",
|
|
138
|
-
"saxes": "^6.0.0",
|
|
139
|
-
"tailwind-merge": "^3.6.0"
|
|
140
|
-
},
|
|
141
|
-
"scripts": {
|
|
142
|
-
"build": "rm -rf dist && rslib build && node scripts/copy-rspack-loaders.mjs && node scripts/build-ui-styles.mjs",
|
|
143
|
-
"test": "rstest run",
|
|
144
|
-
"typecheck": "tsc --noEmit"
|
|
145
|
-
},
|
|
146
|
-
"module": "./dist/index.js"
|
|
147
|
-
}
|
|
141
|
+
"saxes": "^6.0.0"
|
|
142
|
+
}
|
|
143
|
+
}
|