@civitai/blocks-react 0.4.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/README.md +48 -0
- package/dist/hooks/useAppStorage.d.ts +75 -0
- package/dist/hooks/useAppStorage.d.ts.map +1 -0
- package/dist/hooks/useAppStorage.js +73 -0
- package/dist/hooks/useAppStorage.js.map +1 -0
- package/dist/hooks/useBlockAnalytics.d.ts +9 -0
- package/dist/hooks/useBlockAnalytics.d.ts.map +1 -0
- package/dist/hooks/useBlockAnalytics.js +14 -0
- package/dist/hooks/useBlockAnalytics.js.map +1 -0
- package/dist/hooks/useBlockContext.d.ts +18 -0
- package/dist/hooks/useBlockContext.d.ts.map +1 -0
- package/dist/hooks/useBlockContext.js +39 -0
- package/dist/hooks/useBlockContext.js.map +1 -0
- package/dist/hooks/useBlockResize.d.ts +13 -0
- package/dist/hooks/useBlockResize.d.ts.map +1 -0
- package/dist/hooks/useBlockResize.js +33 -0
- package/dist/hooks/useBlockResize.js.map +1 -0
- package/dist/hooks/useBlockSettings.d.ts +7 -0
- package/dist/hooks/useBlockSettings.d.ts.map +1 -0
- package/dist/hooks/useBlockSettings.js +9 -0
- package/dist/hooks/useBlockSettings.js.map +1 -0
- package/dist/hooks/useBlockToken.d.ts +16 -0
- package/dist/hooks/useBlockToken.d.ts.map +1 -0
- package/dist/hooks/useBlockToken.js +61 -0
- package/dist/hooks/useBlockToken.js.map +1 -0
- package/dist/hooks/useBuzzPurchase.d.ts +12 -0
- package/dist/hooks/useBuzzPurchase.d.ts.map +1 -0
- package/dist/hooks/useBuzzPurchase.js +16 -0
- package/dist/hooks/useBuzzPurchase.js.map +1 -0
- package/dist/hooks/useBuzzWorkflow.d.ts +21 -0
- package/dist/hooks/useBuzzWorkflow.d.ts.map +1 -0
- package/dist/hooks/useBuzzWorkflow.js +76 -0
- package/dist/hooks/useBuzzWorkflow.js.map +1 -0
- package/dist/hooks/useCheckpointPicker.d.ts +34 -0
- package/dist/hooks/useCheckpointPicker.d.ts.map +1 -0
- package/dist/hooks/useCheckpointPicker.js +41 -0
- package/dist/hooks/useCheckpointPicker.js.map +1 -0
- package/dist/hooks/useCivitaiNavigate.d.ts +11 -0
- package/dist/hooks/useCivitaiNavigate.d.ts.map +1 -0
- package/dist/hooks/useCivitaiNavigate.js +16 -0
- package/dist/hooks/useCivitaiNavigate.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/detector.d.ts +31 -0
- package/dist/internal/detector.d.ts.map +1 -0
- package/dist/internal/detector.js +67 -0
- package/dist/internal/detector.js.map +1 -0
- package/dist/internal/iframeTransport.d.ts +55 -0
- package/dist/internal/iframeTransport.d.ts.map +1 -0
- package/dist/internal/iframeTransport.js +200 -0
- package/dist/internal/iframeTransport.js.map +1 -0
- package/dist/internal/inlineTransport.d.ts +18 -0
- package/dist/internal/inlineTransport.d.ts.map +1 -0
- package/dist/internal/inlineTransport.js +36 -0
- package/dist/internal/inlineTransport.js.map +1 -0
- package/dist/internal/singleton.d.ts +18 -0
- package/dist/internal/singleton.d.ts.map +1 -0
- package/dist/internal/singleton.js +28 -0
- package/dist/internal/singleton.js.map +1 -0
- package/dist/internal/transport.d.ts +100 -0
- package/dist/internal/transport.d.ts.map +1 -0
- package/dist/internal/transport.js +67 -0
- package/dist/internal/transport.js.map +1 -0
- package/dist/internal/validate.d.ts +56 -0
- package/dist/internal/validate.d.ts.map +1 -0
- package/dist/internal/validate.js +202 -0
- package/dist/internal/validate.js.map +1 -0
- package/dist/testing.d.ts +14 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +16 -0
- package/dist/testing.js.map +1 -0
- package/dist/ui/SettingsForm.d.ts +79 -0
- package/dist/ui/SettingsForm.d.ts.map +1 -0
- package/dist/ui/SettingsForm.js +199 -0
- package/dist/ui/SettingsForm.js.map +1 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +10 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BlockCheckpointInfo } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/**
|
|
3
|
+
* Drives the platform-side Checkpoint picker and the persist-override flow.
|
|
4
|
+
*
|
|
5
|
+
* `open` opens the host's Resource picker filtered to Checkpoints in the
|
|
6
|
+
* given ecosystem; resolves with `{ selected }` (undefined when the user
|
|
7
|
+
* dismissed without picking).
|
|
8
|
+
*
|
|
9
|
+
* `persist` writes the chosen versionId into `block_user_settings` via the
|
|
10
|
+
* host. Pass `null` to clear the override and fall back to the publisher
|
|
11
|
+
* default at next mount. Throws on host-side validation failure (e.g.
|
|
12
|
+
* "wrong-ecosystem") — surface the message to the user; don't retry blindly.
|
|
13
|
+
*
|
|
14
|
+
* Both flows are host-mediated: the block never touches the picker UI or
|
|
15
|
+
* the user-settings table directly. Same trust model as useBuzzPurchase /
|
|
16
|
+
* useBuzzWorkflow.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useCheckpointPicker(): {
|
|
19
|
+
open: (opts: {
|
|
20
|
+
/**
|
|
21
|
+
* Ecosystem key (e.g. 'Flux1', 'SDXL'). Get it from
|
|
22
|
+
* `useBlockContext().context.checkpoint?.baseModel` — but for the
|
|
23
|
+
* picker filter the host will collapse to the ecosystem family, so
|
|
24
|
+
* any baseModel in the family works as a hint.
|
|
25
|
+
*/
|
|
26
|
+
baseModelGroup: string;
|
|
27
|
+
/** Currently-selected versionId so the picker can pre-highlight it. */
|
|
28
|
+
currentVersionId?: number;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
selected?: BlockCheckpointInfo;
|
|
31
|
+
}>;
|
|
32
|
+
persist: (versionId: number | null) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=useCheckpointPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCheckpointPicker.d.ts","sourceRoot":"","sources":["../../src/hooks/useCheckpointPicker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAKnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,IAAI;IACrC,IAAI,EAAE,CAAC,IAAI,EAAE;QACX;;;;;WAKG;QACH,cAAc,EAAE,MAAM,CAAC;QACvB,uEAAuE;QACvE,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,KAAK,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,mBAAmB,CAAA;KAAE,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD,CAiCA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { getTransport } from '../internal/singleton.js';
|
|
3
|
+
import { sendTypedRequest } from '../internal/transport.js';
|
|
4
|
+
/**
|
|
5
|
+
* Drives the platform-side Checkpoint picker and the persist-override flow.
|
|
6
|
+
*
|
|
7
|
+
* `open` opens the host's Resource picker filtered to Checkpoints in the
|
|
8
|
+
* given ecosystem; resolves with `{ selected }` (undefined when the user
|
|
9
|
+
* dismissed without picking).
|
|
10
|
+
*
|
|
11
|
+
* `persist` writes the chosen versionId into `block_user_settings` via the
|
|
12
|
+
* host. Pass `null` to clear the override and fall back to the publisher
|
|
13
|
+
* default at next mount. Throws on host-side validation failure (e.g.
|
|
14
|
+
* "wrong-ecosystem") — surface the message to the user; don't retry blindly.
|
|
15
|
+
*
|
|
16
|
+
* Both flows are host-mediated: the block never touches the picker UI or
|
|
17
|
+
* the user-settings table directly. Same trust model as useBuzzPurchase /
|
|
18
|
+
* useBuzzWorkflow.
|
|
19
|
+
*/
|
|
20
|
+
export function useCheckpointPicker() {
|
|
21
|
+
const open = useCallback(async (opts) => {
|
|
22
|
+
const { selected } = await sendTypedRequest(getTransport(), {
|
|
23
|
+
type: 'OPEN_CHECKPOINT_PICKER',
|
|
24
|
+
payload: {
|
|
25
|
+
baseModelGroup: opts.baseModelGroup,
|
|
26
|
+
...(opts.currentVersionId != null
|
|
27
|
+
? { currentVersionId: opts.currentVersionId }
|
|
28
|
+
: {}),
|
|
29
|
+
},
|
|
30
|
+
}, 'CHECKPOINT_PICKER_RESULT');
|
|
31
|
+
return { selected };
|
|
32
|
+
}, []);
|
|
33
|
+
const persist = useCallback(async (versionId) => {
|
|
34
|
+
const { ok, error } = await sendTypedRequest(getTransport(), { type: 'SET_USER_CHECKPOINT', payload: { versionId } }, 'USER_CHECKPOINT_SET');
|
|
35
|
+
if (!ok) {
|
|
36
|
+
throw new Error(error ?? 'failed to persist checkpoint');
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
return { open, persist };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=useCheckpointPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCheckpointPicker.js","sourceRoot":"","sources":["../../src/hooks/useCheckpointPicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB;IAcjC,MAAM,IAAI,GAAG,WAAW,CACtB,KAAK,EAAE,IAA2D,EAAE,EAAE;QACpE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,CACzC,YAAY,EAAE,EACd;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE;gBACP,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI;oBAC/B,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE;oBAC7C,CAAC,CAAC,EAAE,CAAC;aACR;SACF,EACD,0BAA0B,CAC3B,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,CAAC;IACtB,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,SAAwB,EAAE,EAAE;QAC7D,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,MAAM,gBAAgB,CAC1C,YAAY,EAAE,EACd,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EACvD,qBAAqB,CACtB,CAAC;QACF,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,KAAK,IAAI,8BAA8B,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requests a navigation within civitai.com. The host mediates — `target:
|
|
3
|
+
* "current"` navigates the parent frame; `"new_tab"` opens a new tab (which
|
|
4
|
+
* requires `allow-popups-to-escape-sandbox` in the manifest sandbox).
|
|
5
|
+
*
|
|
6
|
+
* Fire-and-forget: the host doesn't reply with confirmation.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useCivitaiNavigate(): {
|
|
9
|
+
navigate: (path: string, target?: 'current' | 'new_tab') => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useCivitaiNavigate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCivitaiNavigate.d.ts","sourceRoot":"","sources":["../../src/hooks/useCivitaiNavigate.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;CAClE,CAKA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { getTransport } from '../internal/singleton.js';
|
|
3
|
+
/**
|
|
4
|
+
* Requests a navigation within civitai.com. The host mediates — `target:
|
|
5
|
+
* "current"` navigates the parent frame; `"new_tab"` opens a new tab (which
|
|
6
|
+
* requires `allow-popups-to-escape-sandbox` in the manifest sandbox).
|
|
7
|
+
*
|
|
8
|
+
* Fire-and-forget: the host doesn't reply with confirmation.
|
|
9
|
+
*/
|
|
10
|
+
export function useCivitaiNavigate() {
|
|
11
|
+
const navigate = useCallback((path, target = 'current') => {
|
|
12
|
+
getTransport().sendMessage({ type: 'NAVIGATE', payload: { path, target } });
|
|
13
|
+
}, []);
|
|
14
|
+
return { navigate };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=useCivitaiNavigate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCivitaiNavigate.js","sourceRoot":"","sources":["../../src/hooks/useCivitaiNavigate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB;IAGhC,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,IAAY,EAAE,SAAgC,SAAS,EAAE,EAAE;QACvF,YAAY,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9E,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@civitai/blocks-react` — React hooks + iframe transport for Civitai App Blocks.
|
|
3
|
+
*
|
|
4
|
+
* Pair with `@civitai/app-sdk/blocks` (framework-agnostic contract). Hooks
|
|
5
|
+
* land in a follow-up commit; this commit ships the transport layer so the
|
|
6
|
+
* platform side can integration-test against a real iframe receiver.
|
|
7
|
+
*/
|
|
8
|
+
export { IframeTransport } from './internal/iframeTransport.js';
|
|
9
|
+
export type { IframeTransportOptions } from './internal/iframeTransport.js';
|
|
10
|
+
export { InlineTransport } from './internal/inlineTransport.js';
|
|
11
|
+
export { BlockTransportDetector, readAllowedOriginsFromEnv } from './internal/detector.js';
|
|
12
|
+
export type { DetectOptions } from './internal/detector.js';
|
|
13
|
+
export { getTransport } from './internal/singleton.js';
|
|
14
|
+
export { sendTypedRequest } from './internal/transport.js';
|
|
15
|
+
export type { BlockSnapshot, BlockTransport, OutboundRequest, } from './internal/transport.js';
|
|
16
|
+
export { useBlockContext } from './hooks/useBlockContext.js';
|
|
17
|
+
export { useBlockSettings } from './hooks/useBlockSettings.js';
|
|
18
|
+
export { useBlockToken } from './hooks/useBlockToken.js';
|
|
19
|
+
export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
|
|
20
|
+
export { useBlockResize } from './hooks/useBlockResize.js';
|
|
21
|
+
export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
|
|
22
|
+
export { useCheckpointPicker } from './hooks/useCheckpointPicker.js';
|
|
23
|
+
export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
|
|
24
|
+
export { useBlockAnalytics } from './hooks/useBlockAnalytics.js';
|
|
25
|
+
export { useAppStorage } from './hooks/useAppStorage.js';
|
|
26
|
+
export type { AppStorageKeyEntry, AppStorageListResult, AppStorageQuota, UseAppStorage, } from './hooks/useAppStorage.js';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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frame transport for Civitai App Blocks.
|
|
3
|
+
*
|
|
4
|
+
* Pair with `@civitai/app-sdk/blocks` (framework-agnostic contract). Hooks
|
|
5
|
+
* land in a follow-up commit; this commit ships the transport layer so the
|
|
6
|
+
* platform side can integration-test against a real iframe receiver.
|
|
7
|
+
*/
|
|
8
|
+
export { IframeTransport } from './internal/iframeTransport.js';
|
|
9
|
+
export { InlineTransport } from './internal/inlineTransport.js';
|
|
10
|
+
export { BlockTransportDetector, readAllowedOriginsFromEnv } from './internal/detector.js';
|
|
11
|
+
export { getTransport } from './internal/singleton.js';
|
|
12
|
+
export { sendTypedRequest } from './internal/transport.js';
|
|
13
|
+
// Hooks
|
|
14
|
+
export { useBlockContext } from './hooks/useBlockContext.js';
|
|
15
|
+
export { useBlockSettings } from './hooks/useBlockSettings.js';
|
|
16
|
+
export { useBlockToken } from './hooks/useBlockToken.js';
|
|
17
|
+
export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
|
|
18
|
+
export { useBlockResize } from './hooks/useBlockResize.js';
|
|
19
|
+
export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
|
|
20
|
+
export { useCheckpointPicker } from './hooks/useCheckpointPicker.js';
|
|
21
|
+
export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
|
|
22
|
+
export { useBlockAnalytics } from './hooks/useBlockAnalytics.js';
|
|
23
|
+
export { useAppStorage } from './hooks/useAppStorage.js';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAO3D,QAAQ;AACR,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BlockTransport } from './transport.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the comma-separated allowlist from the build-time env. The block app
|
|
4
|
+
* sets this at bundling time; the transport refuses to mount without at
|
|
5
|
+
* least one origin.
|
|
6
|
+
*
|
|
7
|
+
* Supported env vars (first match wins):
|
|
8
|
+
* - `VITE_BLOCK_ALLOWED_PARENT_ORIGINS` (Vite, the PWA starters)
|
|
9
|
+
* - `NEXT_PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS` (Next.js)
|
|
10
|
+
* - `PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS` (SvelteKit)
|
|
11
|
+
*
|
|
12
|
+
* In tests / SSR where no env is present, callers should pass
|
|
13
|
+
* `detect({ allowedParentOrigins })` explicitly.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readAllowedOriginsFromEnv(): string[];
|
|
16
|
+
export interface DetectOptions {
|
|
17
|
+
/** Override the env-derived allowlist. Required for tests and inline-mode dev. */
|
|
18
|
+
allowedParentOrigins?: string[];
|
|
19
|
+
/** Override `globalThis.window`. Tests use this with `happy-dom`'s window. */
|
|
20
|
+
window?: Window;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the right transport for the current runtime.
|
|
24
|
+
*
|
|
25
|
+
* - `window.__CIVITAI_BLOCK_CONTEXT__` present → `InlineTransport` (v2)
|
|
26
|
+
* - otherwise → `IframeTransport`
|
|
27
|
+
*/
|
|
28
|
+
export declare const BlockTransportDetector: {
|
|
29
|
+
detect(opts?: DetectOptions): BlockTransport;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/internal/detector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAWpD;AAqBD,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;kBACpB,aAAa,GAAQ,cAAc;CAQjD,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { IframeTransport } from './iframeTransport.js';
|
|
2
|
+
import { InlineTransport } from './inlineTransport.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the comma-separated allowlist from the build-time env. The block app
|
|
5
|
+
* sets this at bundling time; the transport refuses to mount without at
|
|
6
|
+
* least one origin.
|
|
7
|
+
*
|
|
8
|
+
* Supported env vars (first match wins):
|
|
9
|
+
* - `VITE_BLOCK_ALLOWED_PARENT_ORIGINS` (Vite, the PWA starters)
|
|
10
|
+
* - `NEXT_PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS` (Next.js)
|
|
11
|
+
* - `PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS` (SvelteKit)
|
|
12
|
+
*
|
|
13
|
+
* In tests / SSR where no env is present, callers should pass
|
|
14
|
+
* `detect({ allowedParentOrigins })` explicitly.
|
|
15
|
+
*/
|
|
16
|
+
export function readAllowedOriginsFromEnv() {
|
|
17
|
+
const candidates = [
|
|
18
|
+
readEnv('VITE_BLOCK_ALLOWED_PARENT_ORIGINS'),
|
|
19
|
+
readEnv('NEXT_PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS'),
|
|
20
|
+
readEnv('PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS'),
|
|
21
|
+
].filter((v) => !!v);
|
|
22
|
+
if (!candidates.length)
|
|
23
|
+
return [];
|
|
24
|
+
return candidates[0]
|
|
25
|
+
.split(',')
|
|
26
|
+
.map((s) => s.trim())
|
|
27
|
+
.filter(Boolean);
|
|
28
|
+
}
|
|
29
|
+
function readEnv(key) {
|
|
30
|
+
// Vite injects import.meta.env at build time; Node exposes process.env.
|
|
31
|
+
// Read each independently, swallowing access errors (e.g. process undefined in browser).
|
|
32
|
+
try {
|
|
33
|
+
const fromImportMeta = import.meta.env?.[key];
|
|
34
|
+
if (fromImportMeta)
|
|
35
|
+
return fromImportMeta;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
/* ignore */
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const fromProcess = globalThis
|
|
42
|
+
.process?.env?.[key];
|
|
43
|
+
if (fromProcess)
|
|
44
|
+
return fromProcess;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
/* ignore */
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the right transport for the current runtime.
|
|
53
|
+
*
|
|
54
|
+
* - `window.__CIVITAI_BLOCK_CONTEXT__` present → `InlineTransport` (v2)
|
|
55
|
+
* - otherwise → `IframeTransport`
|
|
56
|
+
*/
|
|
57
|
+
export const BlockTransportDetector = {
|
|
58
|
+
detect(opts = {}) {
|
|
59
|
+
const win = opts.window ?? globalThis.window;
|
|
60
|
+
if (win?.__CIVITAI_BLOCK_CONTEXT__) {
|
|
61
|
+
return new InlineTransport();
|
|
62
|
+
}
|
|
63
|
+
const allowedParentOrigins = opts.allowedParentOrigins ?? readAllowedOriginsFromEnv();
|
|
64
|
+
return new IframeTransport({ allowedParentOrigins, window: opts.window });
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../src/internal/detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,UAAU,GAAG;QACjB,OAAO,CAAC,mCAAmC,CAAC;QAC5C,OAAO,CAAC,0CAA0C,CAAC;QACnD,OAAO,CAAC,qCAAqC,CAAC;KAC/C,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,IAAI,CAAC,UAAU,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO,UAAU,CAAC,CAAC,CAAE;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IAC1B,wEAAwE;IACxE,yFAAyF;IACzF,IAAI,CAAC;QACH,MAAM,cAAc,GAAI,MAAM,CAAC,IAAqD,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAChG,IAAI,cAAc;YAAE,OAAO,cAAc,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;IACD,IAAI,CAAC;QACH,MAAM,WAAW,GAAI,UAAyE;aAC3F,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,WAAW;YAAE,OAAO,WAAW,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AASD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,MAAM,CAAC,OAAsB,EAAE;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAK,UAAkC,CAAC,MAAM,CAAC;QACtE,IAAI,GAAG,EAAE,yBAAyB,EAAE,CAAC;YACnC,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/B,CAAC;QACD,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,IAAI,yBAAyB,EAAE,CAAC;QACtF,OAAO,IAAI,eAAe,CAAC,EAAE,oBAAoB,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type BlockInitPayload, type BlockToParentMessage, type ParentToBlockMessageType } from '@civitai/app-sdk/blocks';
|
|
2
|
+
import { type BlockSnapshot, type BlockTransport, type OutboundRequest } from './transport.js';
|
|
3
|
+
export interface IframeTransportOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Origins from which `BLOCK_INIT` (and any other inbound message) is
|
|
6
|
+
* accepted. MUST contain at least one entry. Messages from any other
|
|
7
|
+
* origin — including the local origin — are dropped silently.
|
|
8
|
+
*
|
|
9
|
+
* Typically wired from `import.meta.env.VITE_BLOCK_ALLOWED_PARENT_ORIGINS`
|
|
10
|
+
* (or the framework's equivalent) at block-app startup.
|
|
11
|
+
*/
|
|
12
|
+
allowedParentOrigins: string[];
|
|
13
|
+
/** Override for tests / SSR. Defaults to `globalThis.window`. */
|
|
14
|
+
window?: Window;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Iframe-mode transport. Validates `event.origin` on every inbound message,
|
|
18
|
+
* awaits `BLOCK_INIT` with a 10s timeout (after which `waitForInit` rejects
|
|
19
|
+
* — the host shows a fallback), queues outbound messages until init, and
|
|
20
|
+
* correlates request/response pairs by `requestId`.
|
|
21
|
+
*/
|
|
22
|
+
export declare class IframeTransport implements BlockTransport {
|
|
23
|
+
private readonly allowedOrigins;
|
|
24
|
+
private readonly window;
|
|
25
|
+
private snapshot;
|
|
26
|
+
private readonly listeners;
|
|
27
|
+
/** Origin of the parent — captured from the first valid `BLOCK_INIT`. */
|
|
28
|
+
private parentOrigin;
|
|
29
|
+
/** Messages queued before `BLOCK_INIT` lands. Flushed in arrival order. */
|
|
30
|
+
private readonly outbound;
|
|
31
|
+
private readonly pending;
|
|
32
|
+
private readonly initPromise;
|
|
33
|
+
private resolveInit;
|
|
34
|
+
private rejectInit;
|
|
35
|
+
private initTimeoutId;
|
|
36
|
+
private initResolved;
|
|
37
|
+
private readonly messageListener;
|
|
38
|
+
constructor(opts: IframeTransportOptions);
|
|
39
|
+
getSnapshot(): BlockSnapshot;
|
|
40
|
+
subscribe(listener: () => void): () => void;
|
|
41
|
+
waitForInit(): Promise<BlockInitPayload>;
|
|
42
|
+
sendMessage(message: BlockToParentMessage): void;
|
|
43
|
+
sendRequest(request: OutboundRequest, responseType: ParentToBlockMessageType, opts?: {
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
}): Promise<unknown>;
|
|
46
|
+
/** Test-only: tear down listeners + reject pending. */
|
|
47
|
+
dispose(): void;
|
|
48
|
+
private dispatch;
|
|
49
|
+
private flushOutbound;
|
|
50
|
+
private postToParent;
|
|
51
|
+
private handleMessage;
|
|
52
|
+
private applyTokenRefresh;
|
|
53
|
+
private emit;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=iframeTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframeTransport.d.ts","sourceRoot":"","sources":["../../src/internal/iframeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAEzB,KAAK,wBAAwB,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAQxB,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,cAAc;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsB;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IAEnD,yEAAyE;IACzE,OAAO,CAAC,YAAY,CAAuB;IAE3C,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAC1E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAE7D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgC;gBAEpD,IAAI,EAAE,sBAAsB;IAiCxC,WAAW,IAAI,aAAa;IAI5B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAO3C,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIxC,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAIhD,WAAW,CACT,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,wBAAwB,EACtC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAChC,OAAO,CAAC,OAAO,CAAC;IAmBnB,uDAAuD;IACvD,OAAO,IAAI,IAAI;IAWf,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,aAAa;IAkFrB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { isMessage, } from '@civitai/app-sdk/blocks';
|
|
2
|
+
import { EMPTY_SNAPSHOT, nextRequestId, snapshotFromInit, tokenFromWrapped, } from './transport.js';
|
|
3
|
+
import { payloadValidatorFor } from './validate.js';
|
|
4
|
+
const INIT_TIMEOUT_MS = 10_000;
|
|
5
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
6
|
+
/**
|
|
7
|
+
* Iframe-mode transport. Validates `event.origin` on every inbound message,
|
|
8
|
+
* awaits `BLOCK_INIT` with a 10s timeout (after which `waitForInit` rejects
|
|
9
|
+
* — the host shows a fallback), queues outbound messages until init, and
|
|
10
|
+
* correlates request/response pairs by `requestId`.
|
|
11
|
+
*/
|
|
12
|
+
export class IframeTransport {
|
|
13
|
+
allowedOrigins;
|
|
14
|
+
window;
|
|
15
|
+
snapshot = EMPTY_SNAPSHOT;
|
|
16
|
+
listeners = new Set();
|
|
17
|
+
/** Origin of the parent — captured from the first valid `BLOCK_INIT`. */
|
|
18
|
+
parentOrigin = null;
|
|
19
|
+
/** Messages queued before `BLOCK_INIT` lands. Flushed in arrival order. */
|
|
20
|
+
outbound = [];
|
|
21
|
+
pending = new Map();
|
|
22
|
+
initPromise;
|
|
23
|
+
resolveInit;
|
|
24
|
+
rejectInit;
|
|
25
|
+
initTimeoutId;
|
|
26
|
+
initResolved = false;
|
|
27
|
+
messageListener;
|
|
28
|
+
constructor(opts) {
|
|
29
|
+
if (!opts.allowedParentOrigins.length) {
|
|
30
|
+
throw new Error('IframeTransport: allowedParentOrigins must contain at least one entry. ' +
|
|
31
|
+
'Configure NEXT_PUBLIC_BLOCK_ALLOWED_PARENT_ORIGINS (or the framework equivalent).');
|
|
32
|
+
}
|
|
33
|
+
this.allowedOrigins = new Set(opts.allowedParentOrigins);
|
|
34
|
+
this.window = opts.window ?? globalThis.window;
|
|
35
|
+
if (!this.window) {
|
|
36
|
+
throw new Error('IframeTransport: no window available; cannot mount on the server.');
|
|
37
|
+
}
|
|
38
|
+
this.initPromise = new Promise((resolve, reject) => {
|
|
39
|
+
this.resolveInit = resolve;
|
|
40
|
+
this.rejectInit = reject;
|
|
41
|
+
});
|
|
42
|
+
this.initTimeoutId = setTimeout(() => {
|
|
43
|
+
if (!this.initResolved) {
|
|
44
|
+
this.initResolved = true;
|
|
45
|
+
this.rejectInit(new Error(`IframeTransport: timed out waiting for BLOCK_INIT after ${INIT_TIMEOUT_MS}ms. ` +
|
|
46
|
+
'Verify the host frame is sending the init message and that its origin is in allowedParentOrigins.'));
|
|
47
|
+
}
|
|
48
|
+
}, INIT_TIMEOUT_MS);
|
|
49
|
+
this.messageListener = (event) => this.handleMessage(event);
|
|
50
|
+
this.window.addEventListener('message', this.messageListener);
|
|
51
|
+
}
|
|
52
|
+
getSnapshot() {
|
|
53
|
+
return this.snapshot;
|
|
54
|
+
}
|
|
55
|
+
subscribe(listener) {
|
|
56
|
+
this.listeners.add(listener);
|
|
57
|
+
return () => {
|
|
58
|
+
this.listeners.delete(listener);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
waitForInit() {
|
|
62
|
+
return this.initPromise;
|
|
63
|
+
}
|
|
64
|
+
sendMessage(message) {
|
|
65
|
+
this.dispatch(message.type, message.payload);
|
|
66
|
+
}
|
|
67
|
+
sendRequest(request, responseType, opts = {}) {
|
|
68
|
+
const requestId = nextRequestId();
|
|
69
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const timeoutId = setTimeout(() => {
|
|
72
|
+
if (this.pending.delete(requestId)) {
|
|
73
|
+
reject(new Error(`IframeTransport: request "${request.type}" timed out after ${timeoutMs}ms`));
|
|
74
|
+
}
|
|
75
|
+
}, timeoutMs);
|
|
76
|
+
this.pending.set(requestId, {
|
|
77
|
+
resolve,
|
|
78
|
+
reject,
|
|
79
|
+
timeoutId,
|
|
80
|
+
responseType,
|
|
81
|
+
});
|
|
82
|
+
this.dispatch(request.type, { ...request.payload, requestId });
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** Test-only: tear down listeners + reject pending. */
|
|
86
|
+
dispose() {
|
|
87
|
+
this.window.removeEventListener('message', this.messageListener);
|
|
88
|
+
clearTimeout(this.initTimeoutId);
|
|
89
|
+
for (const pending of this.pending.values()) {
|
|
90
|
+
clearTimeout(pending.timeoutId);
|
|
91
|
+
pending.reject(new Error('IframeTransport disposed'));
|
|
92
|
+
}
|
|
93
|
+
this.pending.clear();
|
|
94
|
+
this.listeners.clear();
|
|
95
|
+
}
|
|
96
|
+
dispatch(type, payload) {
|
|
97
|
+
if (!this.parentOrigin) {
|
|
98
|
+
this.outbound.push({ type, payload });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.postToParent({ type, payload });
|
|
102
|
+
}
|
|
103
|
+
flushOutbound() {
|
|
104
|
+
while (this.outbound.length) {
|
|
105
|
+
const msg = this.outbound.shift();
|
|
106
|
+
this.postToParent(msg);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
postToParent(msg) {
|
|
110
|
+
// `parentOrigin` is captured from a validated BLOCK_INIT; safe to use as targetOrigin.
|
|
111
|
+
this.window.parent.postMessage(msg, this.parentOrigin);
|
|
112
|
+
}
|
|
113
|
+
handleMessage(event) {
|
|
114
|
+
if (!this.allowedOrigins.has(event.origin))
|
|
115
|
+
return;
|
|
116
|
+
const data = event.data;
|
|
117
|
+
if (data == null || typeof data !== 'object' || typeof data.type !== 'string')
|
|
118
|
+
return;
|
|
119
|
+
// Trust-boundary shape check. `isMessage` only narrows on `type`;
|
|
120
|
+
// anything that reaches state-mutating code below must pass the
|
|
121
|
+
// payload validator for its type. Failures drop with a console.warn
|
|
122
|
+
// rather than crash — see ./validate.ts.
|
|
123
|
+
const validator = payloadValidatorFor(data.type);
|
|
124
|
+
if (validator && !validator(data.payload)) {
|
|
125
|
+
// eslint-disable-next-line no-console -- developer-facing diagnostic at a trust boundary
|
|
126
|
+
console.warn(`IframeTransport: dropping malformed "${data.type}" message from ${event.origin}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (isMessage(data, 'BLOCK_INIT')) {
|
|
130
|
+
if (!this.initResolved) {
|
|
131
|
+
this.initResolved = true;
|
|
132
|
+
clearTimeout(this.initTimeoutId);
|
|
133
|
+
this.parentOrigin = event.origin;
|
|
134
|
+
this.snapshot = snapshotFromInit(data.payload);
|
|
135
|
+
this.emit();
|
|
136
|
+
this.flushOutbound();
|
|
137
|
+
// Auto-send BLOCK_READY so the platform's 10-second ready timeout
|
|
138
|
+
// doesn't trigger a fallback. We send height: 0 as a placeholder;
|
|
139
|
+
// useBlockResize takes over with real measurements as soon as the
|
|
140
|
+
// block's root element mounts. Queued because the iframe's React
|
|
141
|
+
// tree hasn't rendered yet at this point — the postMessage goes
|
|
142
|
+
// out on the next microtask via the standard dispatch path.
|
|
143
|
+
this.dispatch('BLOCK_READY', { height: 0 });
|
|
144
|
+
this.resolveInit(data.payload);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
// Host-pushed token rotation (no requestId). Always apply to the
|
|
149
|
+
// snapshot; never matches a pending request.
|
|
150
|
+
if (isMessage(data, 'TOKEN_REFRESH')) {
|
|
151
|
+
this.applyTokenRefresh(data.payload.token);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
// For request/response replies, look up the pending entry by `requestId`.
|
|
155
|
+
const payload = data.payload;
|
|
156
|
+
let pending;
|
|
157
|
+
let matchedRequestId = null;
|
|
158
|
+
if (payload && typeof payload.requestId === 'string') {
|
|
159
|
+
const candidate = this.pending.get(payload.requestId);
|
|
160
|
+
if (candidate && candidate.responseType === data.type) {
|
|
161
|
+
pending = candidate;
|
|
162
|
+
matchedRequestId = payload.requestId;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// TOKEN_REFRESH_RESPONSE updates the snapshot whether or not the
|
|
166
|
+
// requestId matched a pending entry — the platform's IframeHost.tsx
|
|
167
|
+
// can answer with an empty requestId on its own schedule. Apply
|
|
168
|
+
// BEFORE resolving so awaiting code (and the useBlockToken effect
|
|
169
|
+
// re-firing on token.expiresAt) sees the new value.
|
|
170
|
+
if (isMessage(data, 'TOKEN_REFRESH_RESPONSE')) {
|
|
171
|
+
this.applyTokenRefresh(data.payload.token);
|
|
172
|
+
}
|
|
173
|
+
if (pending && matchedRequestId !== null) {
|
|
174
|
+
clearTimeout(pending.timeoutId);
|
|
175
|
+
this.pending.delete(matchedRequestId);
|
|
176
|
+
pending.resolve(payload);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (isMessage(data, 'SUSPEND')) {
|
|
180
|
+
// Reserved for future lifecycle hooks; no-op in v1.
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (isMessage(data, 'RESUME')) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
applyTokenRefresh(wrapped) {
|
|
188
|
+
// Replace the whole token — scopes and buzzBudget can change at refresh
|
|
189
|
+
// time (e.g. a manifest update altered the buzz budget). Carrying the
|
|
190
|
+
// wrapped value end-to-end avoids the bug class where the snapshot's
|
|
191
|
+
// expiresAt updated but scopes stayed stale.
|
|
192
|
+
this.snapshot = { ...this.snapshot, token: tokenFromWrapped(wrapped) };
|
|
193
|
+
this.emit();
|
|
194
|
+
}
|
|
195
|
+
emit() {
|
|
196
|
+
for (const listener of this.listeners)
|
|
197
|
+
listener();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=iframeTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframeTransport.js","sourceRoot":"","sources":["../../src/internal/iframeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAKV,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAuB1C;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACT,cAAc,CAAsB;IACpC,MAAM,CAAS;IAExB,QAAQ,GAAkB,cAAc,CAAC;IAChC,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAEnD,yEAAyE;IACjE,YAAY,GAAkB,IAAI,CAAC;IAE3C,2EAA2E;IAC1D,QAAQ,GAA8C,EAAE,CAAC;IACzD,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE5C,WAAW,CAA4B;IAChD,WAAW,CAAuC;IAClD,UAAU,CAAwB;IAClC,aAAa,CAAgC;IAC7C,YAAY,GAAG,KAAK,CAAC;IAEZ,eAAe,CAAgC;IAEhE,YAAY,IAA4B;QACtC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,yEAAyE;gBACvE,mFAAmF,CACtF,CAAC;QACJ,CAAC;QACD,IAAI,C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IAEO,IAAI;QACV,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS;YAAE,QAAQ,EAAE,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BlockToParentMessage, ParentToBlockMessageType } from '@civitai/app-sdk/blocks';
|
|
2
|
+
import { type BlockSnapshot, type BlockTransport, type OutboundRequest } from './transport.js';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__CIVITAI_BLOCK_CONTEXT__?: import('@civitai/app-sdk/blocks').BlockInitPayload;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class InlineTransport implements BlockTransport {
|
|
9
|
+
private snapshot;
|
|
10
|
+
constructor();
|
|
11
|
+
getSnapshot(): BlockSnapshot;
|
|
12
|
+
subscribe(_listener: () => void): () => void;
|
|
13
|
+
sendMessage(_message: BlockToParentMessage): void;
|
|
14
|
+
sendRequest(_request: OutboundRequest, _responseType: ParentToBlockMessageType, _opts?: {
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
}): Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=inlineTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineTransport.d.ts","sourceRoot":"","sources":["../../src/internal/inlineTransport.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,yBAAyB,CAAC,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC;KAChF;CACF;AAED,qBAAa,eAAgB,YAAW,cAAc;IACpD,OAAO,CAAC,QAAQ,CAAgB;;IAOhC,WAAW,IAAI,aAAa;IAI5B,SAAS,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAI5C,WAAW,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;IAIjD,WAAW,CACT,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,wBAAwB,EACvC,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,OAAO,CAAC;CAGpB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// v2 stub. Reads bootstrap state from `window.__CIVITAI_BLOCK_CONTEXT__`;
|
|
2
|
+
// not wired to any real platform path in v1. Lives here so `BlockTransportDetector`
|
|
3
|
+
// can branch and so the public hook surface is identical between modes.
|
|
4
|
+
//
|
|
5
|
+
// Intentionally minimal: tests verify only that the detector picks this when
|
|
6
|
+
// bootstrap is present. The full implementation lands with v2 inline mode.
|
|
7
|
+
//
|
|
8
|
+
// TODO(v2 trust boundary): inline mode currently reads the bootstrap object
|
|
9
|
+
// directly from the host's window without origin or shape validation — the
|
|
10
|
+
// equivalent of `IframeTransport`'s `allowedParentOrigins` + `payloadValidatorFor`
|
|
11
|
+
// gates. v1 impact is bounded because `sendMessage` / `sendRequest` are no-ops
|
|
12
|
+
// here, but the v2 implementation must add an equivalent trust boundary
|
|
13
|
+
// (e.g. validate the bootstrap shape with `isValidBlockInitPayload` from
|
|
14
|
+
// `./validate.ts` before constructing the snapshot, and document any
|
|
15
|
+
// host-cooperation contract that takes the place of origin allowlisting).
|
|
16
|
+
import { EMPTY_SNAPSHOT, snapshotFromInit, } from './transport.js';
|
|
17
|
+
export class InlineTransport {
|
|
18
|
+
snapshot;
|
|
19
|
+
constructor() {
|
|
20
|
+
const bootstrap = globalThis.window?.__CIVITAI_BLOCK_CONTEXT__;
|
|
21
|
+
this.snapshot = bootstrap ? snapshotFromInit(bootstrap) : EMPTY_SNAPSHOT;
|
|
22
|
+
}
|
|
23
|
+
getSnapshot() {
|
|
24
|
+
return this.snapshot;
|
|
25
|
+
}
|
|
26
|
+
subscribe(_listener) {
|
|
27
|
+
return () => { };
|
|
28
|
+
}
|
|
29
|
+
sendMessage(_message) {
|
|
30
|
+
// v2 will invoke platform APIs directly; intentional no-op in v1.
|
|
31
|
+
}
|
|
32
|
+
sendRequest(_request, _responseType, _opts) {
|
|
33
|
+
return Promise.reject(new Error('InlineTransport.sendRequest is not implemented in v1'));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=inlineTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineTransport.js","sourceRoot":"","sources":["../../src/internal/inlineTransport.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,oFAAoF;AACpF,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,mFAAmF;AACnF,+EAA+E;AAC/E,wEAAwE;AACxE,yEAAyE;AACzE,qEAAqE;AACrE,0EAA0E;AAO1E,OAAO,EACL,cAAc,EACd,gBAAgB,GAIjB,MAAM,gBAAgB,CAAC;AAQxB,MAAM,OAAO,eAAe;IAClB,QAAQ,CAAgB;IAEhC;QACE,MAAM,SAAS,GAAI,UAAkC,CAAC,MAAM,EAAE,yBAAyB,CAAC;QACxF,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAC3E,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,SAAS,CAAC,SAAqB;QAC7B,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IAED,WAAW,CAAC,QAA8B;QACxC,kEAAkE;IACpE,CAAC;IAED,WAAW,CACT,QAAyB,EACzB,aAAuC,EACvC,KAA8B;QAE9B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;IAC3F,CAAC;CACF"}
|