@rozenite/controls-plugin 2.2.0 → 2.3.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/CHANGELOG.md +16 -0
- package/dist/devtools/assets/panel-EMOeI6i6.css +1 -0
- package/dist/devtools/assets/panel-mjW0t-tQ.js +18 -0
- package/dist/devtools/panel.html +2 -2
- package/dist/react-native/cjs/package.json +3 -0
- package/dist/react-native/cjs/react-native.js +14 -0
- package/dist/react-native/cjs/src/react-native/controlsRegistry.js +70 -0
- package/dist/react-native/cjs/src/react-native/useControlsAgentTools.js +175 -0
- package/dist/react-native/cjs/src/react-native/useRozeniteControlsPlugin.js +177 -0
- package/dist/react-native/cjs/src/shared/agent-tools.js +51 -0
- package/dist/react-native/cjs/src/shared/messaging.js +2 -0
- package/dist/react-native/cjs/src/shared/serialization.js +102 -0
- package/dist/react-native/cjs/src/shared/types.js +5 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/react-native.d.ts +2 -0
- package/dist/react-native/react-native.js +11 -0
- package/dist/react-native/src/react-native/controlsRegistry.d.ts +23 -0
- package/dist/react-native/src/react-native/controlsRegistry.js +66 -0
- package/dist/react-native/src/react-native/useControlsAgentTools.d.ts +2 -0
- package/dist/react-native/src/react-native/useControlsAgentTools.js +171 -0
- package/dist/react-native/src/react-native/useRozeniteControlsPlugin.d.ts +3 -0
- package/dist/react-native/src/react-native/useRozeniteControlsPlugin.js +173 -0
- package/dist/react-native/src/shared/agent-tools.d.ts +48 -0
- package/dist/react-native/src/shared/agent-tools.js +48 -0
- package/dist/react-native/src/shared/messaging.d.ts +35 -0
- package/dist/react-native/src/shared/messaging.js +1 -0
- package/dist/react-native/src/shared/serialization.d.ts +22 -0
- package/dist/react-native/src/shared/serialization.js +96 -0
- package/dist/react-native/src/shared/types.d.ts +69 -0
- package/dist/react-native/src/shared/types.js +1 -0
- package/dist/rozenite.json +1 -1
- package/dist/sdk/package.json +3 -0
- package/dist/sdk/sdk.d.ts +10 -0
- package/dist/sdk/sdk.js +8 -0
- package/dist/sdk/src/shared/agent-tools.d.ts +48 -0
- package/dist/sdk/src/shared/agent-tools.js +51 -0
- package/dist/sdk/src/shared/messaging.d.ts +35 -0
- package/dist/sdk/src/shared/messaging.js +2 -0
- package/dist/sdk/src/shared/types.d.ts +69 -0
- package/dist/sdk/src/shared/types.js +5 -0
- package/package.json +17 -18
- package/react-native.ts +8 -1
- package/rozenite.config.ts +1 -0
- package/src/__tests__/release-bundle.test.ts +32 -0
- package/dist/devtools/assets/panel-BGnH7fJp.js +0 -18
- package/dist/devtools/assets/panel-DFvY5duB.css +0 -1
- package/dist/react-native/chunks/useRozeniteControlsPlugin.require.cjs +0 -1
- package/dist/react-native/chunks/useRozeniteControlsPlugin.require.js +0 -466
- package/dist/react-native/index.cjs +0 -1
- package/dist/react-native/index.d.ts +0 -138
- package/dist/react-native/index.js +0 -8
- package/dist/sdk/index.cjs +0 -1
- package/dist/sdk/index.d.ts +0 -150
- package/dist/sdk/index.js +0 -55
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type ControlsTextItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
type: 'text';
|
|
4
|
+
title: string;
|
|
5
|
+
value: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ControlsValidationResult = {
|
|
9
|
+
valid: true;
|
|
10
|
+
} | {
|
|
11
|
+
valid: false;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export type ControlsMutableItemBase<TValue> = {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
value: TValue;
|
|
18
|
+
description?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
validate?: (nextValue: TValue) => ControlsValidationResult;
|
|
21
|
+
onUpdate: (nextValue: TValue) => void | Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
export type ControlsToggleItem = ControlsMutableItemBase<boolean> & {
|
|
24
|
+
type: 'toggle';
|
|
25
|
+
};
|
|
26
|
+
export type ControlsButtonItem = {
|
|
27
|
+
id: string;
|
|
28
|
+
type: 'button';
|
|
29
|
+
title: string;
|
|
30
|
+
actionLabel?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
onPress: () => void | Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
export type ControlsSelectOption = {
|
|
36
|
+
label: string;
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
export type ControlsSelectItem = ControlsMutableItemBase<string> & {
|
|
40
|
+
type: 'select';
|
|
41
|
+
options: ControlsSelectOption[];
|
|
42
|
+
};
|
|
43
|
+
export type ControlsInputItem = ControlsMutableItemBase<string> & {
|
|
44
|
+
type: 'input';
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
applyLabel?: string;
|
|
47
|
+
};
|
|
48
|
+
export type ControlsItem = ControlsTextItem | ControlsToggleItem | ControlsButtonItem | ControlsSelectItem | ControlsInputItem;
|
|
49
|
+
export type ControlsSection = {
|
|
50
|
+
id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
items: ControlsItem[];
|
|
54
|
+
};
|
|
55
|
+
export type ControlsTextItemSnapshot = Omit<ControlsTextItem, never>;
|
|
56
|
+
export type ControlsToggleItemSnapshot = Omit<ControlsToggleItem, 'validate' | 'onUpdate'>;
|
|
57
|
+
export type ControlsButtonItemSnapshot = Omit<ControlsButtonItem, 'onPress'>;
|
|
58
|
+
export type ControlsSelectItemSnapshot = Omit<ControlsSelectItem, 'validate' | 'onUpdate'>;
|
|
59
|
+
export type ControlsInputItemSnapshot = Omit<ControlsInputItem, 'validate' | 'onUpdate'>;
|
|
60
|
+
export type ControlsItemSnapshot = ControlsTextItemSnapshot | ControlsToggleItemSnapshot | ControlsButtonItemSnapshot | ControlsSelectItemSnapshot | ControlsInputItemSnapshot;
|
|
61
|
+
export type ControlsSectionSnapshot = Omit<ControlsSection, 'items'> & {
|
|
62
|
+
items: ControlsItemSnapshot[];
|
|
63
|
+
};
|
|
64
|
+
export type RozeniteControlsPluginOptions = {
|
|
65
|
+
sections: ControlsSection[];
|
|
66
|
+
};
|
|
67
|
+
export type RozeniteControlsPluginOptionsUpdater = (previousOptions: RozeniteControlsPluginOptions) => RozeniteControlsPluginOptions;
|
|
68
|
+
export type RozeniteControlsPluginOptionsInput = RozeniteControlsPluginOptions | RozeniteControlsPluginOptionsUpdater;
|
|
69
|
+
export declare const createSection: <TSection extends ControlsSection>(section: TSection) => TSection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const createSection = (section) => section;
|
package/dist/rozenite.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@rozenite/controls-plugin","version":"2.
|
|
1
|
+
{"name":"@rozenite/controls-plugin","version":"2.3.0","description":"A Rozenite plugin for exposing app-defined controls directly in React Native DevTools.","panels":[{"name":"Controls","source":"/devtools/panel.html"}],"integrations":["react-native","react-native-web","lynx","lynx-web"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CONTROLS_AGENT_PLUGIN_ID, controlsToolDefinitions } from './src/shared/agent-tools.js';
|
|
2
|
+
export { CONTROLS_AGENT_PLUGIN_ID, controlsToolDefinitions };
|
|
3
|
+
export declare const controlsTools: {
|
|
4
|
+
readonly listSections: import("@rozenite/agent-shared").AgentToolDescriptor<undefined, import("./src/shared/agent-tools.js").ControlsListSectionsResult>;
|
|
5
|
+
readonly getItem: import("@rozenite/agent-shared").AgentToolDescriptor<import("./src/shared/agent-tools.js").ControlsSectionItemArgs, import("./src/shared/agent-tools.js").ControlsGetItemResult>;
|
|
6
|
+
readonly setValue: import("@rozenite/agent-shared").AgentToolDescriptor<import("./src/shared/agent-tools.js").ControlsSetValueArgs, import("./src/shared/agent-tools.js").ControlsSetValueResult>;
|
|
7
|
+
readonly pressButton: import("@rozenite/agent-shared").AgentToolDescriptor<import("./src/shared/agent-tools.js").ControlsSectionItemArgs, import("./src/shared/agent-tools.js").ControlsPressButtonResult>;
|
|
8
|
+
};
|
|
9
|
+
export type { ControlsGetItemArgs, ControlsGetItemResult, ControlsListSectionItemSummary, ControlsListSectionSummary, ControlsListSectionsArgs, ControlsListSectionsResult, ControlsPressButtonArgs, ControlsPressButtonResult, ControlsSectionItemArgs, ControlsSetValueArgs, ControlsSetValueResult, } from './src/shared/agent-tools.js';
|
|
10
|
+
export type { ControlsButtonItemSnapshot, ControlsInputItemSnapshot, ControlsItemSnapshot, ControlsSectionSnapshot, ControlsSelectItemSnapshot, ControlsSelectOption, ControlsTextItemSnapshot, ControlsToggleItemSnapshot, } from './src/shared/types.js';
|
package/dist/sdk/sdk.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.controlsTools = exports.controlsToolDefinitions = exports.CONTROLS_AGENT_PLUGIN_ID = void 0;
|
|
4
|
+
const agent_shared_1 = require("@rozenite/agent-shared");
|
|
5
|
+
const agent_tools_js_1 = require("./src/shared/agent-tools.js");
|
|
6
|
+
Object.defineProperty(exports, "CONTROLS_AGENT_PLUGIN_ID", { enumerable: true, get: function () { return agent_tools_js_1.CONTROLS_AGENT_PLUGIN_ID; } });
|
|
7
|
+
Object.defineProperty(exports, "controlsToolDefinitions", { enumerable: true, get: function () { return agent_tools_js_1.controlsToolDefinitions; } });
|
|
8
|
+
exports.controlsTools = (0, agent_shared_1.defineAgentToolDescriptors)(agent_tools_js_1.CONTROLS_AGENT_PLUGIN_ID, agent_tools_js_1.controlsToolDefinitions);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type AgentToolContract } from '@rozenite/agent-shared';
|
|
2
|
+
import type { ControlsItem, ControlsItemSnapshot } from './types';
|
|
3
|
+
export declare const CONTROLS_AGENT_PLUGIN_ID = "@rozenite/controls-plugin";
|
|
4
|
+
export type ControlsSectionItemArgs = {
|
|
5
|
+
sectionId: string;
|
|
6
|
+
itemId: string;
|
|
7
|
+
};
|
|
8
|
+
export type ControlsListSectionsArgs = undefined;
|
|
9
|
+
export type ControlsListSectionItemSummary = {
|
|
10
|
+
id: string;
|
|
11
|
+
type: ControlsItem['type'];
|
|
12
|
+
title: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ControlsListSectionSummary = {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
items: ControlsListSectionItemSummary[];
|
|
20
|
+
};
|
|
21
|
+
export type ControlsListSectionsResult = {
|
|
22
|
+
sections: ControlsListSectionSummary[];
|
|
23
|
+
};
|
|
24
|
+
export type ControlsGetItemArgs = ControlsSectionItemArgs;
|
|
25
|
+
export type ControlsGetItemResult = {
|
|
26
|
+
sectionId: string;
|
|
27
|
+
item: ControlsItemSnapshot;
|
|
28
|
+
};
|
|
29
|
+
export type ControlsSetValueArgs = ControlsSectionItemArgs & {
|
|
30
|
+
value: boolean | string;
|
|
31
|
+
};
|
|
32
|
+
export type ControlsSetValueResult = {
|
|
33
|
+
applied: true;
|
|
34
|
+
sectionId: string;
|
|
35
|
+
itemId: string;
|
|
36
|
+
};
|
|
37
|
+
export type ControlsPressButtonArgs = ControlsSectionItemArgs;
|
|
38
|
+
export type ControlsPressButtonResult = {
|
|
39
|
+
pressed: true;
|
|
40
|
+
sectionId: string;
|
|
41
|
+
itemId: string;
|
|
42
|
+
};
|
|
43
|
+
export declare const controlsToolDefinitions: {
|
|
44
|
+
readonly listSections: AgentToolContract<undefined, ControlsListSectionsResult>;
|
|
45
|
+
readonly getItem: AgentToolContract<ControlsSectionItemArgs, ControlsGetItemResult>;
|
|
46
|
+
readonly setValue: AgentToolContract<ControlsSetValueArgs, ControlsSetValueResult>;
|
|
47
|
+
readonly pressButton: AgentToolContract<ControlsSectionItemArgs, ControlsPressButtonResult>;
|
|
48
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.controlsToolDefinitions = exports.CONTROLS_AGENT_PLUGIN_ID = void 0;
|
|
4
|
+
const agent_shared_1 = require("@rozenite/agent-shared");
|
|
5
|
+
exports.CONTROLS_AGENT_PLUGIN_ID = '@rozenite/controls-plugin';
|
|
6
|
+
exports.controlsToolDefinitions = {
|
|
7
|
+
listSections: (0, agent_shared_1.defineAgentToolContract)({
|
|
8
|
+
name: 'list-sections',
|
|
9
|
+
description: 'List all controls sections with their item IDs, types, and titles. Does not include values — call get-item for that.',
|
|
10
|
+
inputSchema: { type: 'object', properties: {} },
|
|
11
|
+
}),
|
|
12
|
+
getItem: (0, agent_shared_1.defineAgentToolContract)({
|
|
13
|
+
name: 'get-item',
|
|
14
|
+
description: 'Get full details of a single controls item including its current value. For select items this includes available options.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
sectionId: { type: 'string', description: 'Section ID.' },
|
|
19
|
+
itemId: { type: 'string', description: 'Item ID.' },
|
|
20
|
+
},
|
|
21
|
+
required: ['sectionId', 'itemId'],
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
setValue: (0, agent_shared_1.defineAgentToolContract)({
|
|
25
|
+
name: 'set-value',
|
|
26
|
+
description: 'Update the value of a toggle, select, or input item. Runs the validate callback when present. Fails for text (read-only) and button items.',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
sectionId: { type: 'string', description: 'Section ID.' },
|
|
31
|
+
itemId: { type: 'string', description: 'Item ID.' },
|
|
32
|
+
value: {
|
|
33
|
+
description: 'New value. Boolean for toggle items, string for select/input items.',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
required: ['sectionId', 'itemId', 'value'],
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
pressButton: (0, agent_shared_1.defineAgentToolContract)({
|
|
40
|
+
name: 'press-button',
|
|
41
|
+
description: "Trigger a button item's action. Fails if the item is not a button or is disabled.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
sectionId: { type: 'string', description: 'Section ID.' },
|
|
46
|
+
itemId: { type: 'string', description: 'Item ID.' },
|
|
47
|
+
},
|
|
48
|
+
required: ['sectionId', 'itemId'],
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ControlsSectionSnapshot } from './types';
|
|
2
|
+
export type ControlsSnapshotEvent = {
|
|
3
|
+
type: 'snapshot';
|
|
4
|
+
sections: ControlsSectionSnapshot[];
|
|
5
|
+
};
|
|
6
|
+
export type ControlsGetSnapshotEvent = {
|
|
7
|
+
type: 'get-snapshot';
|
|
8
|
+
};
|
|
9
|
+
export type ControlsUpdateRequestEvent = {
|
|
10
|
+
type: 'update-request';
|
|
11
|
+
requestId: string;
|
|
12
|
+
sectionId: string;
|
|
13
|
+
itemId: string;
|
|
14
|
+
value: boolean | string;
|
|
15
|
+
};
|
|
16
|
+
export type ControlsUpdateResultEvent = {
|
|
17
|
+
type: 'update-result';
|
|
18
|
+
requestId: string;
|
|
19
|
+
sectionId: string;
|
|
20
|
+
itemId: string;
|
|
21
|
+
status: 'ok' | 'error';
|
|
22
|
+
message?: string;
|
|
23
|
+
};
|
|
24
|
+
export type ControlsInvokeActionEvent = {
|
|
25
|
+
type: 'invoke-action';
|
|
26
|
+
sectionId: string;
|
|
27
|
+
itemId: string;
|
|
28
|
+
action: 'press';
|
|
29
|
+
};
|
|
30
|
+
export type ControlsEvent = ControlsSnapshotEvent | ControlsGetSnapshotEvent | ControlsUpdateRequestEvent | ControlsUpdateResultEvent | ControlsInvokeActionEvent;
|
|
31
|
+
export type ControlsEventMap = {
|
|
32
|
+
[K in ControlsEvent['type']]: Extract<ControlsEvent, {
|
|
33
|
+
type: K;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type ControlsTextItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
type: 'text';
|
|
4
|
+
title: string;
|
|
5
|
+
value: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ControlsValidationResult = {
|
|
9
|
+
valid: true;
|
|
10
|
+
} | {
|
|
11
|
+
valid: false;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export type ControlsMutableItemBase<TValue> = {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
value: TValue;
|
|
18
|
+
description?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
validate?: (nextValue: TValue) => ControlsValidationResult;
|
|
21
|
+
onUpdate: (nextValue: TValue) => void | Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
export type ControlsToggleItem = ControlsMutableItemBase<boolean> & {
|
|
24
|
+
type: 'toggle';
|
|
25
|
+
};
|
|
26
|
+
export type ControlsButtonItem = {
|
|
27
|
+
id: string;
|
|
28
|
+
type: 'button';
|
|
29
|
+
title: string;
|
|
30
|
+
actionLabel?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
onPress: () => void | Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
export type ControlsSelectOption = {
|
|
36
|
+
label: string;
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
export type ControlsSelectItem = ControlsMutableItemBase<string> & {
|
|
40
|
+
type: 'select';
|
|
41
|
+
options: ControlsSelectOption[];
|
|
42
|
+
};
|
|
43
|
+
export type ControlsInputItem = ControlsMutableItemBase<string> & {
|
|
44
|
+
type: 'input';
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
applyLabel?: string;
|
|
47
|
+
};
|
|
48
|
+
export type ControlsItem = ControlsTextItem | ControlsToggleItem | ControlsButtonItem | ControlsSelectItem | ControlsInputItem;
|
|
49
|
+
export type ControlsSection = {
|
|
50
|
+
id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
items: ControlsItem[];
|
|
54
|
+
};
|
|
55
|
+
export type ControlsTextItemSnapshot = Omit<ControlsTextItem, never>;
|
|
56
|
+
export type ControlsToggleItemSnapshot = Omit<ControlsToggleItem, 'validate' | 'onUpdate'>;
|
|
57
|
+
export type ControlsButtonItemSnapshot = Omit<ControlsButtonItem, 'onPress'>;
|
|
58
|
+
export type ControlsSelectItemSnapshot = Omit<ControlsSelectItem, 'validate' | 'onUpdate'>;
|
|
59
|
+
export type ControlsInputItemSnapshot = Omit<ControlsInputItem, 'validate' | 'onUpdate'>;
|
|
60
|
+
export type ControlsItemSnapshot = ControlsTextItemSnapshot | ControlsToggleItemSnapshot | ControlsButtonItemSnapshot | ControlsSelectItemSnapshot | ControlsInputItemSnapshot;
|
|
61
|
+
export type ControlsSectionSnapshot = Omit<ControlsSection, 'items'> & {
|
|
62
|
+
items: ControlsItemSnapshot[];
|
|
63
|
+
};
|
|
64
|
+
export type RozeniteControlsPluginOptions = {
|
|
65
|
+
sections: ControlsSection[];
|
|
66
|
+
};
|
|
67
|
+
export type RozeniteControlsPluginOptionsUpdater = (previousOptions: RozeniteControlsPluginOptions) => RozeniteControlsPluginOptions;
|
|
68
|
+
export type RozeniteControlsPluginOptionsInput = RozeniteControlsPluginOptions | RozeniteControlsPluginOptionsUpdater;
|
|
69
|
+
export declare const createSection: <TSection extends ControlsSection>(section: TSection) => TSection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rozenite/controls-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A Rozenite plugin for exposing app-defined controls directly in React Native DevTools.",
|
|
5
5
|
"homepage": "https://github.com/callstackincubator/rozenite#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -12,31 +12,30 @@
|
|
|
12
12
|
"url": "https://github.com/callstackincubator/rozenite.git"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
|
-
"main": "./dist/react-native/
|
|
16
|
-
"module": "./dist/react-native/
|
|
17
|
-
"types": "./dist/react-native/
|
|
15
|
+
"main": "./dist/react-native/cjs/react-native.js",
|
|
16
|
+
"module": "./dist/react-native/react-native.js",
|
|
17
|
+
"types": "./dist/react-native/react-native.d.ts",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"types": "./dist/react-native/
|
|
21
|
-
"import": "./dist/react-native/
|
|
22
|
-
"require": "./dist/react-native/
|
|
20
|
+
"types": "./dist/react-native/react-native.d.ts",
|
|
21
|
+
"import": "./dist/react-native/react-native.js",
|
|
22
|
+
"require": "./dist/react-native/cjs/react-native.js"
|
|
23
23
|
},
|
|
24
24
|
"./package.json": "./package.json",
|
|
25
25
|
"./sdk": {
|
|
26
26
|
"development": "./sdk.ts",
|
|
27
|
-
"types": "./dist/sdk/
|
|
28
|
-
"
|
|
29
|
-
"require": "./dist/sdk/index.cjs"
|
|
27
|
+
"types": "./dist/sdk/sdk.d.ts",
|
|
28
|
+
"default": "./dist/sdk/sdk.js"
|
|
30
29
|
}
|
|
31
30
|
},
|
|
32
31
|
"publishConfig": {
|
|
33
32
|
"access": "public"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
|
-
"@rozenite/agent-
|
|
37
|
-
"@rozenite/
|
|
38
|
-
"@rozenite/
|
|
39
|
-
"@rozenite/
|
|
35
|
+
"@rozenite/agent-bridge": "2.3.0",
|
|
36
|
+
"@rozenite/agent-shared": "2.3.0",
|
|
37
|
+
"@rozenite/plugin-bridge": "2.3.0",
|
|
38
|
+
"@rozenite/ui": "2.3.0"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@types/react": "~19.2.3",
|
|
@@ -47,12 +46,12 @@
|
|
|
47
46
|
"react-native-web": "^0.21.2",
|
|
48
47
|
"typescript": "~5.9.3",
|
|
49
48
|
"vite": "^7.3.1",
|
|
50
|
-
"@rozenite/
|
|
51
|
-
"rozenite": "2.
|
|
49
|
+
"@rozenite/test-utils": "2.3.0",
|
|
50
|
+
"@rozenite/vite-plugin": "2.3.0",
|
|
51
|
+
"rozenite": "2.3.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"react": "*"
|
|
55
|
-
"react-native": "*"
|
|
54
|
+
"react": "*"
|
|
56
55
|
},
|
|
57
56
|
"scripts": {
|
|
58
57
|
"build": "rozenite build",
|
package/react-native.ts
CHANGED
|
@@ -16,8 +16,15 @@ export {
|
|
|
16
16
|
|
|
17
17
|
export let useRozeniteControlsPlugin: typeof import('./src/react-native/useRozeniteControlsPlugin').useRozeniteControlsPlugin;
|
|
18
18
|
|
|
19
|
+
// Neither Lynx runtime has a `window`, so `typeof window` alone reported
|
|
20
|
+
// every Lynx app as a server and installed the no-op stub below. `lynx` is
|
|
21
|
+
// a free binding in module scope, not a property of `globalThis`. Kept
|
|
22
|
+
// inline rather than imported so this stays a foldable expression and the
|
|
23
|
+
// `require`s below can still be dropped from production bundles.
|
|
24
|
+
declare const lynx: unknown;
|
|
25
|
+
|
|
19
26
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
20
|
-
const isServer = typeof window === 'undefined';
|
|
27
|
+
const isServer = typeof window === 'undefined' && typeof lynx === 'undefined';
|
|
21
28
|
|
|
22
29
|
if (isDev && !isServer) {
|
|
23
30
|
useRozeniteControlsPlugin =
|
package/rozenite.config.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { bundleForRelease, RELEASE_BUNDLE_TIMEOUT } from '@rozenite/test-utils';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
|
|
6
|
+
// An app importing this plugin ships its React Native code -- that much is
|
|
7
|
+
// the app's own choice. What must never follow it into the bundle is the
|
|
8
|
+
// panel: the DevTools UI, its React DOM tree and `@rozenite/ui`.
|
|
9
|
+
// See docs/agents/release-bundle-testing.md.
|
|
10
|
+
const packageRoot = path.resolve(fileURLToPath(import.meta.url), '../../..');
|
|
11
|
+
const reactNativeEntry = path.join(packageRoot, 'dist/react-native/cjs/react-native.js');
|
|
12
|
+
|
|
13
|
+
describe('@rozenite/controls-plugin in a release bundle', () => {
|
|
14
|
+
it(
|
|
15
|
+
'ships no panel code when an app imports it',
|
|
16
|
+
async () => {
|
|
17
|
+
const result = await bundleForRelease({
|
|
18
|
+
resolveFrom: packageRoot,
|
|
19
|
+
files: {
|
|
20
|
+
'index.js': `require(${JSON.stringify(reactNativeEntry)});\n`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Keeps the check below honest: the entry really did get bundled.
|
|
25
|
+
expect(result.rozeniteModules).toContain(
|
|
26
|
+
'packages/controls-plugin/dist/react-native/cjs/react-native.js',
|
|
27
|
+
);
|
|
28
|
+
expect(result.panelModules).toEqual([]);
|
|
29
|
+
},
|
|
30
|
+
RELEASE_BUNDLE_TIMEOUT,
|
|
31
|
+
);
|
|
32
|
+
});
|