@ahnseungchan/webviewkit 1.3.0 → 2.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.
Files changed (54) hide show
  1. package/README.md +68 -61
  2. package/dist/index.d.mts +454 -0
  3. package/dist/index.d.ts +454 -11
  4. package/dist/index.js +1659 -45
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +1574 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +26 -6
  9. package/dist/bridge/WebViewBridgeProvider.d.ts +0 -18
  10. package/dist/bridge/WebViewBridgeProvider.d.ts.map +0 -1
  11. package/dist/bridge/WebViewBridgeProvider.js +0 -26
  12. package/dist/bridge/client.d.ts +0 -20
  13. package/dist/bridge/client.d.ts.map +0 -1
  14. package/dist/bridge/client.js +0 -48
  15. package/dist/bridge/detect-host.d.ts +0 -4
  16. package/dist/bridge/detect-host.d.ts.map +0 -1
  17. package/dist/bridge/detect-host.js +0 -19
  18. package/dist/bridge/host.d.ts +0 -31
  19. package/dist/bridge/host.d.ts.map +0 -1
  20. package/dist/bridge/host.js +0 -77
  21. package/dist/bridge/index.d.ts +0 -10
  22. package/dist/bridge/index.d.ts.map +0 -1
  23. package/dist/bridge/index.js +0 -33
  24. package/dist/bridge/protocol.d.ts +0 -51
  25. package/dist/bridge/protocol.d.ts.map +0 -1
  26. package/dist/bridge/protocol.js +0 -65
  27. package/dist/bridge/stack-router-bridge.d.ts +0 -17
  28. package/dist/bridge/stack-router-bridge.d.ts.map +0 -1
  29. package/dist/bridge/stack-router-bridge.js +0 -38
  30. package/dist/bridge/transport.d.ts +0 -11
  31. package/dist/bridge/transport.d.ts.map +0 -1
  32. package/dist/bridge/transport.js +0 -65
  33. package/dist/constants.d.ts +0 -3
  34. package/dist/constants.d.ts.map +0 -1
  35. package/dist/constants.js +0 -5
  36. package/dist/history.d.ts +0 -11
  37. package/dist/history.d.ts.map +0 -1
  38. package/dist/history.js +0 -91
  39. package/dist/index.d.ts.map +0 -1
  40. package/dist/stack-dev/stack-dev-roadmap.d.ts +0 -15
  41. package/dist/stack-dev/stack-dev-roadmap.d.ts.map +0 -1
  42. package/dist/stack-dev/stack-dev-roadmap.js +0 -66
  43. package/dist/stack-router/_components/back-router.d.ts +0 -3
  44. package/dist/stack-router/_components/back-router.d.ts.map +0 -1
  45. package/dist/stack-router/_components/back-router.js +0 -39
  46. package/dist/stack-router/_components/header.d.ts +0 -3
  47. package/dist/stack-router/_components/header.d.ts.map +0 -1
  48. package/dist/stack-router/_components/header.js +0 -42
  49. package/dist/stack-router/stack-router-provider.d.ts +0 -27
  50. package/dist/stack-router/stack-router-provider.d.ts.map +0 -1
  51. package/dist/stack-router/stack-router-provider.js +0 -227
  52. package/dist/type.d.ts +0 -37
  53. package/dist/type.d.ts.map +0 -1
  54. package/dist/type.js +0 -14
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebViewBridgeProvider = exports.installStackRouterBridge = exports.getStackRouterBridge = exports.createStackRouterBridge = exports.emitBridgeEnvelope = exports.handleBridgeMessage = exports.installBridgeHost = exports.createWebViewBridgeClient = exports.WebViewBridgeClient = exports.createBridgeTransport = exports.isNativeBridgeHost = exports.detectBridgeHost = exports.serializeBridgeMessage = exports.parseBridgeMessage = exports.isBridgeEnvelope = exports.createBridgeEnvelope = exports.createBridgeId = exports.RN_BRIDGE_HANDLER = exports.FLUTTER_UNIFIED_HANDLER = exports.FLUTTER_LEGACY_STACK_HANDLERS = exports.STACK_BRIDGE_METHODS = exports.BRIDGE_NAMESPACE = exports.BRIDGE_PROTOCOL_VERSION = void 0;
4
- var protocol_1 = require("./protocol");
5
- Object.defineProperty(exports, "BRIDGE_PROTOCOL_VERSION", { enumerable: true, get: function () { return protocol_1.BRIDGE_PROTOCOL_VERSION; } });
6
- Object.defineProperty(exports, "BRIDGE_NAMESPACE", { enumerable: true, get: function () { return protocol_1.BRIDGE_NAMESPACE; } });
7
- Object.defineProperty(exports, "STACK_BRIDGE_METHODS", { enumerable: true, get: function () { return protocol_1.STACK_BRIDGE_METHODS; } });
8
- Object.defineProperty(exports, "FLUTTER_LEGACY_STACK_HANDLERS", { enumerable: true, get: function () { return protocol_1.FLUTTER_LEGACY_STACK_HANDLERS; } });
9
- Object.defineProperty(exports, "FLUTTER_UNIFIED_HANDLER", { enumerable: true, get: function () { return protocol_1.FLUTTER_UNIFIED_HANDLER; } });
10
- Object.defineProperty(exports, "RN_BRIDGE_HANDLER", { enumerable: true, get: function () { return protocol_1.RN_BRIDGE_HANDLER; } });
11
- Object.defineProperty(exports, "createBridgeId", { enumerable: true, get: function () { return protocol_1.createBridgeId; } });
12
- Object.defineProperty(exports, "createBridgeEnvelope", { enumerable: true, get: function () { return protocol_1.createBridgeEnvelope; } });
13
- Object.defineProperty(exports, "isBridgeEnvelope", { enumerable: true, get: function () { return protocol_1.isBridgeEnvelope; } });
14
- Object.defineProperty(exports, "parseBridgeMessage", { enumerable: true, get: function () { return protocol_1.parseBridgeMessage; } });
15
- Object.defineProperty(exports, "serializeBridgeMessage", { enumerable: true, get: function () { return protocol_1.serializeBridgeMessage; } });
16
- var detect_host_1 = require("./detect-host");
17
- Object.defineProperty(exports, "detectBridgeHost", { enumerable: true, get: function () { return detect_host_1.detectBridgeHost; } });
18
- Object.defineProperty(exports, "isNativeBridgeHost", { enumerable: true, get: function () { return detect_host_1.isNativeBridgeHost; } });
19
- var transport_1 = require("./transport");
20
- Object.defineProperty(exports, "createBridgeTransport", { enumerable: true, get: function () { return transport_1.createBridgeTransport; } });
21
- var client_1 = require("./client");
22
- Object.defineProperty(exports, "WebViewBridgeClient", { enumerable: true, get: function () { return client_1.WebViewBridgeClient; } });
23
- Object.defineProperty(exports, "createWebViewBridgeClient", { enumerable: true, get: function () { return client_1.createWebViewBridgeClient; } });
24
- var host_1 = require("./host");
25
- Object.defineProperty(exports, "installBridgeHost", { enumerable: true, get: function () { return host_1.installBridgeHost; } });
26
- Object.defineProperty(exports, "handleBridgeMessage", { enumerable: true, get: function () { return host_1.handleBridgeMessage; } });
27
- Object.defineProperty(exports, "emitBridgeEnvelope", { enumerable: true, get: function () { return host_1.emitBridgeEnvelope; } });
28
- var stack_router_bridge_1 = require("./stack-router-bridge");
29
- Object.defineProperty(exports, "createStackRouterBridge", { enumerable: true, get: function () { return stack_router_bridge_1.createStackRouterBridge; } });
30
- Object.defineProperty(exports, "getStackRouterBridge", { enumerable: true, get: function () { return stack_router_bridge_1.getStackRouterBridge; } });
31
- Object.defineProperty(exports, "installStackRouterBridge", { enumerable: true, get: function () { return stack_router_bridge_1.installStackRouterBridge; } });
32
- var WebViewBridgeProvider_1 = require("./WebViewBridgeProvider");
33
- Object.defineProperty(exports, "WebViewBridgeProvider", { enumerable: true, get: function () { return WebViewBridgeProvider_1.WebViewBridgeProvider; } });
@@ -1,51 +0,0 @@
1
- /** WebViewKit native bridge protocol (v1) */
2
- export declare const BRIDGE_PROTOCOL_VERSION: 1;
3
- export declare const BRIDGE_NAMESPACE: "webviewkit";
4
- export type BridgeHostKind = "react-native" | "flutter" | "browser" | "unknown";
5
- /** Stack navigation — maps to common `stackPush` / `stackPop` WebView handlers */
6
- export declare const STACK_BRIDGE_METHODS: {
7
- readonly PUSH: "stack.push";
8
- readonly REPLACE: "stack.replace";
9
- readonly POP: "stack.pop";
10
- readonly RESET: "stack.reset";
11
- };
12
- export type StackBridgeMethod = (typeof STACK_BRIDGE_METHODS)[keyof typeof STACK_BRIDGE_METHODS];
13
- export type StackMeta = Record<string, unknown> | null;
14
- export type StackPushPayload = {
15
- url: string;
16
- meta?: StackMeta;
17
- };
18
- export type StackReplacePayload = StackPushPayload;
19
- export type StackResetPayload = {
20
- url: string;
21
- meta?: StackMeta;
22
- };
23
- export type BridgeErrorBody = {
24
- code: string;
25
- message: string;
26
- };
27
- export type BridgeEnvelope<TPayload = unknown> = {
28
- v: typeof BRIDGE_PROTOCOL_VERSION;
29
- ns: typeof BRIDGE_NAMESPACE;
30
- id: string;
31
- method: string;
32
- payload?: TPayload;
33
- error?: BridgeErrorBody;
34
- };
35
- export declare function createBridgeId(): string;
36
- export declare function createBridgeEnvelope<TPayload>(method: string, payload?: TPayload, id?: string): BridgeEnvelope<TPayload>;
37
- export declare function isBridgeEnvelope(value: unknown): value is BridgeEnvelope;
38
- export declare function parseBridgeMessage(raw: string | unknown): BridgeEnvelope | null;
39
- export declare function serializeBridgeMessage(msg: BridgeEnvelope): string;
40
- /** Flutter InAppWebView legacy handler names */
41
- export declare const FLUTTER_LEGACY_STACK_HANDLERS: {
42
- readonly push: "stackPush";
43
- readonly replace: "stackReplace";
44
- readonly pop: "stackPop";
45
- readonly reset: "stackReset";
46
- };
47
- /** Unified handler name when native listens on one channel */
48
- export declare const FLUTTER_UNIFIED_HANDLER = "webviewkitBridge";
49
- /** React Native receives messages via this global handler name suggestion */
50
- export declare const RN_BRIDGE_HANDLER = "webviewkitBridge";
51
- //# sourceMappingURL=protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAClD,eAAO,MAAM,gBAAgB,EAAG,YAAqB,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEhF,kFAAkF;AAClF,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAEnE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AACjE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,cAAc,CAAC,QAAQ,GAAG,OAAO,IAAI;IAC/C,CAAC,EAAE,OAAO,uBAAuB,CAAC;IAClC,EAAE,EAAE,OAAO,gBAAgB,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,wBAAgB,cAAc,IAAI,MAAM,CAKvC;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAC3C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,QAAQ,EAClB,EAAE,CAAC,EAAE,MAAM,GACV,cAAc,CAAC,QAAQ,CAAC,CAQ1B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CASxE;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,OAAO,GACpB,cAAc,GAAG,IAAI,CAQvB;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAElE;AAED,gDAAgD;AAChD,eAAO,MAAM,6BAA6B;;;;;CAKhC,CAAC;AAEX,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,qBAAqB,CAAC"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RN_BRIDGE_HANDLER = exports.FLUTTER_UNIFIED_HANDLER = exports.FLUTTER_LEGACY_STACK_HANDLERS = exports.STACK_BRIDGE_METHODS = exports.BRIDGE_NAMESPACE = exports.BRIDGE_PROTOCOL_VERSION = void 0;
4
- exports.createBridgeId = createBridgeId;
5
- exports.createBridgeEnvelope = createBridgeEnvelope;
6
- exports.isBridgeEnvelope = isBridgeEnvelope;
7
- exports.parseBridgeMessage = parseBridgeMessage;
8
- exports.serializeBridgeMessage = serializeBridgeMessage;
9
- /** WebViewKit native bridge protocol (v1) */
10
- exports.BRIDGE_PROTOCOL_VERSION = 1;
11
- exports.BRIDGE_NAMESPACE = "webviewkit";
12
- /** Stack navigation — maps to common `stackPush` / `stackPop` WebView handlers */
13
- exports.STACK_BRIDGE_METHODS = {
14
- PUSH: "stack.push",
15
- REPLACE: "stack.replace",
16
- POP: "stack.pop",
17
- RESET: "stack.reset",
18
- };
19
- function createBridgeId() {
20
- if (typeof crypto !== "undefined" && crypto.randomUUID) {
21
- return crypto.randomUUID();
22
- }
23
- return `wv-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
24
- }
25
- function createBridgeEnvelope(method, payload, id) {
26
- return {
27
- v: exports.BRIDGE_PROTOCOL_VERSION,
28
- ns: exports.BRIDGE_NAMESPACE,
29
- id: id !== null && id !== void 0 ? id : createBridgeId(),
30
- method,
31
- ...(payload !== undefined ? { payload } : {}),
32
- };
33
- }
34
- function isBridgeEnvelope(value) {
35
- if (!value || typeof value !== "object")
36
- return false;
37
- const o = value;
38
- return (o.v === exports.BRIDGE_PROTOCOL_VERSION &&
39
- o.ns === exports.BRIDGE_NAMESPACE &&
40
- typeof o.id === "string" &&
41
- typeof o.method === "string");
42
- }
43
- function parseBridgeMessage(raw) {
44
- try {
45
- const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
46
- return isBridgeEnvelope(parsed) ? parsed : null;
47
- }
48
- catch (_a) {
49
- return null;
50
- }
51
- }
52
- function serializeBridgeMessage(msg) {
53
- return JSON.stringify(msg);
54
- }
55
- /** Flutter InAppWebView legacy handler names */
56
- exports.FLUTTER_LEGACY_STACK_HANDLERS = {
57
- push: "stackPush",
58
- replace: "stackReplace",
59
- pop: "stackPop",
60
- reset: "stackReset",
61
- };
62
- /** Unified handler name when native listens on one channel */
63
- exports.FLUTTER_UNIFIED_HANDLER = "webviewkitBridge";
64
- /** React Native receives messages via this global handler name suggestion */
65
- exports.RN_BRIDGE_HANDLER = "webviewkitBridge";
@@ -1,17 +0,0 @@
1
- import type { StackMeta } from "./protocol";
2
- import type { BridgeTransportOptions } from "./transport";
3
- export type StackRouterBridge = {
4
- push: (url: string, meta?: StackMeta) => Promise<unknown>;
5
- replace: (url: string, meta?: StackMeta) => Promise<unknown>;
6
- pop: () => Promise<unknown>;
7
- reset: (url: string) => Promise<unknown>;
8
- };
9
- export type CreateStackRouterBridgeOptions = BridgeTransportOptions;
10
- /**
11
- * Web → native stack navigation (Flutter `callHandler` / RN `postMessage`).
12
- * Returns null in browser-only environments.
13
- */
14
- export declare function createStackRouterBridge(options?: CreateStackRouterBridgeOptions): StackRouterBridge | null;
15
- export declare function getStackRouterBridge(): StackRouterBridge | null;
16
- export declare function installStackRouterBridge(options?: CreateStackRouterBridgeOptions): StackRouterBridge | null;
17
- //# sourceMappingURL=stack-router-bridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-router-bridge.d.ts","sourceRoot":"","sources":["../../src/bridge/stack-router-bridge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,sBAAsB,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,8BAA8B,GACvC,iBAAiB,GAAG,IAAI,CAY1B;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAG/D;AAED,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,8BAA8B,GACvC,iBAAiB,GAAG,IAAI,CAO1B"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStackRouterBridge = createStackRouterBridge;
4
- exports.getStackRouterBridge = getStackRouterBridge;
5
- exports.installStackRouterBridge = installStackRouterBridge;
6
- const client_1 = require("./client");
7
- const detect_host_1 = require("./detect-host");
8
- /**
9
- * Web → native stack navigation (Flutter `callHandler` / RN `postMessage`).
10
- * Returns null in browser-only environments.
11
- */
12
- function createStackRouterBridge(options) {
13
- const host = (0, detect_host_1.detectBridgeHost)();
14
- if (!(0, detect_host_1.isNativeBridgeHost)(host))
15
- return null;
16
- const client = (0, client_1.createWebViewBridgeClient)(options);
17
- return {
18
- push: (url, meta) => client.stackPush(url, meta !== null && meta !== void 0 ? meta : null),
19
- replace: (url, meta) => client.stackReplace(url, meta !== null && meta !== void 0 ? meta : null),
20
- pop: () => client.stackPop(),
21
- reset: (url) => client.stackReset(url),
22
- };
23
- }
24
- function getStackRouterBridge() {
25
- var _a, _b;
26
- if (typeof window === "undefined")
27
- return null;
28
- return (_b = (_a = window.stackRouterBridge) !== null && _a !== void 0 ? _a : createStackRouterBridge()) !== null && _b !== void 0 ? _b : null;
29
- }
30
- function installStackRouterBridge(options) {
31
- if (typeof window === "undefined")
32
- return null;
33
- const bridge = createStackRouterBridge(options);
34
- if (bridge) {
35
- window.stackRouterBridge = bridge;
36
- }
37
- return bridge;
38
- }
@@ -1,11 +0,0 @@
1
- import type { BridgeEnvelope, BridgeHostKind } from "./protocol";
2
- export type BridgeTransportOptions = {
3
- /** Flutter: use stackPush/stackPop handlers (default true) */
4
- flutterLegacyHandlers?: boolean;
5
- };
6
- export interface BridgeTransport {
7
- readonly host: BridgeHostKind;
8
- send(envelope: BridgeEnvelope): Promise<void>;
9
- }
10
- export declare function createBridgeTransport(host?: BridgeHostKind, options?: BridgeTransportOptions): BridgeTransport;
11
- //# sourceMappingURL=transport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/bridge/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQjE,MAAM,MAAM,sBAAsB,GAAG;IACnC,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAoED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,cAAmC,EACzC,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAIjB"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBridgeTransport = createBridgeTransport;
4
- const detect_host_1 = require("./detect-host");
5
- const protocol_1 = require("./protocol");
6
- function stackMethodToLegacyHandler(method) {
7
- switch (method) {
8
- case protocol_1.STACK_BRIDGE_METHODS.PUSH:
9
- return protocol_1.FLUTTER_LEGACY_STACK_HANDLERS.push;
10
- case protocol_1.STACK_BRIDGE_METHODS.REPLACE:
11
- return protocol_1.FLUTTER_LEGACY_STACK_HANDLERS.replace;
12
- case protocol_1.STACK_BRIDGE_METHODS.POP:
13
- return protocol_1.FLUTTER_LEGACY_STACK_HANDLERS.pop;
14
- case protocol_1.STACK_BRIDGE_METHODS.RESET:
15
- return protocol_1.FLUTTER_LEGACY_STACK_HANDLERS.reset;
16
- default:
17
- return null;
18
- }
19
- }
20
- function createReactNativeTransport() {
21
- return {
22
- host: "react-native",
23
- async send(envelope) {
24
- window.ReactNativeWebView.postMessage((0, protocol_1.serializeBridgeMessage)(envelope));
25
- },
26
- };
27
- }
28
- function createFlutterTransport(options) {
29
- const useLegacy = options.flutterLegacyHandlers !== false;
30
- return {
31
- host: "flutter",
32
- async send(envelope) {
33
- var _a, _b;
34
- const call = window.flutter_inappwebview.callHandler.bind(window.flutter_inappwebview);
35
- if (useLegacy) {
36
- const handler = stackMethodToLegacyHandler(envelope.method);
37
- if (handler) {
38
- const payload = envelope.payload;
39
- if (envelope.method === protocol_1.STACK_BRIDGE_METHODS.POP) {
40
- await call(handler);
41
- return;
42
- }
43
- const url = (_a = payload === null || payload === void 0 ? void 0 : payload.url) !== null && _a !== void 0 ? _a : "";
44
- const meta = payload && "meta" in payload ? (_b = payload.meta) !== null && _b !== void 0 ? _b : null : null;
45
- await call(handler, url, meta);
46
- return;
47
- }
48
- }
49
- await call(protocol_1.FLUTTER_UNIFIED_HANDLER, (0, protocol_1.serializeBridgeMessage)(envelope));
50
- },
51
- };
52
- }
53
- const browserTransport = {
54
- host: "browser",
55
- async send() {
56
- /* no native host — web-only */
57
- },
58
- };
59
- function createBridgeTransport(host = (0, detect_host_1.detectBridgeHost)(), options = {}) {
60
- if (host === "react-native")
61
- return createReactNativeTransport();
62
- if (host === "flutter")
63
- return createFlutterTransport(options);
64
- return browserTransport;
65
- }
@@ -1,3 +0,0 @@
1
- /** push/back 애니메이션·history 지연과 동기화 */
2
- export declare const STACK_TRANSITION_MS = 500;
3
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,eAAO,MAAM,mBAAmB,MAAM,CAAC"}
package/dist/constants.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STACK_TRANSITION_MS = void 0;
4
- /** push/back 애니메이션·history 지연과 동기화 */
5
- exports.STACK_TRANSITION_MS = 500;
package/dist/history.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { HistoryListener, HistoryState } from "./type";
2
- export declare const history: {
3
- push: (path: string, data?: unknown) => Promise<void>;
4
- replace: (path: string, data?: unknown) => Promise<void>;
5
- back: () => Promise<void>;
6
- forward: () => Promise<void>;
7
- go: (delta: number) => Promise<void>;
8
- getCurrentState: () => HistoryState;
9
- addListener: (listener: HistoryListener) => () => boolean;
10
- };
11
- //# sourceMappingURL=history.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAqBtE,eAAO,MAAM,OAAO;iBACC,MAAM,SAAS,OAAO;oBAYnB,MAAM,SAAS,OAAO;;;gBAwC1B,MAAM;2BAUH,YAAY;4BAWT,eAAe;CAIxC,CAAC"}
package/dist/history.js DELETED
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.history = void 0;
4
- const type_1 = require("./type");
5
- const constants_1 = require("./constants");
6
- const isBrowser = typeof window !== "undefined";
7
- const listeners = new Set();
8
- const notifyListeners = (state) => {
9
- listeners.forEach((listener) => listener(state));
10
- };
11
- if (isBrowser) {
12
- window.addEventListener("popstate", (event) => {
13
- const state = event.state;
14
- notifyListeners(state);
15
- });
16
- }
17
- const delay = () => new Promise((resolve) => setTimeout(resolve, constants_1.STACK_TRANSITION_MS * 0.6));
18
- exports.history = {
19
- push: async (path, data) => {
20
- if (!isBrowser)
21
- return;
22
- const state = {
23
- path,
24
- data,
25
- action: type_1.HistoryAction.PUSH,
26
- };
27
- window.history.pushState(state, "", path);
28
- await delay();
29
- notifyListeners(state);
30
- },
31
- replace: async (path, data) => {
32
- if (!isBrowser)
33
- return;
34
- const state = {
35
- path,
36
- data,
37
- action: type_1.HistoryAction.REPLACE,
38
- };
39
- window.history.replaceState(state, "", path);
40
- await delay();
41
- notifyListeners(state);
42
- },
43
- back: async () => {
44
- if (!isBrowser)
45
- return;
46
- window.history.back();
47
- await new Promise((resolve) => {
48
- const onPop = () => {
49
- window.removeEventListener("popstate", onPop);
50
- resolve();
51
- };
52
- window.addEventListener("popstate", onPop);
53
- });
54
- notifyListeners({
55
- path: window.location.pathname,
56
- action: type_1.HistoryAction.POP,
57
- });
58
- },
59
- forward: async () => {
60
- if (!isBrowser)
61
- return;
62
- window.history.forward();
63
- await delay();
64
- notifyListeners({
65
- path: window.location.pathname,
66
- action: type_1.HistoryAction.PUSH,
67
- });
68
- },
69
- go: async (delta) => {
70
- if (!isBrowser)
71
- return;
72
- window.history.go(delta);
73
- await delay();
74
- notifyListeners({
75
- path: window.location.pathname,
76
- action: type_1.HistoryAction.PUSH,
77
- });
78
- },
79
- getCurrentState: () => {
80
- if (!isBrowser) {
81
- return { path: "/" };
82
- }
83
- return (window.history.state || {
84
- path: window.location.pathname,
85
- });
86
- },
87
- addListener: (listener) => {
88
- listeners.add(listener);
89
- return () => listeners.delete(listener);
90
- },
91
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,OAAO,IAAI,mBAAmB,EAC9B,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,6BAA6B,EAC7B,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,UAAU,CAAC"}
@@ -1,15 +0,0 @@
1
- export interface StackDevRoadmapProps {
2
- /** 스택에 쌓인 페이지 경로 (아래 → 위 순) */
3
- pages: {
4
- path: string;
5
- }[];
6
- currentPath: string;
7
- /** false면 렌더하지 않음 */
8
- visible?: boolean;
9
- }
10
- /**
11
- * 개발 환경에서 스택 깊이·경로를 눈으로 확인하는 로드맵 오버레이.
12
- * StackRouterProvider `enableDevTools` 와 함께 사용합니다.
13
- */
14
- export declare function StackDevRoadmap({ pages, currentPath, visible, }: StackDevRoadmapProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
15
- //# sourceMappingURL=stack-dev-roadmap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-dev-roadmap.d.ts","sourceRoot":"","sources":["../../src/stack-dev/stack-dev-roadmap.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,WAAW,EACX,OAAc,GACf,EAAE,oBAAoB,2DAkGtB"}
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StackDevRoadmap = StackDevRoadmap;
7
- const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
8
- const react_1 = __importDefault(require("react"));
9
- /**
10
- * 개발 환경에서 스택 깊이·경로를 눈으로 확인하는 로드맵 오버레이.
11
- * StackRouterProvider `enableDevTools` 와 함께 사용합니다.
12
- */
13
- function StackDevRoadmap({ pages, currentPath, visible = true, }) {
14
- if (!visible || pages.length === 0)
15
- return null;
16
- const depth = pages.length;
17
- return ((0, jsx_runtime_1.jsxs)("div", { role: "status", "aria-live": "polite", "aria-label": `WebViewKit stack depth ${depth}`, style: {
18
- position: "fixed",
19
- bottom: 12,
20
- right: 12,
21
- zIndex: 2147483646,
22
- minWidth: 200,
23
- maxWidth: 320,
24
- padding: "10px 12px",
25
- borderRadius: 10,
26
- background: "rgba(7, 11, 18, 0.92)",
27
- border: "1px solid rgba(0, 232, 184, 0.35)",
28
- color: "#e8eef4",
29
- fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',
30
- fontSize: 11,
31
- lineHeight: 1.45,
32
- boxShadow: "0 8px 24px rgba(0,0,0,0.35)",
33
- pointerEvents: "none",
34
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [(0, jsx_runtime_1.jsx)("span", { style: { color: "#00e8b8", fontWeight: 700 }, children: "WebViewKit" }), (0, jsx_runtime_1.jsxs)("span", { style: { color: "#94a3b8" }, children: ["stack \u00D7 ", depth] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
35
- display: "flex",
36
- alignItems: "center",
37
- gap: 0,
38
- marginTop: 10,
39
- padding: "4px 0",
40
- }, children: pages.map((page, index) => {
41
- const isCurrent = page.path === currentPath;
42
- const isLast = index === pages.length - 1;
43
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [index > 0 && ((0, jsx_runtime_1.jsx)("span", { style: {
44
- width: 14,
45
- height: 2,
46
- background: isLast
47
- ? "linear-gradient(90deg,#334155,#00e8b8)"
48
- : "#334155",
49
- flexShrink: 0,
50
- } })), (0, jsx_runtime_1.jsx)("span", { title: page.path, style: {
51
- width: isCurrent ? 12 : 8,
52
- height: isCurrent ? 12 : 8,
53
- borderRadius: "50%",
54
- flexShrink: 0,
55
- background: isCurrent ? "#00e8b8" : "#475569",
56
- boxShadow: isCurrent ? "0 0 10px rgba(0,232,184,0.85)" : "none",
57
- transition: "all 0.2s ease",
58
- } })] }, `${page.path}-${index}`));
59
- }) }), (0, jsx_runtime_1.jsx)("ol", { style: { margin: "8px 0 0", paddingLeft: 18, color: "#cbd5e1" }, children: pages.map((page, index) => {
60
- const isCurrent = index === pages.length - 1;
61
- return ((0, jsx_runtime_1.jsxs)("li", { style: {
62
- fontWeight: isCurrent ? 600 : 400,
63
- color: isCurrent ? "#00e8b8" : "#94a3b8",
64
- }, children: [page.path, isCurrent ? " ← top" : ""] }, `${page.path}-${index}`));
65
- }) })] }));
66
- }
@@ -1,3 +0,0 @@
1
- declare const BackRouter: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
- export default BackRouter;
3
- //# sourceMappingURL=back-router.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"back-router.d.ts","sourceRoot":"","sources":["../../../src/stack-router/_components/back-router.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU,wDAOf,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
7
- const styled_1 = __importDefault(require("@emotion/styled"));
8
- const stack_router_provider_1 = require("../stack-router-provider");
9
- const BackRouter = () => {
10
- const { back } = (0, stack_router_provider_1.useStackRouter)();
11
- return ((0, jsx_runtime_1.jsx)(BackButton, { onClick: back, children: (0, jsx_runtime_1.jsx)(BackIcon, {}) }));
12
- };
13
- exports.default = BackRouter;
14
- /**
15
- styles
16
- */
17
- const BackButton = styled_1.default.button `
18
- display: flex;
19
- align-items: center;
20
- justify-content: center;
21
- width: 40px;
22
- height: 40px;
23
- border: none;
24
- background: none;
25
- cursor: pointer;
26
- padding: 8px;
27
- border-radius: 50%;
28
- transition: all 0.2s;
29
- color: #000000;
30
-
31
- &:hover {
32
- color: #666666;
33
- }
34
-
35
- &:active {
36
- color: #999999;
37
- }
38
- `;
39
- const BackIcon = () => ((0, jsx_runtime_1.jsx)("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M12 20L4 12L12 4", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
@@ -1,3 +0,0 @@
1
- declare const Header: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
- export default Header;
3
- //# sourceMappingURL=header.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/stack-router/_components/header.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,MAAM,wDAmBX,CAAC;AAsBF,eAAe,MAAM,CAAC"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
7
- const react_1 = require("react");
8
- const styled_1 = __importDefault(require("@emotion/styled"));
9
- const back_router_1 = __importDefault(require("./back-router"));
10
- const stack_router_provider_1 = require("../stack-router-provider");
11
- const constants_1 = require("../../constants");
12
- const Header = () => {
13
- const { currentPath, visiblePages } = (0, stack_router_provider_1.useStackRouter)();
14
- const [displayPath, setDisplayPath] = (0, react_1.useState)(currentPath);
15
- const [isVisible, setIsVisible] = (0, react_1.useState)(visiblePages.length > 1);
16
- (0, react_1.useEffect)(() => {
17
- const timer = setTimeout(() => {
18
- setDisplayPath(currentPath);
19
- setIsVisible(visiblePages.length > 1);
20
- }, constants_1.STACK_TRANSITION_MS);
21
- return () => clearTimeout(timer);
22
- }, [currentPath, visiblePages]);
23
- return ((0, jsx_runtime_1.jsxs)(StyledHeader, { children: [isVisible && (0, jsx_runtime_1.jsx)(back_router_1.default, {}), (0, jsx_runtime_1.jsx)(StyledTitle, { children: displayPath })] }));
24
- };
25
- /**
26
- styles
27
- */
28
- const StyledHeader = styled_1.default.header `
29
- width: 100%;
30
- height: 64px;
31
- background-color: white;
32
- border-bottom: 1px solid #e5e7eb;
33
- display: flex;
34
- align-items: center;
35
- padding: 0 1rem;
36
- `;
37
- const StyledTitle = styled_1.default.h1 `
38
- font-size: 1.25rem;
39
- font-weight: 600;
40
- color: #111827;
41
- `;
42
- exports.default = Header;
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- import { HistoryState, StackRouterProviderProps } from "../type";
3
- interface StackRouterContextProps {
4
- currentPath: string;
5
- currentState: HistoryState;
6
- Activities: {
7
- path: string;
8
- element: React.ReactNode;
9
- }[];
10
- initialActivity: {
11
- path: string;
12
- element: React.ReactNode;
13
- };
14
- push: (path: string, data?: any) => void;
15
- replace: (path: string, data?: any) => void;
16
- back: () => void;
17
- forward: () => void;
18
- visiblePages: {
19
- path: string;
20
- element: React.ReactNode;
21
- }[];
22
- }
23
- export declare const useStackRouter: () => StackRouterContextProps;
24
- declare const StackRouterProvider: ({ maxWidth, Activities, initialActivity, enableDevTools, }: StackRouterProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
25
- export default StackRouterProvider;
26
- export { StackRouterProvider };
27
- //# sourceMappingURL=stack-router-provider.d.ts.map