@simplysm/capacitor-plugin-intent 12.16.41
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 +188 -0
- package/android/build.gradle +14 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/kr/co/simplysm/capacitor/intent/IntentPlugin.java +376 -0
- package/dist/src/IIntentPlugin.d.ts +63 -0
- package/dist/src/IIntentPlugin.js +1 -0
- package/dist/src/Intent.d.ts +64 -0
- package/dist/src/Intent.js +80 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/web/IntentWeb.d.ts +19 -0
- package/dist/src/web/IntentWeb.js +24 -0
- package/package.json +26 -0
- package/src/IIntentPlugin.ts +65 -0
- package/src/Intent.ts +90 -0
- package/src/index.ts +2 -0
- package/src/web/IntentWeb.ts +34 -0
- package/tests/slice1-directory-and-config.spec.ts +50 -0
- package/tests/slice2-java-renaming.spec.ts +34 -0
- package/tests/slice3-typescript-renaming.spec.ts +76 -0
- package/tests/slice4-docs-and-deprecation.spec.ts +31 -0
- package/tests/slice5-start-activity-for-result-android.spec.md +98 -0
- package/tests/slice5-start-activity-for-result-types.spec.ts +40 -0
- package/tests/slice6-start-activity-for-result-web.spec.ts +34 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { IActivityResult, IIntentResult, IStartActivityForResultOptions } from "./IIntentPlugin";
|
|
2
|
+
/**
|
|
3
|
+
* Android Intent 송수신 플러그인
|
|
4
|
+
* - 산업용 장치(바코드 스캐너, PDA 등) 연동용
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class Intent {
|
|
7
|
+
/**
|
|
8
|
+
* Intent 수신 등록
|
|
9
|
+
* @returns 해제 함수
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const unsub = await Intent.subscribe(
|
|
14
|
+
* ["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
15
|
+
* (result) => console.log(result.extras)
|
|
16
|
+
* );
|
|
17
|
+
*
|
|
18
|
+
* // 해제
|
|
19
|
+
* unsub();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
static subscribe(filters: string[], callback: (result: IIntentResult) => void): Promise<() => Promise<void>>;
|
|
23
|
+
/**
|
|
24
|
+
* 모든 Intent 수신기 해제
|
|
25
|
+
*/
|
|
26
|
+
static unsubscribeAll(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Intent 전송
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* await Intent.send({
|
|
33
|
+
* action: "com.symbol.datawedge.api.ACTION",
|
|
34
|
+
* extras: {
|
|
35
|
+
* "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING"
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
static send(options: {
|
|
41
|
+
action: string;
|
|
42
|
+
extras?: Record<string, unknown>;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* 앱 시작 Intent 가져오기
|
|
46
|
+
*/
|
|
47
|
+
static getLaunchIntent(): Promise<IIntentResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Activity 시작 후 결과 수신
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const result = await Intent.startActivityForResult({
|
|
54
|
+
* action: "android.intent.action.GET_CONTENT",
|
|
55
|
+
* type: "image/*",
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* if (result.resultCode === -1) { // RESULT_OK
|
|
59
|
+
* console.log("Selected:", result.data);
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
static startActivityForResult(options: IStartActivityForResultOptions): Promise<IActivityResult>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { registerPlugin } from "@capacitor/core";
|
|
2
|
+
const IntentPlugin = registerPlugin("Intent", {
|
|
3
|
+
web: async () => {
|
|
4
|
+
const { IntentWeb } = await import("./web/IntentWeb");
|
|
5
|
+
return new IntentWeb();
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Android Intent 송수신 플러그인
|
|
10
|
+
* - 산업용 장치(바코드 스캐너, PDA 등) 연동용
|
|
11
|
+
*/
|
|
12
|
+
export class Intent {
|
|
13
|
+
/**
|
|
14
|
+
* Intent 수신 등록
|
|
15
|
+
* @returns 해제 함수
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const unsub = await Intent.subscribe(
|
|
20
|
+
* ["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
21
|
+
* (result) => console.log(result.extras)
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* // 해제
|
|
25
|
+
* unsub();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
static async subscribe(filters, callback) {
|
|
29
|
+
const { id } = await IntentPlugin.subscribe({ filters }, callback);
|
|
30
|
+
return async () => {
|
|
31
|
+
await IntentPlugin.unsubscribe({ id });
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 모든 Intent 수신기 해제
|
|
36
|
+
*/
|
|
37
|
+
static async unsubscribeAll() {
|
|
38
|
+
await IntentPlugin.unsubscribeAll();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Intent 전송
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* await Intent.send({
|
|
46
|
+
* action: "com.symbol.datawedge.api.ACTION",
|
|
47
|
+
* extras: {
|
|
48
|
+
* "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING"
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
static async send(options) {
|
|
54
|
+
await IntentPlugin.send(options);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 앱 시작 Intent 가져오기
|
|
58
|
+
*/
|
|
59
|
+
static async getLaunchIntent() {
|
|
60
|
+
return await IntentPlugin.getLaunchIntent();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Activity 시작 후 결과 수신
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const result = await Intent.startActivityForResult({
|
|
68
|
+
* action: "android.intent.action.GET_CONTENT",
|
|
69
|
+
* type: "image/*",
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* if (result.resultCode === -1) { // RESULT_OK
|
|
73
|
+
* console.log("Selected:", result.data);
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
static async startActivityForResult(options) {
|
|
78
|
+
return await IntentPlugin.startActivityForResult(options);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
import { IActivityResult, IIntentPlugin, IIntentResult, IStartActivityForResultOptions } from "../IIntentPlugin";
|
|
3
|
+
export declare class IntentWeb extends WebPlugin implements IIntentPlugin {
|
|
4
|
+
subscribe(_options: {
|
|
5
|
+
filters: string[];
|
|
6
|
+
}, _callback: (result: IIntentResult) => void): Promise<{
|
|
7
|
+
id: string;
|
|
8
|
+
}>;
|
|
9
|
+
unsubscribe(_options: {
|
|
10
|
+
id: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
unsubscribeAll(): Promise<void>;
|
|
13
|
+
send(_options: {
|
|
14
|
+
action: string;
|
|
15
|
+
extras?: Record<string, unknown>;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
getLaunchIntent(): Promise<IIntentResult>;
|
|
18
|
+
startActivityForResult(_options: IStartActivityForResultOptions): Promise<IActivityResult>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
export class IntentWeb extends WebPlugin {
|
|
3
|
+
async subscribe(_options, _callback) {
|
|
4
|
+
alert("[Intent] 웹 환경에서는 Intent를 지원하지 않습니다.");
|
|
5
|
+
return await Promise.resolve({ id: "web-stub" });
|
|
6
|
+
}
|
|
7
|
+
async unsubscribe(_options) {
|
|
8
|
+
await Promise.resolve();
|
|
9
|
+
}
|
|
10
|
+
async unsubscribeAll() {
|
|
11
|
+
await Promise.resolve();
|
|
12
|
+
}
|
|
13
|
+
async send(_options) {
|
|
14
|
+
alert("[Intent] 웹 환경에서는 Intent를 지원하지 않습니다.");
|
|
15
|
+
await Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
async getLaunchIntent() {
|
|
18
|
+
return await Promise.resolve({});
|
|
19
|
+
}
|
|
20
|
+
async startActivityForResult(_options) {
|
|
21
|
+
alert("[Intent] 웹 환경에서는 startActivityForResult를 지원하지 않습니다.");
|
|
22
|
+
return await Promise.resolve({ resultCode: 0 });
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@simplysm/capacitor-plugin-intent",
|
|
3
|
+
"version": "12.16.41",
|
|
4
|
+
"description": "심플리즘 패키지 - Capacitor Intent Plugin",
|
|
5
|
+
"author": "김석래",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/kslhunter/simplysm.git",
|
|
9
|
+
"directory": "packages/capacitor-plugin-intent"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"capacitor": {
|
|
16
|
+
"android": {
|
|
17
|
+
"src": "android"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@capacitor/core": "^7.4.4"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@capacitor/core": "^7.6.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface IIntentResult {
|
|
2
|
+
/** Intent action */
|
|
3
|
+
action?: string;
|
|
4
|
+
/** Extra data */
|
|
5
|
+
extras?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IStartActivityForResultOptions {
|
|
9
|
+
/** Intent action */
|
|
10
|
+
action: string;
|
|
11
|
+
/** Data URI */
|
|
12
|
+
uri?: string;
|
|
13
|
+
/** Extra data */
|
|
14
|
+
extras?: Record<string, unknown>;
|
|
15
|
+
/** Target package name */
|
|
16
|
+
package?: string;
|
|
17
|
+
/** Target component class name */
|
|
18
|
+
component?: string;
|
|
19
|
+
/** MIME type */
|
|
20
|
+
type?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IActivityResult {
|
|
24
|
+
/** Activity result code (RESULT_OK = -1, RESULT_CANCELED = 0) */
|
|
25
|
+
resultCode: number;
|
|
26
|
+
/** Result data URI */
|
|
27
|
+
data?: string;
|
|
28
|
+
/** Result extras */
|
|
29
|
+
extras?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IIntentPlugin {
|
|
33
|
+
/**
|
|
34
|
+
* Intent 수신기 등록
|
|
35
|
+
*/
|
|
36
|
+
subscribe(
|
|
37
|
+
options: { filters: string[] },
|
|
38
|
+
callback: (result: IIntentResult) => void,
|
|
39
|
+
): Promise<{ id: string }>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 특정 Intent 수신기 해제
|
|
43
|
+
*/
|
|
44
|
+
unsubscribe(options: { id: string }): Promise<void>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 모든 Intent 수신기 해제
|
|
48
|
+
*/
|
|
49
|
+
unsubscribeAll(): Promise<void>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Intent 전송
|
|
53
|
+
*/
|
|
54
|
+
send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 앱 시작 Intent 가져오기
|
|
58
|
+
*/
|
|
59
|
+
getLaunchIntent(): Promise<IIntentResult>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Activity 시작 후 결과 수신
|
|
63
|
+
*/
|
|
64
|
+
startActivityForResult(options: IStartActivityForResultOptions): Promise<IActivityResult>;
|
|
65
|
+
}
|
package/src/Intent.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { registerPlugin } from "@capacitor/core";
|
|
2
|
+
import { IActivityResult, IIntentPlugin, IIntentResult, IStartActivityForResultOptions } from "./IIntentPlugin";
|
|
3
|
+
|
|
4
|
+
const IntentPlugin = registerPlugin<IIntentPlugin>("Intent", {
|
|
5
|
+
web: async () => {
|
|
6
|
+
const { IntentWeb } = await import("./web/IntentWeb");
|
|
7
|
+
return new IntentWeb();
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Android Intent 송수신 플러그인
|
|
13
|
+
* - 산업용 장치(바코드 스캐너, PDA 등) 연동용
|
|
14
|
+
*/
|
|
15
|
+
export abstract class Intent {
|
|
16
|
+
/**
|
|
17
|
+
* Intent 수신 등록
|
|
18
|
+
* @returns 해제 함수
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const unsub = await Intent.subscribe(
|
|
23
|
+
* ["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
24
|
+
* (result) => console.log(result.extras)
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* // 해제
|
|
28
|
+
* unsub();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
static async subscribe(
|
|
32
|
+
filters: string[],
|
|
33
|
+
callback: (result: IIntentResult) => void,
|
|
34
|
+
): Promise<() => Promise<void>> {
|
|
35
|
+
const { id } = await IntentPlugin.subscribe({ filters }, callback);
|
|
36
|
+
return async () => {
|
|
37
|
+
await IntentPlugin.unsubscribe({ id });
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 모든 Intent 수신기 해제
|
|
43
|
+
*/
|
|
44
|
+
static async unsubscribeAll(): Promise<void> {
|
|
45
|
+
await IntentPlugin.unsubscribeAll();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Intent 전송
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* await Intent.send({
|
|
54
|
+
* action: "com.symbol.datawedge.api.ACTION",
|
|
55
|
+
* extras: {
|
|
56
|
+
* "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING"
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
static async send(options: { action: string; extras?: Record<string, unknown> }): Promise<void> {
|
|
62
|
+
await IntentPlugin.send(options);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 앱 시작 Intent 가져오기
|
|
67
|
+
*/
|
|
68
|
+
static async getLaunchIntent(): Promise<IIntentResult> {
|
|
69
|
+
return await IntentPlugin.getLaunchIntent();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Activity 시작 후 결과 수신
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const result = await Intent.startActivityForResult({
|
|
78
|
+
* action: "android.intent.action.GET_CONTENT",
|
|
79
|
+
* type: "image/*",
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* if (result.resultCode === -1) { // RESULT_OK
|
|
83
|
+
* console.log("Selected:", result.data);
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
static async startActivityForResult(options: IStartActivityForResultOptions): Promise<IActivityResult> {
|
|
88
|
+
return await IntentPlugin.startActivityForResult(options);
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
import { IActivityResult, IIntentPlugin, IIntentResult, IStartActivityForResultOptions } from "../IIntentPlugin";
|
|
3
|
+
|
|
4
|
+
export class IntentWeb extends WebPlugin implements IIntentPlugin {
|
|
5
|
+
async subscribe(
|
|
6
|
+
_options: { filters: string[] },
|
|
7
|
+
_callback: (result: IIntentResult) => void,
|
|
8
|
+
): Promise<{ id: string }> {
|
|
9
|
+
alert("[Intent] 웹 환경에서는 Intent를 지원하지 않습니다.");
|
|
10
|
+
return await Promise.resolve({ id: "web-stub" });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async unsubscribe(_options: { id: string }): Promise<void> {
|
|
14
|
+
await Promise.resolve();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async unsubscribeAll(): Promise<void> {
|
|
18
|
+
await Promise.resolve();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async send(_options: { action: string; extras?: Record<string, unknown> }): Promise<void> {
|
|
22
|
+
alert("[Intent] 웹 환경에서는 Intent를 지원하지 않습니다.");
|
|
23
|
+
await Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getLaunchIntent(): Promise<IIntentResult> {
|
|
27
|
+
return await Promise.resolve({});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async startActivityForResult(_options: IStartActivityForResultOptions): Promise<IActivityResult> {
|
|
31
|
+
alert("[Intent] 웹 환경에서는 startActivityForResult를 지원하지 않습니다.");
|
|
32
|
+
return await Promise.resolve({ resultCode: 0 });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
|
|
4
|
+
const pkgRoot = resolve(import.meta.dirname, "..");
|
|
5
|
+
const monoRoot = resolve(pkgRoot, "../..");
|
|
6
|
+
|
|
7
|
+
describe("Slice 1: 디렉토리 이동 및 설정 파일 변경", () => {
|
|
8
|
+
// Scenario: 디렉토리 이동
|
|
9
|
+
test("패키지가 packages/capacitor-plugin-intent/ 경로에 존재한다", () => {
|
|
10
|
+
expect(existsSync(resolve(monoRoot, "packages/capacitor-plugin-intent"))).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("packages/capacitor-plugin-broadcast/ 경로는 존재하지 않는다", () => {
|
|
14
|
+
expect(existsSync(resolve(monoRoot, "packages/capacitor-plugin-broadcast"))).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Scenario: npm 패키지명 변경
|
|
18
|
+
test("package.json의 name이 @simplysm/capacitor-plugin-intent이다", () => {
|
|
19
|
+
const pkg = JSON.parse(readFileSync(resolve(pkgRoot, "package.json"), "utf-8"));
|
|
20
|
+
expect(pkg.name).toBe("@simplysm/capacitor-plugin-intent");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Scenario: package.json 메타데이터 갱신
|
|
24
|
+
test("package.json의 description에 Intent가 포함된다", () => {
|
|
25
|
+
const pkg = JSON.parse(readFileSync(resolve(pkgRoot, "package.json"), "utf-8"));
|
|
26
|
+
expect(pkg.description).toContain("Intent");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("package.json의 repository.directory가 packages/capacitor-plugin-intent이다", () => {
|
|
30
|
+
const pkg = JSON.parse(readFileSync(resolve(pkgRoot, "package.json"), "utf-8"));
|
|
31
|
+
expect(pkg.repository.directory).toBe("packages/capacitor-plugin-intent");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Scenario: simplysm.js 설정 키 변경
|
|
35
|
+
test("simplysm.js에서 capacitor-plugin-intent 키로 패키지가 등록되어 있다", async () => {
|
|
36
|
+
const config = (await import(resolve(monoRoot, "simplysm.js"))).default();
|
|
37
|
+
expect(config.packages["capacitor-plugin-intent"]).toBeDefined();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("simplysm.js에서 capacitor-plugin-broadcast 키는 존재하지 않는다", async () => {
|
|
41
|
+
const config = (await import(resolve(monoRoot, "simplysm.js"))).default();
|
|
42
|
+
expect(config.packages["capacitor-plugin-broadcast"]).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Scenario: build.gradle namespace 변경
|
|
46
|
+
test("build.gradle namespace가 kr.co.simplysm.capacitor.intent이다", () => {
|
|
47
|
+
const gradle = readFileSync(resolve(pkgRoot, "android/build.gradle"), "utf-8");
|
|
48
|
+
expect(gradle).toContain('namespace "kr.co.simplysm.capacitor.intent"');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
|
|
4
|
+
const pkgRoot = resolve(import.meta.dirname, "..");
|
|
5
|
+
const javaBase = resolve(pkgRoot, "android/src/main/java/kr/co/simplysm/capacitor");
|
|
6
|
+
|
|
7
|
+
describe("Slice 2: Java 소스 리네이밍", () => {
|
|
8
|
+
// Scenario: Java 패키지 경로 변경
|
|
9
|
+
test("IntentPlugin.java가 intent/ 경로에 존재한다", () => {
|
|
10
|
+
expect(existsSync(resolve(javaBase, "intent/IntentPlugin.java"))).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("이전 broadcast/ 디렉토리는 존재하지 않는다", () => {
|
|
14
|
+
expect(existsSync(resolve(javaBase, "broadcast"))).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Scenario: Java 패키지 선언 변경
|
|
18
|
+
test("package 선언이 kr.co.simplysm.capacitor.intent이다", () => {
|
|
19
|
+
const java = readFileSync(resolve(javaBase, "intent/IntentPlugin.java"), "utf-8");
|
|
20
|
+
expect(java).toContain("package kr.co.simplysm.capacitor.intent;");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Scenario: Java 클래스명 변경
|
|
24
|
+
test("클래스명이 IntentPlugin이다", () => {
|
|
25
|
+
const java = readFileSync(resolve(javaBase, "intent/IntentPlugin.java"), "utf-8");
|
|
26
|
+
expect(java).toContain("public class IntentPlugin extends Plugin");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Scenario: Capacitor 플러그인 등록명 변경
|
|
30
|
+
test('@CapacitorPlugin(name = "Intent")로 등록된다', () => {
|
|
31
|
+
const java = readFileSync(resolve(javaBase, "intent/IntentPlugin.java"), "utf-8");
|
|
32
|
+
expect(java).toContain('@CapacitorPlugin(name = "Intent")');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
|
|
4
|
+
const pkgRoot = resolve(import.meta.dirname, "..");
|
|
5
|
+
const srcDir = resolve(pkgRoot, "src");
|
|
6
|
+
|
|
7
|
+
describe("Slice 3: TypeScript 소스 리네이밍", () => {
|
|
8
|
+
// Scenario: 메인 클래스 파일 및 클래스명 변경
|
|
9
|
+
test("Intent.ts에 abstract class Intent가 존재한다", () => {
|
|
10
|
+
expect(existsSync(resolve(srcDir, "Intent.ts"))).toBe(true);
|
|
11
|
+
const content = readFileSync(resolve(srcDir, "Intent.ts"), "utf-8");
|
|
12
|
+
expect(content).toContain("abstract class Intent");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('registerPlugin<IIntentPlugin>("Intent", ...) 호출이 존재한다', () => {
|
|
16
|
+
const content = readFileSync(resolve(srcDir, "Intent.ts"), "utf-8");
|
|
17
|
+
expect(content).toContain('registerPlugin<IIntentPlugin>("Intent"');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Scenario: 플러그인 인터페이스 파일 및 타입명 변경
|
|
21
|
+
test("IIntentPlugin.ts에 IIntentPlugin, IIntentResult 인터페이스가 존재한다", () => {
|
|
22
|
+
expect(existsSync(resolve(srcDir, "IIntentPlugin.ts"))).toBe(true);
|
|
23
|
+
const content = readFileSync(resolve(srcDir, "IIntentPlugin.ts"), "utf-8");
|
|
24
|
+
expect(content).toContain("interface IIntentPlugin");
|
|
25
|
+
expect(content).toContain("interface IIntentResult");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Scenario: Web stub 파일 및 클래스명 변경
|
|
29
|
+
test("IntentWeb.ts에 class IntentWeb extends WebPlugin implements IIntentPlugin이 존재한다", () => {
|
|
30
|
+
expect(existsSync(resolve(srcDir, "web/IntentWeb.ts"))).toBe(true);
|
|
31
|
+
const content = readFileSync(resolve(srcDir, "web/IntentWeb.ts"), "utf-8");
|
|
32
|
+
expect(content).toContain("class IntentWeb extends WebPlugin implements IIntentPlugin");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Scenario: index.ts export 경로 갱신
|
|
36
|
+
test('index.ts에 export * from "./Intent"와 export * from "./IIntentPlugin"이 존재한다', () => {
|
|
37
|
+
const content = readFileSync(resolve(srcDir, "index.ts"), "utf-8");
|
|
38
|
+
expect(content).toContain('export * from "./Intent"');
|
|
39
|
+
expect(content).toContain('export * from "./IIntentPlugin"');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Scenario: subscribe API 보존
|
|
43
|
+
test("Intent.subscribe API가 존재하고 함수를 반환한다", async () => {
|
|
44
|
+
const mod = await import(resolve(srcDir, "Intent.ts"));
|
|
45
|
+
expect(typeof mod.Intent.subscribe).toBe("function");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Scenario: send API 보존
|
|
49
|
+
test("Intent.send API가 존재한다", async () => {
|
|
50
|
+
const mod = await import(resolve(srcDir, "Intent.ts"));
|
|
51
|
+
expect(typeof mod.Intent.send).toBe("function");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Scenario: getLaunchIntent API 보존
|
|
55
|
+
test("Intent.getLaunchIntent API가 존재한다", async () => {
|
|
56
|
+
const mod = await import(resolve(srcDir, "Intent.ts"));
|
|
57
|
+
expect(typeof mod.Intent.getLaunchIntent).toBe("function");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Scenario: unsubscribeAll API 보존
|
|
61
|
+
test("Intent.unsubscribeAll API가 존재한다", async () => {
|
|
62
|
+
const mod = await import(resolve(srcDir, "Intent.ts"));
|
|
63
|
+
expect(typeof mod.Intent.unsubscribeAll).toBe("function");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Scenario: Web 환경에서 stub 동작
|
|
67
|
+
test("IntentWeb이 IIntentPlugin의 모든 메서드를 구현한다", async () => {
|
|
68
|
+
const mod = await import(resolve(srcDir, "web/IntentWeb.ts"));
|
|
69
|
+
const web = new mod.IntentWeb();
|
|
70
|
+
expect(typeof web.subscribe).toBe("function");
|
|
71
|
+
expect(typeof web.unsubscribe).toBe("function");
|
|
72
|
+
expect(typeof web.unsubscribeAll).toBe("function");
|
|
73
|
+
expect(typeof web.send).toBe("function");
|
|
74
|
+
expect(typeof web.getLaunchIntent).toBe("function");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
|
|
4
|
+
const pkgRoot = resolve(import.meta.dirname, "..");
|
|
5
|
+
const monoRoot = resolve(pkgRoot, "../..");
|
|
6
|
+
|
|
7
|
+
describe("Slice 4: 문서 갱신 및 npm deprecated", () => {
|
|
8
|
+
// Scenario: 패키지 README 갱신
|
|
9
|
+
test("패키지 README.md에 @simplysm/capacitor-plugin-intent 설치 안내가 있다", () => {
|
|
10
|
+
const readme = readFileSync(resolve(pkgRoot, "README.md"), "utf-8");
|
|
11
|
+
expect(readme).toContain("@simplysm/capacitor-plugin-intent");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("패키지 README.md에 broadcast/Broadcast 문자열이 존재하지 않는다", () => {
|
|
15
|
+
const readme = readFileSync(resolve(pkgRoot, "README.md"), "utf-8");
|
|
16
|
+
// BroadcastReceiver는 Android API 용어이므로 제외하지 않음 — 여기서는 플러그인 이름 참조만 검사
|
|
17
|
+
expect(readme).not.toMatch(/capacitor-plugin-broadcast/);
|
|
18
|
+
expect(readme).not.toMatch(/\bBroadcast\b/);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Scenario: 루트 README 갱신
|
|
22
|
+
test("루트 README.md에 capacitor-plugin-intent 항목이 존재한다", () => {
|
|
23
|
+
const readme = readFileSync(resolve(monoRoot, "README.md"), "utf-8");
|
|
24
|
+
expect(readme).toContain("capacitor-plugin-intent");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("루트 README.md에 capacitor-plugin-broadcast 항목은 존재하지 않는다", () => {
|
|
28
|
+
const readme = readFileSync(resolve(monoRoot, "README.md"), "utf-8");
|
|
29
|
+
expect(readme).not.toContain("capacitor-plugin-broadcast");
|
|
30
|
+
});
|
|
31
|
+
});
|