@fugood/bricks-ctor 2.25.0-beta.4 → 2.25.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compile/__tests__/index.test.js +152 -0
- package/compile/__tests__/util.test.js +278 -0
- package/compile/action-name-map.ts +64 -0
- package/compile/index.ts +208 -19
- package/package.json +3 -3
- package/skills/bricks-ctor/SKILL.md +21 -17
- package/skills/bricks-ctor/{rules → references}/animation.md +3 -2
- package/skills/bricks-ctor/{rules → references}/architecture-patterns.md +12 -0
- package/skills/bricks-ctor/{rules → references}/automations.md +11 -0
- package/skills/bricks-ctor/references/buttress.md +245 -0
- package/skills/bricks-ctor/references/data-calculation.md +239 -0
- package/skills/bricks-ctor/references/simulator.md +131 -0
- package/skills/bricks-ctor/references/verification-toolchain.md +179 -0
- package/skills/bricks-design/SKILL.md +160 -45
- package/skills/bricks-design/references/architecture-truths.md +132 -0
- package/skills/bricks-design/references/avoiding-complexity.md +91 -0
- package/skills/bricks-design/references/design-critique.md +195 -0
- package/skills/bricks-design/references/design-languages.md +265 -0
- package/skills/bricks-design/references/performance.md +116 -0
- package/skills/bricks-design/references/presentation-and-slideshow.md +137 -0
- package/skills/bricks-design/references/translating-inputs.md +152 -0
- package/skills/bricks-design/references/variations-and-tweaks.md +124 -0
- package/skills/bricks-design/references/when-the-brief-is-branded.md +284 -0
- package/skills/bricks-design/references/when-the-brief-is-vague.md +85 -0
- package/skills/bricks-design/references/workflow.md +134 -0
- package/skills/bricks-ux/SKILL.md +120 -0
- package/skills/bricks-ux/references/accessibility.md +162 -0
- package/skills/bricks-ux/references/flow-states.md +175 -0
- package/skills/bricks-ux/references/interaction-archetypes.md +189 -0
- package/skills/bricks-ux/references/monitoring-screens.md +153 -0
- package/skills/bricks-ux/references/pressable-composition.md +126 -0
- package/skills/bricks-ux/references/user-journey.md +168 -0
- package/skills/bricks-ux/references/ux-critique.md +256 -0
- package/tools/_git-author.ts +10 -2
- package/tools/_last-pushed-commit.ts +28 -0
- package/tools/_shell.ts +8 -1
- package/tools/deploy.ts +15 -0
- package/tools/mcp-tools/compile.ts +19 -9
- package/tools/mcp-tools/media.ts +4 -1
- package/tools/pull.ts +91 -16
- package/tools/push-config.ts +118 -0
- package/tools/{preview-main.mjs → simulator-main.mjs} +207 -12
- package/tools/simulator-preload.cjs +16 -0
- package/tools/{preview.ts → simulator.ts} +4 -4
- package/types/{animation.ts → animation.d.ts} +24 -8
- package/types/{automation.ts → automation.d.ts} +16 -20
- package/types/{brick-base.ts → brick-base.d.ts} +1 -1
- package/types/bricks/{Camera.ts → Camera.d.ts} +8 -8
- package/types/bricks/{Chart.ts → Chart.d.ts} +4 -4
- package/types/bricks/{GenerativeMedia.ts → GenerativeMedia.d.ts} +15 -15
- package/types/bricks/{Icon.ts → Icon.d.ts} +7 -7
- package/types/bricks/{Image.ts → Image.d.ts} +21 -9
- package/types/bricks/{Items.ts → Items.d.ts} +7 -7
- package/types/bricks/{Lottie.ts → Lottie.d.ts} +10 -10
- package/types/bricks/{Maps.ts → Maps.d.ts} +11 -11
- package/types/bricks/{QrCode.ts → QrCode.d.ts} +7 -7
- package/types/bricks/{Rect.ts → Rect.d.ts} +7 -7
- package/types/bricks/{RichText.ts → RichText.d.ts} +12 -9
- package/types/bricks/{Rive.ts → Rive.d.ts} +9 -9
- package/types/bricks/Scene3D.d.ts +676 -0
- package/types/bricks/{Sketch.ts → Sketch.d.ts} +6 -6
- package/types/bricks/{Slideshow.ts → Slideshow.d.ts} +7 -7
- package/types/bricks/{Svg.ts → Svg.d.ts} +7 -7
- package/types/bricks/{Text.ts → Text.d.ts} +9 -9
- package/types/bricks/{TextInput.ts → TextInput.d.ts} +10 -10
- package/types/bricks/{Video.ts → Video.d.ts} +12 -12
- package/types/bricks/{VideoStreaming.ts → VideoStreaming.d.ts} +10 -10
- package/types/bricks/{WebRtcStream.ts → WebRtcStream.d.ts} +1 -1
- package/types/bricks/{WebView.ts → WebView.d.ts} +4 -4
- package/types/bricks/{index.ts → index.d.ts} +1 -0
- package/types/{common.ts → common.d.ts} +3 -6
- package/types/data-calc-command/base.d.ts +57 -0
- package/types/data-calc-command/collection.d.ts +418 -0
- package/types/data-calc-command/color.d.ts +432 -0
- package/types/data-calc-command/constant.d.ts +50 -0
- package/types/data-calc-command/datetime.d.ts +147 -0
- package/types/data-calc-command/file.d.ts +129 -0
- package/types/data-calc-command/index.d.ts +13 -0
- package/types/data-calc-command/iteratee.d.ts +23 -0
- package/types/data-calc-command/logictype.d.ts +190 -0
- package/types/data-calc-command/math.d.ts +275 -0
- package/types/data-calc-command/object.d.ts +119 -0
- package/types/data-calc-command/sandbox.d.ts +66 -0
- package/types/data-calc-command/string.d.ts +407 -0
- package/types/{data-calc.ts → data-calc.d.ts} +1 -0
- package/types/{data.ts → data.d.ts} +4 -2
- package/types/generators/{Assistant.ts → Assistant.d.ts} +19 -0
- package/types/generators/{LlmGgml.ts → LlmGgml.d.ts} +43 -1
- package/types/generators/{LlmMlx.ts → LlmMlx.d.ts} +1 -0
- package/types/generators/{RerankerGgml.ts → RerankerGgml.d.ts} +5 -1
- package/types/generators/{SoundRecorder.ts → SoundRecorder.d.ts} +10 -1
- package/types/generators/{SpeechToTextGgml.ts → SpeechToTextGgml.d.ts} +6 -1
- package/types/generators/{SttAppleBuiltin.ts → SttAppleBuiltin.d.ts} +27 -4
- package/types/generators/{ThermalPrinter.ts → ThermalPrinter.d.ts} +9 -7
- package/types/generators/{VadGgml.ts → VadGgml.d.ts} +12 -2
- package/types/{subspace.ts → subspace.d.ts} +1 -1
- package/utils/__tests__/id.test.js +154 -0
- package/utils/data.ts +2 -2
- package/utils/event-props.ts +17 -0
- package/utils/id.ts +78 -27
- package/skills/bricks-ctor/rules/buttress.md +0 -156
- package/skills/bricks-ctor/rules/data-calculation.md +0 -209
- package/skills/bricks-design/LICENSE.txt +0 -180
- package/types/data-calc-command.ts +0 -7005
- /package/skills/bricks-ctor/{rules → references}/local-sync.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/media-flow.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/remote-data-bank.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/standby-transition.md +0 -0
- /package/types/{canvas.ts → canvas.d.ts} +0 -0
- /package/types/{data-calc-script.ts → data-calc-script.d.ts} +0 -0
- /package/types/generators/{AlarmClock.ts → AlarmClock.d.ts} +0 -0
- /package/types/generators/{BleCentral.ts → BleCentral.d.ts} +0 -0
- /package/types/generators/{BlePeripheral.ts → BlePeripheral.d.ts} +0 -0
- /package/types/generators/{CanvasMap.ts → CanvasMap.d.ts} +0 -0
- /package/types/generators/{CastlesPay.ts → CastlesPay.d.ts} +0 -0
- /package/types/generators/{DataBank.ts → DataBank.d.ts} +0 -0
- /package/types/generators/{File.ts → File.d.ts} +0 -0
- /package/types/generators/{GraphQl.ts → GraphQl.d.ts} +0 -0
- /package/types/generators/{Http.ts → Http.d.ts} +0 -0
- /package/types/generators/{HttpServer.ts → HttpServer.d.ts} +0 -0
- /package/types/generators/{Information.ts → Information.d.ts} +0 -0
- /package/types/generators/{Intent.ts → Intent.d.ts} +0 -0
- /package/types/generators/{Iterator.ts → Iterator.d.ts} +0 -0
- /package/types/generators/{Keyboard.ts → Keyboard.d.ts} +0 -0
- /package/types/generators/{LlmAnthropicCompat.ts → LlmAnthropicCompat.d.ts} +0 -0
- /package/types/generators/{LlmAppleBuiltin.ts → LlmAppleBuiltin.d.ts} +0 -0
- /package/types/generators/{LlmMediaTekNeuroPilot.ts → LlmMediaTekNeuroPilot.d.ts} +0 -0
- /package/types/generators/{LlmOnnx.ts → LlmOnnx.d.ts} +0 -0
- /package/types/generators/{LlmOpenAiCompat.ts → LlmOpenAiCompat.d.ts} +0 -0
- /package/types/generators/{LlmQualcommAiEngine.ts → LlmQualcommAiEngine.d.ts} +0 -0
- /package/types/generators/{Mcp.ts → Mcp.d.ts} +0 -0
- /package/types/generators/{McpServer.ts → McpServer.d.ts} +0 -0
- /package/types/generators/{MediaFlow.ts → MediaFlow.d.ts} +0 -0
- /package/types/generators/{MqttBroker.ts → MqttBroker.d.ts} +0 -0
- /package/types/generators/{MqttClient.ts → MqttClient.d.ts} +0 -0
- /package/types/generators/{Question.ts → Question.d.ts} +0 -0
- /package/types/generators/{RealtimeTranscription.ts → RealtimeTranscription.d.ts} +0 -0
- /package/types/generators/{SerialPort.ts → SerialPort.d.ts} +0 -0
- /package/types/generators/{SoundPlayer.ts → SoundPlayer.d.ts} +0 -0
- /package/types/generators/{SpeechToTextOnnx.ts → SpeechToTextOnnx.d.ts} +0 -0
- /package/types/generators/{SpeechToTextPlatform.ts → SpeechToTextPlatform.d.ts} +0 -0
- /package/types/generators/{SqLite.ts → SqLite.d.ts} +0 -0
- /package/types/generators/{Step.ts → Step.d.ts} +0 -0
- /package/types/generators/{Tcp.ts → Tcp.d.ts} +0 -0
- /package/types/generators/{TcpServer.ts → TcpServer.d.ts} +0 -0
- /package/types/generators/{TextToSpeechAppleBuiltin.ts → TextToSpeechAppleBuiltin.d.ts} +0 -0
- /package/types/generators/{TextToSpeechGgml.ts → TextToSpeechGgml.d.ts} +0 -0
- /package/types/generators/{TextToSpeechOnnx.ts → TextToSpeechOnnx.d.ts} +0 -0
- /package/types/generators/{TextToSpeechOpenAiLike.ts → TextToSpeechOpenAiLike.d.ts} +0 -0
- /package/types/generators/{Tick.ts → Tick.d.ts} +0 -0
- /package/types/generators/{Udp.ts → Udp.d.ts} +0 -0
- /package/types/generators/{VadOnnx.ts → VadOnnx.d.ts} +0 -0
- /package/types/generators/{VadTraditional.ts → VadTraditional.d.ts} +0 -0
- /package/types/generators/{VectorStore.ts → VectorStore.d.ts} +0 -0
- /package/types/generators/{Watchdog.ts → Watchdog.d.ts} +0 -0
- /package/types/generators/{WebCrawler.ts → WebCrawler.d.ts} +0 -0
- /package/types/generators/{WebRtc.ts → WebRtc.d.ts} +0 -0
- /package/types/generators/{WebSocket.ts → WebSocket.d.ts} +0 -0
- /package/types/generators/{index.ts → index.d.ts} +0 -0
- /package/types/{index.ts → index.d.ts} +0 -0
- /package/types/{switch.ts → switch.d.ts} +0 -0
- /package/types/{system.ts → system.d.ts} +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { compile } from '../index'
|
|
2
|
+
|
|
3
|
+
const SUBSPACE_ID = 'SUBSPACE_00000000-0000-0000-0000-000000000001'
|
|
4
|
+
const CANVAS_ID = 'CANVAS_00000000-0000-0000-0000-000000000001'
|
|
5
|
+
const ANIMATION_ID = 'ANIMATION_00000000-0000-0000-0000-000000000001'
|
|
6
|
+
const DATA_ID = 'PROPERTY_BANK_DATA_NODE_00000000-0000-0000-0000-000000000001'
|
|
7
|
+
|
|
8
|
+
const makeApp = (animations = [], data = []) => {
|
|
9
|
+
const rootCanvas = {
|
|
10
|
+
__typename: 'Canvas',
|
|
11
|
+
id: CANVAS_ID,
|
|
12
|
+
items: [],
|
|
13
|
+
}
|
|
14
|
+
const rootSubspace = {
|
|
15
|
+
__typename: 'Subspace',
|
|
16
|
+
id: SUBSPACE_ID,
|
|
17
|
+
title: 'Main Subspace',
|
|
18
|
+
layout: {
|
|
19
|
+
width: 96,
|
|
20
|
+
height: 54,
|
|
21
|
+
},
|
|
22
|
+
rootCanvas,
|
|
23
|
+
canvases: [rootCanvas],
|
|
24
|
+
animations,
|
|
25
|
+
bricks: [],
|
|
26
|
+
generators: [],
|
|
27
|
+
data,
|
|
28
|
+
dataRouting: [],
|
|
29
|
+
dataCalculation: [],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
name: 'Compile animation test',
|
|
34
|
+
rootSubspace,
|
|
35
|
+
subspaces: [rootSubspace],
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const makeData = (remoteUpdate) => ({
|
|
40
|
+
__typename: 'Data',
|
|
41
|
+
id: DATA_ID,
|
|
42
|
+
type: 'string',
|
|
43
|
+
remoteUpdate,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
describe('compile animations', () => {
|
|
47
|
+
test('normalizes mixed legacy spring config', async () => {
|
|
48
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
49
|
+
try {
|
|
50
|
+
const config = await compile(
|
|
51
|
+
makeApp([
|
|
52
|
+
{
|
|
53
|
+
__typename: 'Animation',
|
|
54
|
+
id: ANIMATION_ID,
|
|
55
|
+
alias: 'btnPressOut',
|
|
56
|
+
title: 'Button Press Out',
|
|
57
|
+
property: 'transform.scale',
|
|
58
|
+
config: {
|
|
59
|
+
__type: 'AnimationSpringConfig',
|
|
60
|
+
toValue: 1,
|
|
61
|
+
friction: 5,
|
|
62
|
+
tension: 200,
|
|
63
|
+
speed: 14,
|
|
64
|
+
bounciness: 8,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
]),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
expect(config.subspace_map[SUBSPACE_ID].animation_map[ANIMATION_ID].config).toEqual({
|
|
71
|
+
toValue: 1,
|
|
72
|
+
friction: 5,
|
|
73
|
+
tension: 200,
|
|
74
|
+
})
|
|
75
|
+
const warning = warnSpy.mock.calls[0][0]
|
|
76
|
+
expect(warning).toContain('Resolved animation spring config')
|
|
77
|
+
expect(warning).toContain('Button Press Out')
|
|
78
|
+
expect(warning).toContain('btnPressOut')
|
|
79
|
+
expect(warning).toContain('transform.scale')
|
|
80
|
+
expect(warning).toContain('Main Subspace')
|
|
81
|
+
expect(warning).not.toContain('ANIMATION_')
|
|
82
|
+
expect(warning).not.toContain('SUBSPACE_')
|
|
83
|
+
} finally {
|
|
84
|
+
warnSpy.mockRestore()
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test('rejects invalid animation property', async () => {
|
|
89
|
+
await expect(
|
|
90
|
+
compile(
|
|
91
|
+
makeApp([
|
|
92
|
+
{
|
|
93
|
+
__typename: 'Animation',
|
|
94
|
+
id: ANIMATION_ID,
|
|
95
|
+
property: 'transform.skewX',
|
|
96
|
+
config: {
|
|
97
|
+
__type: 'AnimationTimingConfig',
|
|
98
|
+
toValue: 1,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
]),
|
|
102
|
+
),
|
|
103
|
+
).rejects.toThrow(/Invalid animation property/)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('rejects invalid animation config type', async () => {
|
|
107
|
+
await expect(
|
|
108
|
+
compile(
|
|
109
|
+
makeApp([
|
|
110
|
+
{
|
|
111
|
+
__typename: 'Animation',
|
|
112
|
+
id: ANIMATION_ID,
|
|
113
|
+
property: 'opacity',
|
|
114
|
+
config: {
|
|
115
|
+
__type: 'AnimationUnknownConfig',
|
|
116
|
+
toValue: 1,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
]),
|
|
120
|
+
),
|
|
121
|
+
).rejects.toThrow(/Invalid animation config type/)
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
describe('compile data remote update', () => {
|
|
126
|
+
test.each([
|
|
127
|
+
[undefined, { bank_type: 'none' }],
|
|
128
|
+
[{ type: 'auto' }, { bank_type: 'create', enable_remote_update: true }],
|
|
129
|
+
[
|
|
130
|
+
{ type: 'device-specific' },
|
|
131
|
+
{
|
|
132
|
+
bank_type: 'create-device-specific',
|
|
133
|
+
enable_remote_update: true,
|
|
134
|
+
use_remote_id_prefix: true,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
{ type: 'global-data', id: 'GLOBAL_PROP_1' },
|
|
139
|
+
{
|
|
140
|
+
bank_type: 'global',
|
|
141
|
+
enable_remote_update: true,
|
|
142
|
+
global_remote_update_prop: 'GLOBAL_PROP_1',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
])('emits bank_type for %p', async (remoteUpdate, expectedRemoteUpdate) => {
|
|
146
|
+
const config = await compile(makeApp([], [makeData(remoteUpdate)]))
|
|
147
|
+
|
|
148
|
+
expect(config.subspace_map[SUBSPACE_ID].property_bank_map[DATA_ID]).toMatchObject(
|
|
149
|
+
expectedRemoteUpdate,
|
|
150
|
+
)
|
|
151
|
+
})
|
|
152
|
+
})
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { generateCalulationMap, validateConfig } from '../util'
|
|
2
|
+
|
|
3
|
+
const baseConfig = (overrides = {}) => ({
|
|
4
|
+
inputs: {},
|
|
5
|
+
enable_async: false,
|
|
6
|
+
disabled_triggers: {},
|
|
7
|
+
output: null,
|
|
8
|
+
outputs: {},
|
|
9
|
+
error: null,
|
|
10
|
+
code: 'return inputs',
|
|
11
|
+
...overrides,
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const SANDBOX_PREFIX = 'PROPERTY_BANK_COMMAND_NODE_'
|
|
15
|
+
|
|
16
|
+
const sandboxNodeIds = (map) =>
|
|
17
|
+
Object.entries(map)
|
|
18
|
+
.filter(([id, node]) => id.startsWith(SANDBOX_PREFIX) && node.type === 'command-node-sandbox')
|
|
19
|
+
.map(([id, node]) => ({ id, command: node.properties.command }))
|
|
20
|
+
|
|
21
|
+
const findSandboxIds = (map) => {
|
|
22
|
+
const sandbox = sandboxNodeIds(map)
|
|
23
|
+
return {
|
|
24
|
+
run: sandbox.find((s) => s.command === 'SANDBOX_RUN_JAVASCRIPT')?.id,
|
|
25
|
+
error: sandbox.find((s) => s.command === 'SANDBOX_GET_ERROR')?.id,
|
|
26
|
+
result: sandbox.find((s) => s.command === 'SANDBOX_GET_RETURN_VALUE')?.id,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('validateConfig', () => {
|
|
31
|
+
test('returns without throwing for a clean config', () => {
|
|
32
|
+
expect(() => validateConfig(baseConfig({ inputs: { a: 'foo' } }))).not.toThrow()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('skips overlap checks in manual trigger mode', () => {
|
|
36
|
+
const config = baseConfig({
|
|
37
|
+
trigger_mode: 'manual',
|
|
38
|
+
inputs: { a: 'foo' },
|
|
39
|
+
output: 'a',
|
|
40
|
+
error: 'a',
|
|
41
|
+
outputs: { x: ['a'] },
|
|
42
|
+
})
|
|
43
|
+
expect(() => validateConfig(config)).not.toThrow()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('throws when error key collides with an input id', () => {
|
|
47
|
+
const config = baseConfig({ inputs: { a: 'foo' }, error: 'a' })
|
|
48
|
+
expect(() => validateConfig(config)).toThrow(/key: error/)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('throws when output key collides with an input id', () => {
|
|
52
|
+
const config = baseConfig({ inputs: { a: 'foo' }, output: 'a' })
|
|
53
|
+
expect(() => validateConfig(config)).toThrow(/key: output/)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('throws when any outputs entry references an input id', () => {
|
|
57
|
+
const config = baseConfig({
|
|
58
|
+
inputs: { a: 'foo', b: 'bar' },
|
|
59
|
+
outputs: { x: ['c', 'b'] },
|
|
60
|
+
})
|
|
61
|
+
expect(() => validateConfig(config)).toThrow(/key: outputs/)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('does not throw when error/output are falsy and inputs are empty', () => {
|
|
65
|
+
expect(() => validateConfig(baseConfig())).not.toThrow()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('generateCalulationMap', () => {
|
|
70
|
+
test('produces only the three sandbox nodes for an empty config', () => {
|
|
71
|
+
const result = generateCalulationMap(baseConfig())
|
|
72
|
+
|
|
73
|
+
expect(Object.keys(result.map)).toHaveLength(3)
|
|
74
|
+
const { run, error, result: returnValue } = findSandboxIds(result.map)
|
|
75
|
+
|
|
76
|
+
expect(result.map[run].in.inputs).toEqual([])
|
|
77
|
+
expect(result.map[error].out.result).toEqual([])
|
|
78
|
+
expect(result.map[returnValue].out.result).toEqual([])
|
|
79
|
+
expect(Object.keys(result.editor_info)).toHaveLength(3)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('chains multiple inputs through OBJECT_SET commands', () => {
|
|
83
|
+
const result = generateCalulationMap(baseConfig({ inputs: { a: 'foo.bar', b: 'baz' } }))
|
|
84
|
+
|
|
85
|
+
const { run } = findSandboxIds(result.map)
|
|
86
|
+
|
|
87
|
+
// Each input gets a data-node + an OBJECT_SET command-node.
|
|
88
|
+
expect(result.map.a.type).toBe('data-node')
|
|
89
|
+
expect(result.map.b.type).toBe('data-node')
|
|
90
|
+
|
|
91
|
+
const aCommandId = result.map.a.out.value[0].id
|
|
92
|
+
const bCommandId = result.map.b.out.value[0].id
|
|
93
|
+
expect(aCommandId).not.toBe(bCommandId)
|
|
94
|
+
|
|
95
|
+
const aCmd = result.map[aCommandId]
|
|
96
|
+
const bCmd = result.map[bCommandId]
|
|
97
|
+
expect(aCmd.properties.command).toBe('OBJECT_SET')
|
|
98
|
+
expect(aCmd.properties.args.path).toBe('foo.bar')
|
|
99
|
+
expect(bCmd.properties.command).toBe('OBJECT_SET')
|
|
100
|
+
expect(bCmd.properties.args.path).toBe('baz')
|
|
101
|
+
|
|
102
|
+
// First command has no upstream obj; second command's obj input is the first command.
|
|
103
|
+
expect(aCmd.in.obj).toBeNull()
|
|
104
|
+
expect(bCmd.in.obj).toEqual([{ id: aCommandId, port: 'result' }])
|
|
105
|
+
// First command forwards its result to the second command's `obj` input.
|
|
106
|
+
expect(aCmd.out.result).toEqual([{ id: bCommandId, port: 'obj' }])
|
|
107
|
+
// The last command feeds the SANDBOX_RUN_JAVASCRIPT `inputs` port.
|
|
108
|
+
expect(bCmd.out.result).toEqual([{ id: run, port: 'inputs' }])
|
|
109
|
+
expect(result.map[run].in.inputs).toEqual([{ id: bCommandId, port: 'result' }])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('builds OBJECT_GET commands and target data-nodes for outputs', () => {
|
|
113
|
+
const result = generateCalulationMap(baseConfig({ outputs: { resultPath: ['pb1', 'pb2'] } }))
|
|
114
|
+
|
|
115
|
+
const { result: returnValue } = findSandboxIds(result.map)
|
|
116
|
+
|
|
117
|
+
// Both target property-bank nodes are created as data-nodes.
|
|
118
|
+
expect(result.map.pb1.type).toBe('data-node')
|
|
119
|
+
expect(result.map.pb2.type).toBe('data-node')
|
|
120
|
+
|
|
121
|
+
// The SANDBOX_GET_RETURN_VALUE forwards to the OBJECT_GET command for the output entry.
|
|
122
|
+
const objectGetRefs = result.map[returnValue].out.result
|
|
123
|
+
expect(objectGetRefs).toHaveLength(1)
|
|
124
|
+
const getCommandId = objectGetRefs[0].id
|
|
125
|
+
expect(objectGetRefs[0].port).toBe('obj')
|
|
126
|
+
|
|
127
|
+
const getCmd = result.map[getCommandId]
|
|
128
|
+
expect(getCmd.type).toBe('command-node-object')
|
|
129
|
+
expect(getCmd.properties.command).toBe('OBJECT_GET')
|
|
130
|
+
expect(getCmd.properties.args.path).toBe('resultPath')
|
|
131
|
+
expect(getCmd.in.obj).toEqual([{ id: returnValue, port: 'result' }])
|
|
132
|
+
|
|
133
|
+
// OBJECT_GET feeds both target data-nodes' `change` ports.
|
|
134
|
+
expect(getCmd.out.result).toEqual([
|
|
135
|
+
{ id: 'pb1', port: 'change' },
|
|
136
|
+
{ id: 'pb2', port: 'change' },
|
|
137
|
+
])
|
|
138
|
+
// Target data-nodes consume the OBJECT_GET result via their `change` port.
|
|
139
|
+
expect(result.map.pb1.in.change).toEqual([{ id: getCommandId, port: 'result' }])
|
|
140
|
+
expect(result.map.pb2.in.change).toEqual([{ id: getCommandId, port: 'result' }])
|
|
141
|
+
|
|
142
|
+
// Without input usage their `out.value` defaults to null.
|
|
143
|
+
expect(result.map.pb1.out.value).toBeNull()
|
|
144
|
+
expect(result.map.pb2.out.value).toBeNull()
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Manual mode is the only mode that lets an output target reuse an input id
|
|
148
|
+
// (see validateConfig tests). When that happens, generateCalulationMap must
|
|
149
|
+
// keep the input-side `out.value` so the data-node remains a usable input.
|
|
150
|
+
test.each([
|
|
151
|
+
['outputs', { outputs: { result: ['shared'] } }],
|
|
152
|
+
['output', { output: 'shared' }],
|
|
153
|
+
['error', { error: 'shared' }],
|
|
154
|
+
])('preserves input out.value when %s target reuses an input id', (_, overrides) => {
|
|
155
|
+
const result = generateCalulationMap(
|
|
156
|
+
baseConfig({ trigger_mode: 'manual', inputs: { shared: 'foo' }, ...overrides }),
|
|
157
|
+
)
|
|
158
|
+
expect(Array.isArray(result.map.shared.out.value)).toBe(true)
|
|
159
|
+
expect(result.map[result.map.shared.out.value[0].id].properties.command).toBe('OBJECT_SET')
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('also rewires in.change to OBJECT_GET when an outputs target reuses an input id', () => {
|
|
163
|
+
const result = generateCalulationMap(
|
|
164
|
+
baseConfig({
|
|
165
|
+
trigger_mode: 'manual',
|
|
166
|
+
inputs: { shared: 'foo' },
|
|
167
|
+
outputs: { result: ['shared'] },
|
|
168
|
+
}),
|
|
169
|
+
)
|
|
170
|
+
expect(result.map.shared.in.change).toHaveLength(1)
|
|
171
|
+
expect(result.map[result.map.shared.in.change[0].id].properties.command).toBe('OBJECT_GET')
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
test('preserves out.value when the same pb appears in multiple outputs entries', () => {
|
|
175
|
+
// Two outputs entries both target `pb1`. The reduce visits each entry in turn
|
|
176
|
+
// and must preserve the accumulated `out.value` from the first iteration via
|
|
177
|
+
// `acc.map[pb]` rather than wiping it on the second.
|
|
178
|
+
const result = generateCalulationMap(
|
|
179
|
+
baseConfig({ outputs: { first: ['pb1'], second: ['pb1'] } }),
|
|
180
|
+
)
|
|
181
|
+
expect(result.map.pb1.type).toBe('data-node')
|
|
182
|
+
// Without an input, out.value remains null after both passes.
|
|
183
|
+
expect(result.map.pb1.out.value).toBeNull()
|
|
184
|
+
// The latest OBJECT_GET wins as the change source — each iteration overwrites
|
|
185
|
+
// `in.change`, so we end up pointing at the second outputs entry's command.
|
|
186
|
+
expect(result.map.pb1.in.change).toHaveLength(1)
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
test('wires the error data-node when error is configured', () => {
|
|
190
|
+
const result = generateCalulationMap(baseConfig({ error: 'errNode' }))
|
|
191
|
+
|
|
192
|
+
const { error } = findSandboxIds(result.map)
|
|
193
|
+
// SANDBOX_GET_ERROR now broadcasts to the error data-node's `change` port.
|
|
194
|
+
expect(result.map[error].out.result).toEqual([{ id: 'errNode', port: 'change' }])
|
|
195
|
+
expect(result.map.errNode.type).toBe('data-node')
|
|
196
|
+
expect(result.map.errNode.in.change).toEqual([{ id: error, port: 'result' }])
|
|
197
|
+
// No upstream input → out.value falls back to null.
|
|
198
|
+
expect(result.map.errNode.out.value).toBeNull()
|
|
199
|
+
// editor_info contains the new node.
|
|
200
|
+
expect(result.editor_info.errNode).toBeDefined()
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
test('wires the output data-node when output is configured', () => {
|
|
204
|
+
const result = generateCalulationMap(baseConfig({ output: 'outNode' }))
|
|
205
|
+
|
|
206
|
+
const { result: returnValue } = findSandboxIds(result.map)
|
|
207
|
+
expect(result.map[returnValue].out.result).toEqual([{ id: 'outNode', port: 'change' }])
|
|
208
|
+
expect(result.map.outNode.type).toBe('data-node')
|
|
209
|
+
expect(result.map.outNode.in.change).toEqual([{ id: returnValue, port: 'result' }])
|
|
210
|
+
expect(result.editor_info.outNode).toBeDefined()
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
test('manual trigger mode sets disable_trigger_command on input value ports', () => {
|
|
214
|
+
const result = generateCalulationMap(
|
|
215
|
+
baseConfig({
|
|
216
|
+
trigger_mode: 'manual',
|
|
217
|
+
inputs: { a: 'foo', b: 'bar' },
|
|
218
|
+
}),
|
|
219
|
+
)
|
|
220
|
+
const aCmdId = result.map.a.out.value[0].id
|
|
221
|
+
const bCmdId = result.map.b.out.value[0].id
|
|
222
|
+
expect(result.map[aCmdId].in.value[0].disable_trigger_command).toBe(true)
|
|
223
|
+
expect(result.map[bCmdId].in.value[0].disable_trigger_command).toBe(true)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
test('auto trigger mode honours per-key disabled_triggers', () => {
|
|
227
|
+
const result = generateCalulationMap(
|
|
228
|
+
baseConfig({
|
|
229
|
+
inputs: { a: 'foo', b: 'bar' },
|
|
230
|
+
disabled_triggers: { a: true, b: false },
|
|
231
|
+
}),
|
|
232
|
+
)
|
|
233
|
+
const aCmdId = result.map.a.out.value[0].id
|
|
234
|
+
const bCmdId = result.map.b.out.value[0].id
|
|
235
|
+
expect(result.map[aCmdId].in.value[0].disable_trigger_command).toBe(true)
|
|
236
|
+
// Falsy disabled_triggers entry → property is not set (or set to undefined).
|
|
237
|
+
expect(result.map[bCmdId].in.value[0].disable_trigger_command).toBeUndefined()
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
test('auto trigger mode without disabled_triggers leaves disable_trigger_command undefined', () => {
|
|
241
|
+
const result = generateCalulationMap(baseConfig({ inputs: { a: 'foo' } }))
|
|
242
|
+
const aCmdId = result.map.a.out.value[0].id
|
|
243
|
+
expect(result.map[aCmdId].in.value[0].disable_trigger_command).toBeUndefined()
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
test('snapshotMode forwards to makeId so generated ids are deterministic v4 uuids', () => {
|
|
247
|
+
const result = generateCalulationMap(baseConfig({ inputs: { a: 'foo' } }), {
|
|
248
|
+
snapshotMode: true,
|
|
249
|
+
})
|
|
250
|
+
const sandboxIds = sandboxNodeIds(result.map).map((s) => s.id)
|
|
251
|
+
const uuid = '[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}'
|
|
252
|
+
sandboxIds.forEach((id) => {
|
|
253
|
+
expect(id).toMatch(new RegExp(`^PROPERTY_BANK_COMMAND_NODE_${uuid}$`))
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
test('validateConfig errors propagate out of generateCalulationMap', () => {
|
|
258
|
+
expect(() => generateCalulationMap(baseConfig({ inputs: { a: 'foo' }, error: 'a' }))).toThrow(
|
|
259
|
+
/key: error/,
|
|
260
|
+
)
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
test('SANDBOX_GET_RETURN_VALUE broadcasts to both output target and outputs commands', () => {
|
|
264
|
+
const result = generateCalulationMap(
|
|
265
|
+
baseConfig({
|
|
266
|
+
output: 'outNode',
|
|
267
|
+
outputs: { foo: ['pb1'] },
|
|
268
|
+
}),
|
|
269
|
+
)
|
|
270
|
+
const { result: returnValue } = findSandboxIds(result.map)
|
|
271
|
+
const refs = result.map[returnValue].out.result
|
|
272
|
+
// First entry is the output data-node's `change` port; remainder are OBJECT_GET ids.
|
|
273
|
+
expect(refs[0]).toEqual({ id: 'outNode', port: 'change' })
|
|
274
|
+
expect(refs).toHaveLength(2)
|
|
275
|
+
expect(refs[1].port).toBe('obj')
|
|
276
|
+
expect(result.map[refs[1].id].properties.command).toBe('OBJECT_GET')
|
|
277
|
+
})
|
|
278
|
+
})
|
|
@@ -350,6 +350,63 @@ export const templateActionNameMap = {
|
|
|
350
350
|
strokeWidth: 'BRICK_SKETCH_STROKE_WIDTH',
|
|
351
351
|
},
|
|
352
352
|
},
|
|
353
|
+
BRICK_SCENE_3D: {
|
|
354
|
+
BRICK_SCENE_3D_ADD_OBJECT: {
|
|
355
|
+
objectId: 'BRICK_SCENE_3D_OBJECT_ID',
|
|
356
|
+
objectType: 'BRICK_SCENE_3D_OBJECT_TYPE',
|
|
357
|
+
objectUrl: 'BRICK_SCENE_3D_OBJECT_URL',
|
|
358
|
+
objectMd5: 'BRICK_SCENE_3D_OBJECT_MD5',
|
|
359
|
+
objectPosition: 'BRICK_SCENE_3D_OBJECT_POSITION',
|
|
360
|
+
objectRotation: 'BRICK_SCENE_3D_OBJECT_ROTATION',
|
|
361
|
+
objectScale: 'BRICK_SCENE_3D_OBJECT_SCALE',
|
|
362
|
+
objectColor: 'BRICK_SCENE_3D_OBJECT_COLOR',
|
|
363
|
+
},
|
|
364
|
+
BRICK_SCENE_3D_REMOVE_OBJECT: {
|
|
365
|
+
objectId: 'BRICK_SCENE_3D_OBJECT_ID',
|
|
366
|
+
},
|
|
367
|
+
BRICK_SCENE_3D_UPDATE_OBJECT: {
|
|
368
|
+
objectId: 'BRICK_SCENE_3D_OBJECT_ID',
|
|
369
|
+
objectPosition: 'BRICK_SCENE_3D_OBJECT_POSITION',
|
|
370
|
+
objectRotation: 'BRICK_SCENE_3D_OBJECT_ROTATION',
|
|
371
|
+
objectScale: 'BRICK_SCENE_3D_OBJECT_SCALE',
|
|
372
|
+
objectVisible: 'BRICK_SCENE_3D_OBJECT_VISIBLE',
|
|
373
|
+
objectColor: 'BRICK_SCENE_3D_OBJECT_COLOR',
|
|
374
|
+
objectNodes: 'BRICK_SCENE_3D_OBJECT_NODES',
|
|
375
|
+
},
|
|
376
|
+
BRICK_SCENE_3D_SET_CAMERA: {
|
|
377
|
+
cameraPosition: 'BRICK_SCENE_3D_CAMERA_POSITION',
|
|
378
|
+
cameraTarget: 'BRICK_SCENE_3D_CAMERA_TARGET',
|
|
379
|
+
cameraFov: 'BRICK_SCENE_3D_CAMERA_FOV',
|
|
380
|
+
cameraAnimateMs: 'BRICK_SCENE_3D_CAMERA_ANIMATE_MS',
|
|
381
|
+
},
|
|
382
|
+
BRICK_SCENE_3D_LOOK_AT: {
|
|
383
|
+
objectId: 'BRICK_SCENE_3D_OBJECT_ID',
|
|
384
|
+
},
|
|
385
|
+
BRICK_SCENE_3D_PLAY_ANIMATION: {
|
|
386
|
+
objectId: 'BRICK_SCENE_3D_OBJECT_ID',
|
|
387
|
+
animationName: 'BRICK_SCENE_3D_ANIMATION_NAME',
|
|
388
|
+
animationLoop: 'BRICK_SCENE_3D_ANIMATION_LOOP',
|
|
389
|
+
animationSpeed: 'BRICK_SCENE_3D_ANIMATION_SPEED',
|
|
390
|
+
},
|
|
391
|
+
BRICK_SCENE_3D_STOP_ANIMATION: {
|
|
392
|
+
objectId: 'BRICK_SCENE_3D_OBJECT_ID',
|
|
393
|
+
animationName: 'BRICK_SCENE_3D_ANIMATION_NAME',
|
|
394
|
+
},
|
|
395
|
+
BRICK_SCENE_3D_SET_BACKGROUND: {
|
|
396
|
+
backgroundColor: 'BRICK_SCENE_3D_BACKGROUND_COLOR',
|
|
397
|
+
backgroundHdrUrl: 'BRICK_SCENE_3D_BACKGROUND_HDR_URL',
|
|
398
|
+
backgroundMd5: 'BRICK_SCENE_3D_BACKGROUND_MD5',
|
|
399
|
+
},
|
|
400
|
+
BRICK_SCENE_3D_SET_CONTROLS: {
|
|
401
|
+
controlsEnabled: 'BRICK_SCENE_3D_CONTROLS_ENABLED',
|
|
402
|
+
controlsAutoRotate: 'BRICK_SCENE_3D_CONTROLS_AUTO_ROTATE',
|
|
403
|
+
controlsAutoRotateSpeed: 'BRICK_SCENE_3D_CONTROLS_AUTO_ROTATE_SPEED',
|
|
404
|
+
},
|
|
405
|
+
BRICK_SCENE_3D_SCREENSHOT: {
|
|
406
|
+
screenshotFormat: 'BRICK_SCENE_3D_SCREENSHOT_FORMAT',
|
|
407
|
+
screenshotQuality: 'BRICK_SCENE_3D_SCREENSHOT_QUALITY',
|
|
408
|
+
},
|
|
409
|
+
},
|
|
353
410
|
|
|
354
411
|
GENERATOR_FILE: {
|
|
355
412
|
GENERATOR_FILE_READ_CONTENT: {
|
|
@@ -782,6 +839,11 @@ export const templateActionNameMap = {
|
|
|
782
839
|
seed: 'GENERATOR_LLM_SEED',
|
|
783
840
|
typicalP: 'GENERATOR_LLM_TYPICAL_P',
|
|
784
841
|
ignoreEos: 'GENERATOR_LLM_IGNORE_EOS',
|
|
842
|
+
mtpSpeculativeDecoding: 'GENERATOR_LLM_MTP_SPECULATIVE_DECODING',
|
|
843
|
+
mtpDraftTokens: 'GENERATOR_LLM_MTP_DRAFT_TOKENS',
|
|
844
|
+
mtpDraftMinTokens: 'GENERATOR_LLM_MTP_DRAFT_MIN_TOKENS',
|
|
845
|
+
mtpDraftMinProbability: 'GENERATOR_LLM_MTP_DRAFT_MIN_PROBABILITY',
|
|
846
|
+
mtpDraftSplitProbability: 'GENERATOR_LLM_MTP_DRAFT_SPLIT_PROBABILITY',
|
|
785
847
|
functionCallEnabled: 'GENERATOR_LLM_FUNCTION_CALL_ENABLED',
|
|
786
848
|
functionCallSchema: 'GENERATOR_LLM_FUNCTION_CALL_SCHEMA',
|
|
787
849
|
},
|
|
@@ -894,10 +956,12 @@ export const templateActionNameMap = {
|
|
|
894
956
|
GENERATOR_APPLE_STT_TRANSCRIBE_FILE: {
|
|
895
957
|
fileUrl: 'GENERATOR_APPLE_STT_FILE_URL',
|
|
896
958
|
language: 'GENERATOR_APPLE_STT_LANGUAGE',
|
|
959
|
+
contextualStrings: 'GENERATOR_APPLE_STT_CONTEXTUAL_STRINGS',
|
|
897
960
|
},
|
|
898
961
|
GENERATOR_APPLE_STT_TRANSCRIBE_DATA: {
|
|
899
962
|
data: 'GENERATOR_APPLE_STT_DATA',
|
|
900
963
|
language: 'GENERATOR_APPLE_STT_LANGUAGE',
|
|
964
|
+
contextualStrings: 'GENERATOR_APPLE_STT_CONTEXTUAL_STRINGS',
|
|
901
965
|
},
|
|
902
966
|
},
|
|
903
967
|
GENERATOR_APPLE_TTS: {
|