@dlinglive/widget 0.0.0-stage → 0.1.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.
- package/dist/index.d.ts +25 -0
- package/dist/index.js +33 -0
- package/dist/react.d.ts +5 -0
- package/dist/react.js +11 -0
- package/package.json +54 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const DEFAULT_LOADER_SRC = "https://dling.live/widget/v1/loader.js";
|
|
2
|
+
export interface BootOptions {
|
|
3
|
+
channel: string;
|
|
4
|
+
}
|
|
5
|
+
export interface LoadOptions {
|
|
6
|
+
src?: string;
|
|
7
|
+
}
|
|
8
|
+
type Command = "boot" | "open" | "close" | "destroy";
|
|
9
|
+
type Global = ((cmd: Command, ...args: unknown[]) => void) & {
|
|
10
|
+
q?: unknown[][];
|
|
11
|
+
loaded?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare global {
|
|
14
|
+
interface Window {
|
|
15
|
+
DlingLive?: Global;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export interface DlingLiveApi {
|
|
19
|
+
boot(options: BootOptions): void;
|
|
20
|
+
open(): void;
|
|
21
|
+
close(): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function loadDlingLive(options?: LoadOptions): DlingLiveApi;
|
|
25
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// npm entry for dlinglive. The widget itself is the CDN loader; this package only injects it and types its API,
|
|
2
|
+
// so a widget fix ships through the CDN without a package release.
|
|
3
|
+
export const DEFAULT_LOADER_SRC = "https://dling.live/widget/v1/loader.js";
|
|
4
|
+
const SCRIPT_ID = "dlinglive-loader";
|
|
5
|
+
function call(cmd, ...args) {
|
|
6
|
+
window.DlingLive?.(cmd, ...args);
|
|
7
|
+
}
|
|
8
|
+
const api = {
|
|
9
|
+
boot: (options) => call("boot", options),
|
|
10
|
+
open: () => call("open"),
|
|
11
|
+
close: () => call("close"),
|
|
12
|
+
destroy: () => call("destroy"),
|
|
13
|
+
};
|
|
14
|
+
// Idempotent: the first call installs a queue stub and the script tag; calls before the script loads are replayed by it.
|
|
15
|
+
export function loadDlingLive(options = {}) {
|
|
16
|
+
if (typeof window === "undefined")
|
|
17
|
+
return api;
|
|
18
|
+
if (!window.DlingLive) {
|
|
19
|
+
const stub = (...args) => {
|
|
20
|
+
stub.q ??= [];
|
|
21
|
+
stub.q.push(args);
|
|
22
|
+
};
|
|
23
|
+
window.DlingLive = stub;
|
|
24
|
+
}
|
|
25
|
+
if (!document.getElementById(SCRIPT_ID)) {
|
|
26
|
+
const script = document.createElement("script");
|
|
27
|
+
script.id = SCRIPT_ID;
|
|
28
|
+
script.async = true;
|
|
29
|
+
script.src = options.src ?? DEFAULT_LOADER_SRC;
|
|
30
|
+
document.head.appendChild(script);
|
|
31
|
+
}
|
|
32
|
+
return api;
|
|
33
|
+
}
|
package/dist/react.d.ts
ADDED
package/dist/react.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { loadDlingLive } from "./index";
|
|
3
|
+
// Renders nothing in place: the widget mounts its own floating launcher. Unmount removes it (SPA route changes).
|
|
4
|
+
export function DlingLive({ channel, src }) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const live = loadDlingLive(src === undefined ? {} : { src });
|
|
7
|
+
live.boot({ channel });
|
|
8
|
+
return () => live.destroy();
|
|
9
|
+
}, [channel, src]);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dlinglive/widget",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "dlinglive 라이브 위젯 로더와 React 컴포넌트",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/2ndlifeinc/dlinglive.git",
|
|
9
|
+
"directory": "packages/widget"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./react": {
|
|
25
|
+
"types": "./dist/react.d.ts",
|
|
26
|
+
"import": "./dist/react.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"react": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@biomejs/biome": "2.6.8",
|
|
39
|
+
"@types/react": "19.3.0",
|
|
40
|
+
"@types/react-dom": "19.3.0",
|
|
41
|
+
"happy-dom": "21.0.4",
|
|
42
|
+
"oxlint": "1.94.0",
|
|
43
|
+
"react": "19.3.1",
|
|
44
|
+
"react-dom": "19.3.1",
|
|
45
|
+
"typescript": "6.0.3",
|
|
46
|
+
"vitest": "5.1.1"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
50
|
+
"format": "biome format --write .",
|
|
51
|
+
"format:check": "biome format .",
|
|
52
|
+
"lint": "node ../../scripts/quality/run-oxlint.mjs . && biome check .",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"check:ci": "pnpm format:check && pnpm lint && pnpm typecheck"
|
|
56
|
+
}
|
|
6
57
|
}
|
package/README.md
DELETED