@jolibox/sdk 1.1.12 → 1.1.13-beta.10
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/.rush/temp/package-deps_build.json +10 -8
- package/.rush/temp/shrinkwrap-deps.json +155 -2
- package/dist/api/index.d.ts +1 -0
- package/dist/api/request.d.ts +7 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +1519 -0
- package/dist/loader/h5.d.ts +5 -0
- package/dist/sdks/lifecycle.d.ts +1 -0
- package/dist/sdks/router.d.ts +15 -0
- package/esbuild.config.js +26 -0
- package/package.json +7 -4
- package/sdk.build.log +4 -4
- package/src/api/index.ts +1 -0
- package/src/api/request.ts +15 -0
- package/src/index.ts +7 -2
- package/src/loader/h5.ts +12 -2
- package/src/loader/index.ts +3 -3
- package/src/sdks/lifecycle.ts +2 -2
- package/src/sdks/router.ts +30 -0
package/dist/loader/h5.d.ts
CHANGED
package/dist/sdks/lifecycle.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class LifecycleSDK extends BaseSDK<LifecycleSDKEventMap> implemen
|
|
|
9
9
|
onReady(callback: (info?: Env['hostUserInfo']) => void): void;
|
|
10
10
|
exit(params: {
|
|
11
11
|
onBeforeExit: () => void;
|
|
12
|
+
shouldStay?: boolean;
|
|
12
13
|
}): {
|
|
13
14
|
code: import("@jolibox/types").ResponseType;
|
|
14
15
|
message: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseSDK } from './sdk';
|
|
2
|
+
import { Router, ResponseType, StandardResponse } from '@jolibox/types';
|
|
3
|
+
export declare class RouterSDK extends BaseSDK implements Router {
|
|
4
|
+
openSchema(schema: string): Promise<{
|
|
5
|
+
code: ResponseType;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
openPage(url: string): Promise<StandardResponse<{
|
|
9
|
+
webviewId: number;
|
|
10
|
+
}>>;
|
|
11
|
+
closePage(webviewId: number): Promise<{
|
|
12
|
+
code: ResponseType;
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
package/esbuild.config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const esbuild = require('esbuild');
|
|
2
2
|
const fs = require('fs');
|
|
3
|
+
const babel = require('@babel/core');
|
|
3
4
|
|
|
4
5
|
function versionPlugin(version) {
|
|
5
6
|
return {
|
|
@@ -52,9 +53,34 @@ function build(format) {
|
|
|
52
53
|
'.js': 'jsx'
|
|
53
54
|
},
|
|
54
55
|
plugins: [versionPlugin(process.env.BUILD_VERSION || '1.0.0')],
|
|
56
|
+
inject: ['../../polyfills/abort-controller-polyfill.js'],
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
// Step 1: Bundle with esbuild
|
|
61
|
+
esbuild.buildSync({
|
|
62
|
+
entryPoints: ['src/index.js'],
|
|
63
|
+
bundle: true,
|
|
64
|
+
outfile: 'dist/temp.js',
|
|
65
|
+
format: 'iife',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Step 2: Transform with Babel
|
|
69
|
+
const code = fs.readFileSync('dist/temp.js', 'utf8');
|
|
70
|
+
const result = babel.transformSync(code, {
|
|
71
|
+
presets: [
|
|
72
|
+
['@babel/preset-env', {
|
|
73
|
+
targets: {
|
|
74
|
+
safari: '14'
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Write the final output
|
|
81
|
+
fs.writeFileSync('dist/index.js', result.code);
|
|
82
|
+
fs.unlinkSync('dist/temp.js'); // Clean up temp file
|
|
83
|
+
|
|
58
84
|
(async ()=>{
|
|
59
85
|
try{
|
|
60
86
|
await build(options.format);
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/sdk",
|
|
3
3
|
"description": "This project is common Jolibox JS-SDk interfere",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.13-beta.10",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"typings": "dist/index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@jolibox/common": "1.1.
|
|
11
|
-
"@jolibox/types": "1.1.
|
|
10
|
+
"@jolibox/common": "1.1.13-beta.10",
|
|
11
|
+
"@jolibox/types": "1.1.13-beta.10"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"typescript": "5.7.3",
|
|
15
15
|
"@jolibox/eslint-config": "1.0.0",
|
|
16
16
|
"@types/jest": "28.1.1",
|
|
17
17
|
"rimraf": "6.0.1",
|
|
18
|
-
"esbuild": "0.24.2"
|
|
18
|
+
"esbuild": "0.24.2",
|
|
19
|
+
"@babel/core": "7.23.3",
|
|
20
|
+
"@babel/preset-env": "7.23.3",
|
|
21
|
+
"@babel/preset-typescript": "7.23.3"
|
|
19
22
|
},
|
|
20
23
|
"scripts": {
|
|
21
24
|
"clean": "rimraf ./dist",
|
package/sdk.build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/sdk@1.1.
|
|
3
|
+
> @jolibox/sdk@1.1.13-beta.10 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.1.
|
|
7
|
+
> @jolibox/sdk@1.1.13-beta.10 build:cjs
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
> @jolibox/sdk@1.1.
|
|
11
|
+
> @jolibox/sdk@1.1.13-beta.10 build:esm
|
|
12
12
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
> @jolibox/sdk@1.1.
|
|
15
|
+
> @jolibox/sdk@1.1.13-beta.10 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|
package/src/api/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RequestParams } from '@jolibox/types';
|
|
2
|
+
import { canIUse } from './can-i-use';
|
|
3
|
+
import { createCommands } from '@jolibox/common';
|
|
4
|
+
|
|
5
|
+
const commands = createCommands();
|
|
6
|
+
|
|
7
|
+
export async function request(params: RequestParams) {
|
|
8
|
+
if (!canIUse('request')) {
|
|
9
|
+
return {
|
|
10
|
+
code: 'FAILURE' as ResponseType,
|
|
11
|
+
message: '[Jolibox SDK]request is not supported in this platform'
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return await commands.executeCommand('HttpSDK.request', params);
|
|
15
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,13 +8,14 @@ import './loader';
|
|
|
8
8
|
/**
|
|
9
9
|
* @public Jolibox JS SDK Entry
|
|
10
10
|
*/
|
|
11
|
-
import { getSystemInfoSync, canIUse, login, checkSession } from './api';
|
|
11
|
+
import { getSystemInfoSync, canIUse, login, checkSession, request } from './api';
|
|
12
12
|
import { RuntimeSDK } from './sdks/runtime';
|
|
13
13
|
import { LifecycleSDK } from './sdks/lifecycle';
|
|
14
14
|
import { StorageSDK } from './sdks/storage';
|
|
15
15
|
import { JoliboxAds } from './sdks/ads';
|
|
16
16
|
import { KeyboardSDK } from './sdks/keyboard';
|
|
17
17
|
import { TaskTrackerSDK } from './sdks/task';
|
|
18
|
+
import { RouterSDK } from './sdks/router';
|
|
18
19
|
|
|
19
20
|
declare global {
|
|
20
21
|
interface Window {
|
|
@@ -26,6 +27,7 @@ declare global {
|
|
|
26
27
|
storage: InstanceType<typeof StorageSDK>;
|
|
27
28
|
keyboard: InstanceType<typeof KeyboardSDK>;
|
|
28
29
|
task: InstanceType<typeof TaskTrackerSDK>;
|
|
30
|
+
router: InstanceType<typeof RouterSDK>;
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -38,12 +40,14 @@ export class JoliboxSDK {
|
|
|
38
40
|
readonly storage = new StorageSDK();
|
|
39
41
|
readonly keyboard = new KeyboardSDK();
|
|
40
42
|
readonly task = new TaskTrackerSDK();
|
|
43
|
+
readonly router = new RouterSDK();
|
|
41
44
|
|
|
42
45
|
//global API
|
|
43
46
|
getSystemInfoSync = getSystemInfoSync.bind(this);
|
|
44
47
|
canIUse = canIUse.bind(this);
|
|
45
48
|
login = login.bind(this);
|
|
46
49
|
checkSession = checkSession.bind(this);
|
|
50
|
+
request = request.bind(this);
|
|
47
51
|
|
|
48
52
|
constructor() {
|
|
49
53
|
window.joliboxsdk = {
|
|
@@ -52,7 +56,8 @@ export class JoliboxSDK {
|
|
|
52
56
|
lifecycle: this.lifecycle,
|
|
53
57
|
storage: this.storage,
|
|
54
58
|
keyboard: this.keyboard,
|
|
55
|
-
task: this.task
|
|
59
|
+
task: this.task,
|
|
60
|
+
router: this.router
|
|
56
61
|
};
|
|
57
62
|
}
|
|
58
63
|
}
|
package/src/loader/h5.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getOriginalLocalStorage } from '@jolibox/common';
|
|
1
2
|
import { compare, major } from './version';
|
|
2
3
|
import { track, trackPerformance } from '../utils/report';
|
|
3
4
|
import { InternalJSModuleEvalError, InternalJSModuleFetchError } from '@jolibox/common';
|
|
@@ -5,6 +6,13 @@ import { getBoostrapModuleUrl, getImplementModuleUrl } from './index';
|
|
|
5
6
|
import { timeline } from '../events';
|
|
6
7
|
import { testMode } from '@/utils/env';
|
|
7
8
|
import { trackError } from '@/utils/event-tracker';
|
|
9
|
+
getOriginalLocalStorage();
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
__joliboxLocalStorage__: Storage;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
8
16
|
|
|
9
17
|
const LOCAL_STORE_KEY = 'jolibox-sdk-loadermeta';
|
|
10
18
|
interface LocalStoreMeta {
|
|
@@ -16,7 +24,9 @@ interface LocalStoreMeta {
|
|
|
16
24
|
timestamp?: number;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
const CURRENT_VERSION_STORE: LocalStoreMeta = JSON.parse(
|
|
27
|
+
const CURRENT_VERSION_STORE: LocalStoreMeta = JSON.parse(
|
|
28
|
+
window.__joliboxLocalStorage__.getItem(LOCAL_STORE_KEY) ?? '{}'
|
|
29
|
+
);
|
|
20
30
|
const now = Date.now();
|
|
21
31
|
|
|
22
32
|
const expired = (now: number, prev: number) =>
|
|
@@ -67,7 +77,7 @@ async function fetchCurrentRemoteScript() {
|
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
window.__joliboxLocalStorage__.setItem(LOCAL_STORE_KEY, JSON.stringify(currentStore));
|
|
71
81
|
} catch (error) {
|
|
72
82
|
console.warn('Failed to fetch loader metadata: ', error);
|
|
73
83
|
}
|
package/src/loader/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { major } from './version';
|
|
2
|
-
|
|
3
2
|
import { createLoadImplement as createH5LoadImplement } from './h5';
|
|
4
3
|
import { createLoadImplement as createNativeLoadImplement } from './native';
|
|
4
|
+
|
|
5
5
|
//TODO: temp
|
|
6
6
|
const BUILD_VERSION = '__JOLIBOX_LOCAL_SDK_VERSION__';
|
|
7
7
|
const currentVersion = BUILD_VERSION;
|
|
@@ -43,9 +43,9 @@ const loadScript = isNative
|
|
|
43
43
|
* as this logic needs to remain self-contained within the SDK.
|
|
44
44
|
*/
|
|
45
45
|
export const getBoostrapModuleUrl = (version: string | number) =>
|
|
46
|
-
`https://
|
|
46
|
+
`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${version}/dist/index.js`;
|
|
47
47
|
export const getImplementModuleUrl = (version: string | number) =>
|
|
48
|
-
`https://
|
|
48
|
+
`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${version}/dist/index.js`;
|
|
49
49
|
|
|
50
50
|
const checkReleaseVersion = (version: string): boolean => {
|
|
51
51
|
const semverRegex = /^\d+\.\d+\.\d+$/;
|
package/src/sdks/lifecycle.ts
CHANGED
|
@@ -19,12 +19,12 @@ export class LifecycleSDK extends BaseSDK<LifecycleSDKEventMap> implements Lifec
|
|
|
19
19
|
this.commands.executeCommand('LifecycleSDK.onReady', wrappedOnReady.bind(this));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
exit(params: { onBeforeExit: () => void }) {
|
|
22
|
+
exit(params: { onBeforeExit: () => void; shouldStay?: boolean }) {
|
|
23
23
|
const errMsg = this.canIUseIfThrow('lifeCycle.exit');
|
|
24
24
|
if (errMsg) {
|
|
25
25
|
return errMsg;
|
|
26
26
|
}
|
|
27
|
-
this.commands.executeCommand('LifecycleSDK.exit', params.onBeforeExit);
|
|
27
|
+
this.commands.executeCommand('LifecycleSDK.exit', params.onBeforeExit, params.shouldStay);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
onJoliboxHide(params: () => void) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseSDK } from './sdk';
|
|
2
|
+
import { Router, ResponseType, StandardResponse } from '@jolibox/types';
|
|
3
|
+
|
|
4
|
+
export class RouterSDK extends BaseSDK implements Router {
|
|
5
|
+
async openSchema(schema: string) {
|
|
6
|
+
const errMsg = this.canIUseIfThrow('router.openSchema');
|
|
7
|
+
if (errMsg) {
|
|
8
|
+
return errMsg;
|
|
9
|
+
}
|
|
10
|
+
return await this.commands.executeCommand('RouterSDK.openSchema', schema);
|
|
11
|
+
}
|
|
12
|
+
async openPage(url: string): Promise<
|
|
13
|
+
StandardResponse<{
|
|
14
|
+
webviewId: number;
|
|
15
|
+
}>
|
|
16
|
+
> {
|
|
17
|
+
const errMsg = this.canIUseIfThrow('router.openPage');
|
|
18
|
+
if (errMsg) {
|
|
19
|
+
return errMsg;
|
|
20
|
+
}
|
|
21
|
+
return await this.commands.executeCommand('RouterSDK.openPage', url);
|
|
22
|
+
}
|
|
23
|
+
async closePage(webviewId: number) {
|
|
24
|
+
const errMsg = this.canIUseIfThrow('router.closePage');
|
|
25
|
+
if (errMsg) {
|
|
26
|
+
return errMsg;
|
|
27
|
+
}
|
|
28
|
+
return await this.commands.executeCommand('RouterSDK.closePage', webviewId);
|
|
29
|
+
}
|
|
30
|
+
}
|