@adminide-stack/yantra-mobile 12.0.172-alpha.1 → 12.0.173
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/lib/features/apps/mobileAppCatalog.js +2 -2
- package/lib/features/apps/mobileAppCatalog.js.map +1 -1
- package/lib/features/chat/NotionPageWidgetCard.js +98 -0
- package/lib/features/chat/NotionPageWidgetCard.js.map +1 -0
- package/lib/features/chat/hostTranscriptProtocol.js +5 -1
- package/lib/features/chat/hostTranscriptProtocol.js.map +1 -1
- package/lib/features/chat/notionPageWidget.js +34 -0
- package/lib/features/chat/notionPageWidget.js.map +1 -0
- package/lib/features/games/cubeforge3D.js +11 -6
- package/lib/features/games/cubeforge3D.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/items.js +2 -8
- package/lib/features/games/vendored/core/cubeforge/items.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/recipes.js +1 -4
- package/lib/features/games/vendored/core/cubeforge/recipes.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/skin.js +83 -0
- package/lib/features/games/vendored/core/cubeforge/skin.js.map +1 -0
- package/lib/features/games/vendored/core/cubeforge/worldgen.js +2 -38
- package/lib/features/games/vendored/core/cubeforge/worldgen.js.map +1 -1
- package/lib/features/games/vendored/core/engine/palette.js +2 -9
- package/lib/features/games/vendored/core/engine/palette.js.map +1 -1
- package/lib/features/games/vendored/core/lessons/lessons.js +2 -96
- package/lib/features/games/vendored/core/lessons/lessons.js.map +1 -1
- package/lib/features/games/vendored/ui/GamesRoot.js +87 -144
- package/lib/features/games/vendored/ui/GamesRoot.js.map +1 -1
- package/lib/features/games/vendored/ui/components/primitives.js +2 -50
- package/lib/features/games/vendored/ui/components/primitives.js.map +1 -1
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +20 -3
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -1
- package/lib/features/games/vendored/ui/screens/SkinEditorScreen.js +169 -0
- package/lib/features/games/vendored/ui/screens/SkinEditorScreen.js.map +1 -0
- package/lib/features/games/vendored/ui/theme.js +1 -3
- package/lib/features/games/vendored/ui/theme.js.map +1 -1
- package/lib/features/notion/notionEditorModel.js +3 -1
- package/lib/features/notion/notionEditorModel.js.map +1 -1
- package/lib/screens/GamesNative/index.js +1 -1
- package/lib/screens/Home/components/homeCatalog.js +2 -2
- package/lib/screens/Home/components/homeCatalog.js.map +1 -1
- package/package.json +4 -4
- package/lib/features/games/vendored/core/classroom/permissions.js +0 -76
- package/lib/features/games/vendored/core/classroom/permissions.js.map +0 -1
- package/lib/features/games/vendored/core/classroom/resourceLink.js +0 -101
- package/lib/features/games/vendored/core/classroom/resourceLink.js.map +0 -1
- package/lib/features/games/vendored/core/classroom/rules.js +0 -83
- package/lib/features/games/vendored/core/classroom/rules.js.map +0 -1
- package/lib/features/games/vendored/core/classroom/worldSettings.js +0 -49
- package/lib/features/games/vendored/core/classroom/worldSettings.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/cycle.js +0 -15
- package/lib/features/games/vendored/core/cubeforge/cycle.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/inventory.js +0 -75
- package/lib/features/games/vendored/core/cubeforge/inventory.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/save.js +0 -92
- package/lib/features/games/vendored/core/cubeforge/save.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/session.js +0 -154
- package/lib/features/games/vendored/core/cubeforge/session.js.map +0 -1
- package/lib/features/games/vendored/core/engine/iso.js +0 -41
- package/lib/features/games/vendored/core/engine/iso.js.map +0 -1
- package/lib/features/games/vendored/core/engine/world.js +0 -148
- package/lib/features/games/vendored/core/engine/world.js.map +0 -1
- package/lib/features/games/vendored/core/games/catalog.js +0 -34
- package/lib/features/games/vendored/core/games/catalog.js.map +0 -1
- package/lib/features/games/vendored/core/logging/events.js +0 -24
- package/lib/features/games/vendored/core/logging/events.js.map +0 -1
- package/lib/features/games/vendored/core/logging/logger.js +0 -54
- package/lib/features/games/vendored/core/logging/logger.js.map +0 -1
- package/lib/features/games/vendored/core/session/gameSession.js +0 -317
- package/lib/features/games/vendored/core/session/gameSession.js.map +0 -1
- package/lib/features/games/vendored/core/storage/worldRepository.js +0 -192
- package/lib/features/games/vendored/core/storage/worldRepository.js.map +0 -1
- package/lib/features/games/vendored/core/store/reactive.js +0 -78
- package/lib/features/games/vendored/core/store/reactive.js.map +0 -1
- package/lib/features/games/vendored/ui/components/BlockPalette.js +0 -64
- package/lib/features/games/vendored/ui/components/BlockPalette.js.map +0 -1
- package/lib/features/games/vendored/ui/components/IsoCanvas.js +0 -124
- package/lib/features/games/vendored/ui/components/IsoCanvas.js.map +0 -1
- package/lib/features/games/vendored/ui/hooks/useReactiveQuery.js +0 -3
- package/lib/features/games/vendored/ui/hooks/useReactiveQuery.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/ActivityScreen.js +0 -68
- package/lib/features/games/vendored/ui/screens/ActivityScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/BuilderScreen.js +0 -227
- package/lib/features/games/vendored/ui/screens/BuilderScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/ClassroomScreen.js +0 -95
- package/lib/features/games/vendored/ui/screens/ClassroomScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js +0 -342
- package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/HubScreen.js +0 -131
- package/lib/features/games/vendored/ui/screens/HubScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/WorldListScreen.js +0 -134
- package/lib/features/games/vendored/ui/screens/WorldListScreen.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkinEditorScreen.js","sources":["../../../../../../src/features/games/vendored/ui/screens/SkinEditorScreen.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useCallback, useState } from 'react';\nimport { Pressable, ScrollView, StyleSheet, Text, View, type GestureResponderEvent } from 'react-native';\nimport { presetSkin, SKIN_GRIDS, SKIN_PALETTE, SKIN_PRESET_COUNT, type SkinGrid, type SkinPart } from '../../core';\nimport { radius, spacing, type Theme } from '../theme';\nimport { Button, SectionHeader, SegmentedControl } from '../components/primitives';\nimport { ScreenHeader } from './ScreenHeader';\n\nconst CANVAS_WIDTH = 280;\nconst MIN_CELL = 18;\nconst MAX_CELL = 34;\nconst PREVIEW_CELL = 5;\nconst SWATCH = 40;\n\n/** Paints a skin one body part at a time, with a front view that updates as you go. */\nexport function SkinEditorScreen(props: {\n theme: Theme;\n initial: number[] | null;\n onBack: () => void;\n onSave: (cells: number[]) => void;\n}): React.ReactElement {\n const { theme, initial, onBack, onSave } = props;\n const [cells, setCells] = useState<number[]>(() => initial ?? presetSkin(0));\n const [part, setPart] = useState<SkinPart>('head');\n const [color, setColor] = useState(11);\n const [preset, setPreset] = useState(0);\n\n const grid = SKIN_GRIDS[part];\n const cell = Math.max(MIN_CELL, Math.min(MAX_CELL, Math.floor(CANVAS_WIDTH / grid.width)));\n\n const paintAt = useCallback(\n (event: GestureResponderEvent) => {\n const { locationX, locationY } = event.nativeEvent;\n const x = Math.floor(locationX / cell);\n const y = Math.floor(locationY / cell);\n if (x < 0 || y < 0 || x >= grid.width || y >= grid.height) return;\n const at = grid.start + y * grid.width + x;\n setCells((prev) => {\n if (prev[at] === color) return prev;\n const next = prev.slice();\n next[at] = color;\n return next;\n });\n },\n [cell, color, grid],\n );\n\n const nextLook = () => {\n const next = (preset + 1) % SKIN_PRESET_COUNT;\n setPreset(next);\n setCells(presetSkin(next));\n };\n\n return (\n <View style={{ flex: 1, backgroundColor: theme.bg }}>\n <ScreenHeader theme={theme} title=\"Your avatar\" onBack={onBack} backLabel=\"Back\" />\n <ScrollView contentContainerStyle={styles.content}>\n <View style={[styles.previewCard, { backgroundColor: theme.surface, borderColor: theme.border }]}>\n <Figure cells={cells} />\n <View style={styles.previewText}>\n <Text style={[styles.previewTitle, { color: theme.text }]}>This is how friends see you</Text>\n <Button theme={theme} variant=\"secondary\" label=\"Try another look\" onPress={nextLook} />\n </View>\n </View>\n\n <SegmentedControl<SkinPart>\n theme={theme}\n value={part}\n onChange={setPart}\n options={[\n { value: 'head', label: 'Head' },\n { value: 'body', label: 'Body' },\n { value: 'arms', label: 'Arms' },\n { value: 'legs', label: 'Legs' },\n ]}\n />\n\n <View style={styles.center}>\n <View\n accessibilityLabel={`Paint the ${part}`}\n onStartShouldSetResponder={() => true}\n onMoveShouldSetResponder={() => true}\n onResponderGrant={paintAt}\n onResponderMove={paintAt}\n style={{\n width: cell * grid.width,\n height: cell * grid.height,\n borderColor: theme.border,\n borderWidth: 1,\n }}\n >\n <Pixels cells={cells} grid={grid} size={cell} />\n </View>\n </View>\n\n <SectionHeader theme={theme} title=\"Colour\" />\n <View style={styles.palette}>\n {SKIN_PALETTE.map((hex, i) => (\n <Pressable\n key={hex}\n accessibilityRole=\"button\"\n accessibilityLabel={`Colour ${i + 1}`}\n accessibilityState={{ selected: i === color }}\n onPress={() => setColor(i)}\n style={[\n styles.swatch,\n { backgroundColor: hex, borderColor: i === color ? theme.primary : theme.border },\n i === color && styles.swatchSelected,\n ]}\n />\n ))}\n </View>\n\n <Button theme={theme} label=\"Save avatar\" onPress={() => onSave(cells)} />\n </ScrollView>\n </View>\n );\n}\n\nfunction Pixels({ cells, grid, size }: { cells: number[]; grid: SkinGrid; size: number }): React.ReactElement {\n const rows = [];\n for (let y = 0; y < grid.height; y += 1) {\n const columns = [];\n for (let x = 0; x < grid.width; x += 1) {\n const value = cells[grid.start + y * grid.width + x] ?? 0;\n columns.push(\n <View key={x} style={{ width: size, height: size, backgroundColor: SKIN_PALETTE[value & 15] }} />,\n );\n }\n rows.push(\n <View key={y} pointerEvents=\"none\" style={styles.row}>\n {columns}\n </View>,\n );\n }\n return <View pointerEvents=\"none\">{rows}</View>;\n}\n\n/** A flat front view: head on the body, arms at the sides, legs below. */\nfunction Figure({ cells }: { cells: number[] }): React.ReactElement {\n return (\n <View style={styles.figure}>\n <Pixels cells={cells} grid={SKIN_GRIDS.head} size={PREVIEW_CELL} />\n <View style={styles.row}>\n <Pixels cells={cells} grid={SKIN_GRIDS.arms} size={PREVIEW_CELL} />\n <Pixels cells={cells} grid={SKIN_GRIDS.body} size={PREVIEW_CELL} />\n <Pixels cells={cells} grid={SKIN_GRIDS.arms} size={PREVIEW_CELL} />\n </View>\n <View style={styles.row}>\n <Pixels cells={cells} grid={SKIN_GRIDS.legs} size={PREVIEW_CELL} />\n <Pixels cells={cells} grid={SKIN_GRIDS.legs} size={PREVIEW_CELL} />\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n content: { padding: spacing.lg, gap: spacing.md },\n center: { alignItems: 'center' },\n row: { flexDirection: 'row' },\n figure: { alignItems: 'center' },\n previewCard: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: spacing.lg,\n padding: spacing.lg,\n borderRadius: radius.lg,\n borderWidth: 1,\n },\n previewText: { flex: 1, gap: spacing.md },\n previewTitle: { fontSize: 16, fontWeight: '600' },\n palette: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },\n swatch: { width: SWATCH, height: SWATCH, borderRadius: radius.sm, borderWidth: 2 },\n swatchSelected: { borderWidth: 4 },\n});\n"],"names":[],"mappings":"sjBAOA,MAAM,YAAe,GAAA,GAAA;AACrB,MAAM,QAAW,GAAA,EAAA;AACjB,MAAM,QAAW,GAAA,EAAA;AACjB,MAAM,YAAe,GAAA,CAAA;AACrB,MAAM,MAAS,GAAA,EAAA;AAGR,SAAS,iBAAiB,KAKV,EAAA;AACrB,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAM,MAAA,CAAC,OAAO,QAAQ,CAAA,GAAI,SAAmB,MAAM,OAAA,IAAA,IAAA,GAAA,OAAA,GAAW,UAAW,CAAA,CA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/features/games/vendored/ui/theme.ts"],"sourcesContent":["/**\n * Theme tokens for the Yantra Games UI. Original palette, tuned for light and\n * dark. Everything the UI colours comes from here so the look stays consistent.\n */\n\nexport type ThemeMode = 'light' | 'dark';\n\nexport interface Theme {\n mode: ThemeMode;\n bg: string;\n surface: string;\n surfaceAlt: string;\n border: string;\n text: string;\n textMuted: string;\n primary: string;\n primaryText: string;\n accent: string;\n danger: string;\n overlay: string;\n gridLine: string;\n gridFill: string;\n gridFillAlt: string;\n shadow: string;\n}\n\nconst lightTheme: Theme = {\n mode: 'light',\n bg: '#f4f6f8',\n surface: '#ffffff',\n surfaceAlt: '#eef1f4',\n border: '#dde2e8',\n text: '#1b2127',\n textMuted: '#687280',\n primary: '#2f7d57',\n primaryText: '#ffffff',\n accent: '#7cc86b',\n danger: '#c0493a',\n overlay: 'rgba(16,22,28,0.45)',\n gridLine: '#c9d2db',\n gridFill: '#e7edf2',\n gridFillAlt: '#dfe6ec',\n shadow: 'rgba(16,22,28,0.12)',\n};\n\nconst darkTheme: Theme = {\n mode: 'dark',\n bg: '#12161b',\n surface: '#1b2229',\n surfaceAlt: '#232b34',\n border: '#2e3842',\n text: '#eef2f6',\n textMuted: '#9aa6b2',\n primary: '#4aa578',\n primaryText: '#07120c',\n accent: '#7cc86b',\n danger: '#e06a5a',\n overlay: 'rgba(0,0,0,0.6)',\n gridLine: '#39434e',\n gridFill: '#222b34',\n gridFillAlt: '#1d252d',\n shadow: 'rgba(0,0,0,0.4)',\n};\n\nexport function getTheme(mode: ThemeMode): Theme {\n return mode === 'dark' ? darkTheme : lightTheme;\n}\n\nexport const spacing = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 16,\n xl: 24,\n xxl: 32,\n} as const;\n\nexport const radius = {\n sm: 8,\n md: 12,\n lg: 18,\n pill: 999,\n} as const;\n"],"names":[],"mappings":"AAwBA,MAAM,UAAoB,GAAA;AAAA,EACxB,IAAM,EAAA,OAAA;AAAA,EACN,EAAI,EAAA,SAAA;AA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theme.ts"],"sourcesContent":["/**\n * Theme tokens for the Yantra Games UI. Original palette, tuned for light and\n * dark. Everything the UI colours comes from here so the look stays consistent.\n */\n\nexport type ThemeMode = 'light' | 'dark';\n\nexport interface Theme {\n mode: ThemeMode;\n bg: string;\n surface: string;\n surfaceAlt: string;\n border: string;\n text: string;\n textMuted: string;\n primary: string;\n primaryText: string;\n accent: string;\n danger: string;\n overlay: string;\n gridLine: string;\n gridFill: string;\n gridFillAlt: string;\n shadow: string;\n}\n\nconst lightTheme: Theme = {\n mode: 'light',\n bg: '#f4f6f8',\n surface: '#ffffff',\n surfaceAlt: '#eef1f4',\n border: '#dde2e8',\n text: '#1b2127',\n textMuted: '#687280',\n primary: '#2f7d57',\n primaryText: '#ffffff',\n accent: '#7cc86b',\n danger: '#c0493a',\n overlay: 'rgba(16,22,28,0.45)',\n gridLine: '#c9d2db',\n gridFill: '#e7edf2',\n gridFillAlt: '#dfe6ec',\n shadow: 'rgba(16,22,28,0.12)',\n};\n\nconst darkTheme: Theme = {\n mode: 'dark',\n bg: '#12161b',\n surface: '#1b2229',\n surfaceAlt: '#232b34',\n border: '#2e3842',\n text: '#eef2f6',\n textMuted: '#9aa6b2',\n primary: '#4aa578',\n primaryText: '#07120c',\n accent: '#7cc86b',\n danger: '#e06a5a',\n overlay: 'rgba(0,0,0,0.6)',\n gridLine: '#39434e',\n gridFill: '#222b34',\n gridFillAlt: '#1d252d',\n shadow: 'rgba(0,0,0,0.4)',\n};\n\nexport function getTheme(mode: ThemeMode): Theme {\n return mode === 'dark' ? darkTheme : lightTheme;\n}\n\nexport const spacing = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 16,\n xl: 24,\n xxl: 32,\n} as const;\n\nexport const radius = {\n sm: 8,\n md: 12,\n lg: 18,\n pill: 999,\n} as const;\n"],"names":[],"mappings":"AAwBA,MAAM,UAAoB,GAAA;AAAA,EACxB,IAAM,EAAA,OAAA;AAAA,EACN,EAAI,EAAA,SAAA;AAAA,EACJ,OAAS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AAI,EAAA,EAAA;AAAA,EACJ,EAAI,EAAA,EAAA;AAAA,EACJ,IAAM,EAAA;AACR"}
|
|
@@ -95,7 +95,9 @@ function toEditorBlock(b, parentId) {
|
|
|
95
95
|
const runs = titleRunsOf(b.properties);
|
|
96
96
|
return {
|
|
97
97
|
id: b.id,
|
|
98
|
-
type
|
|
98
|
+
// A block can arrive with no type (seen on pages the agent wrote). Every reader goes straight to
|
|
99
|
+
// `block.type.startsWith`, so one such block took the whole page down instead of showing as text.
|
|
100
|
+
type: typeof b.type === "string" && b.type ? b.type : "paragraph",
|
|
99
101
|
parentId,
|
|
100
102
|
text: runsText(runs),
|
|
101
103
|
runs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notionEditorModel.js","sources":["../../../src/features/notion/notionEditorModel.ts"],"sourcesContent":["/**\n * Local, optimistic model of an open page for the native editor: blocks by\n * id plus each parent's ordered child ids. Edits apply here first and are\n * sent to the server in the background, so typing never waits on the network.\n *\n * Pure: no RN imports, so it runs under jest as-is.\n */\nimport { isPageBlock, type NotionBlock, type NotionBlockTree } from './notionBlocks';\nimport { runsText, type RichRun } from './notionRichTitle';\nimport { titleRunsOf } from './notionRichText';\n\nexport interface EditorBlock {\n id: string;\n type: string;\n parentId: string;\n /** Plain text of `runs` (what the TextInput edits). */\n text: string;\n /** Formatted runs of the title (bold, colours, links, mentions) - what is saved. */\n runs: RichRun[];\n properties: Record<string, unknown>;\n}\n\nexport interface EditorModel {\n rootId: string;\n blocks: Record<string, EditorBlock>;\n children: Record<string, string[]>;\n}\n\nexport interface EditorLine {\n block: EditorBlock;\n depth: number;\n number?: number;\n}\n\n/** Block types the editor edits as text. */\nexport const TEXT_TYPES: readonly string[] = [\n 'paragraph',\n 'text',\n 'heading_1',\n 'heading_2',\n 'heading_3',\n 'bulleted_list',\n 'numbered_list',\n 'todo',\n 'toggle',\n 'quote',\n 'callout',\n 'code',\n];\n\n/** Types a block can be turned into from the editor toolbar (web slash menu basics). */\nexport const TURN_INTO: ReadonlyArray<{ type: string; label: string; short: string }> = [\n { type: 'paragraph', label: 'Text', short: 'Aa' },\n { type: 'heading_1', label: 'Heading 1', short: 'H1' },\n { type: 'heading_2', label: 'Heading 2', short: 'H2' },\n { type: 'heading_3', label: 'Heading 3', short: 'H3' },\n { type: 'bulleted_list', label: 'Bulleted list', short: '•' },\n { type: 'numbered_list', label: 'Numbered list', short: '1.' },\n { type: 'todo', label: 'To-do', short: '☐' },\n { type: 'toggle', label: 'Toggle', short: '▸' },\n { type: 'quote', label: 'Quote', short: '❝' },\n { type: 'callout', label: 'Callout', short: '💡' },\n { type: 'code', label: 'Code', short: '</>' },\n];\n\nexport function isTextType(type: string): boolean {\n return TEXT_TYPES.includes(type);\n}\n\n/** Layout containers with no content of their own (web column_list / column). */\nexport const LAYOUT_TYPES: readonly string[] = ['column_list', 'column'];\n\n/** Return in a list / to-do continues it; anything else starts a paragraph. */\nexport function nextTypeAfter(type: string): string {\n return type === 'bulleted_list' || type === 'numbered_list' || type === 'todo' ? type : 'paragraph';\n}\n\n/**\n * `rootId` is the page id the caller already knows: the tree's root block can come back\n * without its fields on device (no id / title), and new top-level blocks are parented to it.\n */\nexport function modelFromTree(tree: NotionBlockTree, rootId: string = tree.block?.id): EditorModel {\n const model: EditorModel = { rootId, blocks: {}, children: {} };\n const walk = (nodes: readonly NotionBlockTree[] | null | undefined, parentId: string) => {\n const ids: string[] = [];\n (nodes ?? []).forEach((node) => {\n const b = node?.block;\n if (!b || b.inTrash || b.archived) return;\n ids.push(b.id);\n model.blocks[b.id] = toEditorBlock(b, parentId);\n if (!isPageBlock(b)) walk(node.children, b.id);\n });\n model.children[parentId] = ids;\n };\n walk(tree.children, rootId);\n return model;\n}\n\nexport function toEditorBlock(b: NotionBlock, parentId: string): EditorBlock {\n const runs = titleRunsOf(b.properties);\n return {\n id: b.id,\n type: b.type,\n parentId,\n text: runsText(runs),\n runs,\n properties: (b.properties ?? {}) as Record<string, unknown>,\n };\n}\n\n/** A fresh, empty block (local, before the server has it). */\nexport function emptyBlock(\n id: string,\n type: string,\n parentId: string,\n properties: Record<string, unknown>,\n): EditorBlock {\n return { id, type, parentId, text: '', runs: [], properties };\n}\n\n/**\n * Depth-first lines in reading order, numbering runs of numbered_list siblings. Children of a\n * toggle listed in `collapsed` are hidden (Notion toggles open on tap).\n */\nexport function flattenModel(model: EditorModel, collapsed: ReadonlySet<string> = new Set()): EditorLine[] {\n const lines: EditorLine[] = [];\n const walk = (parentId: string, depth: number) => {\n let run = 0;\n (model.children[parentId] ?? []).forEach((id) => {\n const block = model.blocks[id];\n if (!block) return;\n // Column layouts are transparent on a phone: their blocks read top to bottom at the\n // same indent (the web shows them side by side).\n if (LAYOUT_TYPES.includes(block.type)) {\n run = 0;\n walk(id, depth);\n return;\n }\n run = block.type === 'numbered_list' ? run + 1 : 0;\n lines.push({ block, depth, ...(block.type === 'numbered_list' ? { number: run } : {}) });\n if (!isPageBlock(block) && !(block.type === 'toggle' && collapsed.has(id))) walk(id, depth + 1);\n });\n };\n walk(model.rootId, 0);\n return lines;\n}\n\n/** Insert `block` under its parent right after `afterId` (end when absent or not found). */\nexport function insertAfter(model: EditorModel, block: EditorBlock, afterId?: string | null): EditorModel {\n const siblings = [...(model.children[block.parentId] ?? [])];\n const at = afterId ? siblings.indexOf(afterId) : -1;\n if (at >= 0) siblings.splice(at + 1, 0, block.id);\n else siblings.push(block.id);\n return {\n ...model,\n blocks: { ...model.blocks, [block.id]: block },\n children: { ...model.children, [block.parentId]: siblings },\n };\n}\n\n/** Remove a block and its subtree. */\nexport function removeBlock(model: EditorModel, id: string): EditorModel {\n const block = model.blocks[id];\n if (!block) return model;\n const blocks = { ...model.blocks };\n const children = { ...model.children };\n const drop = (bid: string) => {\n (children[bid] ?? []).forEach(drop);\n delete children[bid];\n delete blocks[bid];\n };\n drop(id);\n children[block.parentId] = (children[block.parentId] ?? []).filter((x) => x !== id);\n return { ...model, blocks, children };\n}\n\nexport function patchBlock(model: EditorModel, id: string, patch: Partial<EditorBlock>): EditorModel {\n const block = model.blocks[id];\n if (!block) return model;\n return { ...model, blocks: { ...model.blocks, [id]: { ...block, ...patch } } };\n}\n\n/** The line before `id` in reading order (where focus goes after deleting it). */\nexport function previousLineId(model: EditorModel, id: string): string | null {\n const lines = flattenModel(model);\n const at = lines.findIndex((l) => l.block.id === id);\n for (let i = at - 1; i >= 0; i -= 1) if (isTextType(lines[i].block.type)) return lines[i].block.id;\n return null;\n}\n\n/** Client-chosen block id (the server accepts `input.id` on create). */\nexport function newBlockId(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) return c.randomUUID();\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0;\n // eslint-disable-next-line no-bitwise\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n}\n\n/**\n * Move a block one place up or down among its siblings. Returns the new sibling order (to send\n * as reorderChildren) or null when it is already at that end.\n */\nexport function moveAmongSiblings(\n model: EditorModel,\n id: string,\n direction: -1 | 1,\n): { model: EditorModel; parentId: string; order: string[] } | null {\n const block = model.blocks[id];\n if (!block) return null;\n const siblings = [...(model.children[block.parentId] ?? [])];\n const at = siblings.indexOf(id);\n const to = at + direction;\n if (at < 0 || to < 0 || to >= siblings.length) return null;\n [siblings[at], siblings[to]] = [siblings[to], siblings[at]];\n return {\n model: { ...model, children: { ...model.children, [block.parentId]: siblings } },\n parentId: block.parentId,\n order: siblings,\n };\n}\n\n/** A removed block with everything under it and where it sat - what Undo puts back. */\nexport interface SubtreeSnapshot {\n id: string;\n parentId: string;\n index: number;\n blocks: Record<string, EditorBlock>;\n children: Record<string, string[]>;\n}\n\nexport function snapshotSubtree(model: EditorModel, id: string): SubtreeSnapshot | null {\n const block = model.blocks[id];\n if (!block) return null;\n const blocks: Record<string, EditorBlock> = {};\n const children: Record<string, string[]> = {};\n const walk = (bid: string) => {\n const b = model.blocks[bid];\n if (!b) return;\n blocks[bid] = b;\n const kids = model.children[bid];\n if (kids) {\n children[bid] = [...kids];\n kids.forEach(walk);\n }\n };\n walk(id);\n const index = (model.children[block.parentId] ?? []).indexOf(id);\n return { id, parentId: block.parentId, index, blocks, children };\n}\n\n/** Put a snapshot back at its old position (clamped to the current siblings). */\nexport function restoreSubtree(model: EditorModel, snap: SubtreeSnapshot): EditorModel {\n const siblings = [...(model.children[snap.parentId] ?? [])].filter((x) => x !== snap.id);\n siblings.splice(Math.max(0, Math.min(snap.index, siblings.length)), 0, snap.id);\n return {\n ...model,\n blocks: { ...model.blocks, ...snap.blocks },\n children: { ...model.children, ...snap.children, [snap.parentId]: siblings },\n };\n}\n\n/** A block to create with its nested children (one appendChildren call, client ids). */\nexport interface NewBlockTree {\n id: string;\n type: string;\n properties: Record<string, unknown>;\n children?: NewBlockTree[];\n}\n\n/** Web \"N columns\": a column_list of N equal columns, each starting with an empty paragraph. */\nexport function columnLayout(n: number, newId: () => string = newBlockId): NewBlockTree {\n const ratio = Math.round((1 / n) * 1000) / 1000;\n return {\n id: newId(),\n type: 'column_list',\n properties: {},\n children: Array.from({ length: n }, () => ({\n id: newId(),\n type: 'column',\n properties: { widthRatio: ratio },\n children: [{ id: newId(), type: 'paragraph', properties: { title: [] } }],\n })),\n };\n}\n\n/** Insert a new block tree locally (after `afterId` under `parentId`). */\nexport function insertTree(\n model: EditorModel,\n tree: NewBlockTree,\n parentId: string,\n afterId?: string | null,\n): EditorModel {\n let next = insertAfter(model, emptyBlock(tree.id, tree.type, parentId, tree.properties), afterId);\n let last: string | null = null;\n (tree.children ?? []).forEach((child) => {\n next = insertTree(next, child, tree.id, last);\n last = child.id;\n });\n if (!(tree.children ?? []).length)\n next = { ...next, children: { ...next.children, [tree.id]: next.children[tree.id] ?? [] } };\n return next;\n}\n\n/** The appendChildren input for a tree (children carry their own parent refs). */\nexport function treeInput(tree: NewBlockTree, parentId: string): Record<string, unknown> {\n return {\n id: tree.id,\n type: tree.type,\n parent: { type: 'block', id: parentId },\n properties: tree.properties,\n ...(tree.children?.length ? { children: tree.children.map((c) => treeInput(c, tree.id)) } : {}),\n };\n}\n\n/** First text block inside a tree (where the caret goes after inserting columns). */\nexport function firstTextId(tree: NewBlockTree): string | null {\n if (TEXT_TYPES.includes(tree.type)) return tree.id;\n for (const c of tree.children ?? []) {\n const hit = firstTextId(c);\n if (hit) return hit;\n }\n return null;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCO,MAAM,UAAgC,GAAA,CAAC,WAAa,EAAA,MAAA,EAAQ,WAAa,EAAA,WAAA,EAAa,WAAa,EAAA,eAAA,EAAiB,eAAiB,EAAA,MAAA,EAAQ,QAAU,EAAA,OAAA,EAAS,WAAW,MAAM;AAGjL,MAAM,YAIR,CAAC;AAAA,EACJ,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,MAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,WAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,WAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,WAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,eAAA;AAAA,EACN,KAAO,EAAA,eAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,eAAA;AAAA,EACN,KAAO,EAAA,eAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,MAAA;AAAA,EACN,KAAO,EAAA,OAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,I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EAAA,IAAA,EAAA;AAwYE,EAAO,OAAA,cAAA,CAAA;AAAA,IACL,IAAI,IAAK,CAAA,EAAA;AAAA,IACT,MAAM,IAAK,CAAA,IAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,IAAM,EAAA,OAAA;AAAA,MACN,EAAI,EAAA;AAAA,KACN;AAAA,IACA,YAAY,IAAK,CAAA;AAAA,GACb,EAAA,CAAA,CAAA,EAAA,GAAA,IAAA,CAAK,QAAL,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAe,MAAS,IAAA;AAAA,IAC1B,QAAA,EAAU,KAAK,QAAS,CAAA,GAAA,CAAI,OAAK,SAAU,CAAA,CAAA,EAAG,IAAK,CAAA,EAAE,CAAC;AAAA,MACpD,EAAC,CAAA;AAET;AAGO,SAAS,YAAY,IAAmC,EAAA;AAvZ/D,EAAA,IAAA,EAAA;AAwZE,EAAA,IAAI,WAAW,QAAS,CAAA,IAAA,CAAK,IAAI,CAAA,SAAU,IAAK,CAAA,EAAA;AAChD,EAAA,KAAA,MAAW,CAAK,IAAA,CAAA,EAAA,GAAA,IAAA,CAAK,QAAL,KAAA,IAAA,GAAA,EAAA,GAAiB,EAAI,EAAA;AACnC,IAAM,MAAA,GAAA,GAAM,YAAY,CAAC,CAAA;AACzB,IAAA,IAAI,KAAY,OAAA,GAAA;AAAA;AAElB,EAAO,OAAA,IAAA;AACT"}
|
|
1
|
+
{"version":3,"file":"notionEditorModel.js","sources":["../../../src/features/notion/notionEditorModel.ts"],"sourcesContent":["/**\n * Local, optimistic model of an open page for the native editor: blocks by\n * id plus each parent's ordered child ids. Edits apply here first and are\n * sent to the server in the background, so typing never waits on the network.\n *\n * Pure: no RN imports, so it runs under jest as-is.\n */\nimport { isPageBlock, type NotionBlock, type NotionBlockTree } from './notionBlocks';\nimport { runsText, type RichRun } from './notionRichTitle';\nimport { titleRunsOf } from './notionRichText';\n\nexport interface EditorBlock {\n id: string;\n type: string;\n parentId: string;\n /** Plain text of `runs` (what the TextInput edits). */\n text: string;\n /** Formatted runs of the title (bold, colours, links, mentions) - what is saved. */\n runs: RichRun[];\n properties: Record<string, unknown>;\n}\n\nexport interface EditorModel {\n rootId: string;\n blocks: Record<string, EditorBlock>;\n children: Record<string, string[]>;\n}\n\nexport interface EditorLine {\n block: EditorBlock;\n depth: number;\n number?: number;\n}\n\n/** Block types the editor edits as text. */\nexport const TEXT_TYPES: readonly string[] = [\n 'paragraph',\n 'text',\n 'heading_1',\n 'heading_2',\n 'heading_3',\n 'bulleted_list',\n 'numbered_list',\n 'todo',\n 'toggle',\n 'quote',\n 'callout',\n 'code',\n];\n\n/** Types a block can be turned into from the editor toolbar (web slash menu basics). */\nexport const TURN_INTO: ReadonlyArray<{ type: string; label: string; short: string }> = [\n { type: 'paragraph', label: 'Text', short: 'Aa' },\n { type: 'heading_1', label: 'Heading 1', short: 'H1' },\n { type: 'heading_2', label: 'Heading 2', short: 'H2' },\n { type: 'heading_3', label: 'Heading 3', short: 'H3' },\n { type: 'bulleted_list', label: 'Bulleted list', short: '•' },\n { type: 'numbered_list', label: 'Numbered list', short: '1.' },\n { type: 'todo', label: 'To-do', short: '☐' },\n { type: 'toggle', label: 'Toggle', short: '▸' },\n { type: 'quote', label: 'Quote', short: '❝' },\n { type: 'callout', label: 'Callout', short: '💡' },\n { type: 'code', label: 'Code', short: '</>' },\n];\n\nexport function isTextType(type: string): boolean {\n return TEXT_TYPES.includes(type);\n}\n\n/** Layout containers with no content of their own (web column_list / column). */\nexport const LAYOUT_TYPES: readonly string[] = ['column_list', 'column'];\n\n/** Return in a list / to-do continues it; anything else starts a paragraph. */\nexport function nextTypeAfter(type: string): string {\n return type === 'bulleted_list' || type === 'numbered_list' || type === 'todo' ? type : 'paragraph';\n}\n\n/**\n * `rootId` is the page id the caller already knows: the tree's root block can come back\n * without its fields on device (no id / title), and new top-level blocks are parented to it.\n */\nexport function modelFromTree(tree: NotionBlockTree, rootId: string = tree.block?.id): EditorModel {\n const model: EditorModel = { rootId, blocks: {}, children: {} };\n const walk = (nodes: readonly NotionBlockTree[] | null | undefined, parentId: string) => {\n const ids: string[] = [];\n (nodes ?? []).forEach((node) => {\n const b = node?.block;\n if (!b || b.inTrash || b.archived) return;\n ids.push(b.id);\n model.blocks[b.id] = toEditorBlock(b, parentId);\n if (!isPageBlock(b)) walk(node.children, b.id);\n });\n model.children[parentId] = ids;\n };\n walk(tree.children, rootId);\n return model;\n}\n\nexport function toEditorBlock(b: NotionBlock, parentId: string): EditorBlock {\n const runs = titleRunsOf(b.properties);\n return {\n id: b.id,\n // A block can arrive with no type (seen on pages the agent wrote). Every reader goes straight to\n // `block.type.startsWith`, so one such block took the whole page down instead of showing as text.\n type: typeof b.type === 'string' && b.type ? b.type : 'paragraph',\n parentId,\n text: runsText(runs),\n runs,\n properties: (b.properties ?? {}) as Record<string, unknown>,\n };\n}\n\n/** A fresh, empty block (local, before the server has it). */\nexport function emptyBlock(\n id: string,\n type: string,\n parentId: string,\n properties: Record<string, unknown>,\n): EditorBlock {\n return { id, type, parentId, text: '', runs: [], properties };\n}\n\n/**\n * Depth-first lines in reading order, numbering runs of numbered_list siblings. Children of a\n * toggle listed in `collapsed` are hidden (Notion toggles open on tap).\n */\nexport function flattenModel(model: EditorModel, collapsed: ReadonlySet<string> = new Set()): EditorLine[] {\n const lines: EditorLine[] = [];\n const walk = (parentId: string, depth: number) => {\n let run = 0;\n (model.children[parentId] ?? []).forEach((id) => {\n const block = model.blocks[id];\n if (!block) return;\n // Column layouts are transparent on a phone: their blocks read top to bottom at the\n // same indent (the web shows them side by side).\n if (LAYOUT_TYPES.includes(block.type)) {\n run = 0;\n walk(id, depth);\n return;\n }\n run = block.type === 'numbered_list' ? run + 1 : 0;\n lines.push({ block, depth, ...(block.type === 'numbered_list' ? { number: run } : {}) });\n if (!isPageBlock(block) && !(block.type === 'toggle' && collapsed.has(id))) walk(id, depth + 1);\n });\n };\n walk(model.rootId, 0);\n return lines;\n}\n\n/** Insert `block` under its parent right after `afterId` (end when absent or not found). */\nexport function insertAfter(model: EditorModel, block: EditorBlock, afterId?: string | null): EditorModel {\n const siblings = [...(model.children[block.parentId] ?? [])];\n const at = afterId ? siblings.indexOf(afterId) : -1;\n if (at >= 0) siblings.splice(at + 1, 0, block.id);\n else siblings.push(block.id);\n return {\n ...model,\n blocks: { ...model.blocks, [block.id]: block },\n children: { ...model.children, [block.parentId]: siblings },\n };\n}\n\n/** Remove a block and its subtree. */\nexport function removeBlock(model: EditorModel, id: string): EditorModel {\n const block = model.blocks[id];\n if (!block) return model;\n const blocks = { ...model.blocks };\n const children = { ...model.children };\n const drop = (bid: string) => {\n (children[bid] ?? []).forEach(drop);\n delete children[bid];\n delete blocks[bid];\n };\n drop(id);\n children[block.parentId] = (children[block.parentId] ?? []).filter((x) => x !== id);\n return { ...model, blocks, children };\n}\n\nexport function patchBlock(model: EditorModel, id: string, patch: Partial<EditorBlock>): EditorModel {\n const block = model.blocks[id];\n if (!block) return model;\n return { ...model, blocks: { ...model.blocks, [id]: { ...block, ...patch } } };\n}\n\n/** The line before `id` in reading order (where focus goes after deleting it). */\nexport function previousLineId(model: EditorModel, id: string): string | null {\n const lines = flattenModel(model);\n const at = lines.findIndex((l) => l.block.id === id);\n for (let i = at - 1; i >= 0; i -= 1) if (isTextType(lines[i].block.type)) return lines[i].block.id;\n return null;\n}\n\n/** Client-chosen block id (the server accepts `input.id` on create). */\nexport function newBlockId(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) return c.randomUUID();\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0;\n // eslint-disable-next-line no-bitwise\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n}\n\n/**\n * Move a block one place up or down among its siblings. Returns the new sibling order (to send\n * as reorderChildren) or null when it is already at that end.\n */\nexport function moveAmongSiblings(\n model: EditorModel,\n id: string,\n direction: -1 | 1,\n): { model: EditorModel; parentId: string; order: string[] } | null {\n const block = model.blocks[id];\n if (!block) return null;\n const siblings = [...(model.children[block.parentId] ?? [])];\n const at = siblings.indexOf(id);\n const to = at + direction;\n if (at < 0 || to < 0 || to >= siblings.length) return null;\n [siblings[at], siblings[to]] = [siblings[to], siblings[at]];\n return {\n model: { ...model, children: { ...model.children, [block.parentId]: siblings } },\n parentId: block.parentId,\n order: siblings,\n };\n}\n\n/** A removed block with everything under it and where it sat - what Undo puts back. */\nexport interface SubtreeSnapshot {\n id: string;\n parentId: string;\n index: number;\n blocks: Record<string, EditorBlock>;\n children: Record<string, string[]>;\n}\n\nexport function snapshotSubtree(model: EditorModel, id: string): SubtreeSnapshot | null {\n const block = model.blocks[id];\n if (!block) return null;\n const blocks: Record<string, EditorBlock> = {};\n const children: Record<string, string[]> = {};\n const walk = (bid: string) => {\n const b = model.blocks[bid];\n if (!b) return;\n blocks[bid] = b;\n const kids = model.children[bid];\n if (kids) {\n children[bid] = [...kids];\n kids.forEach(walk);\n }\n };\n walk(id);\n const index = (model.children[block.parentId] ?? []).indexOf(id);\n return { id, parentId: block.parentId, index, blocks, children };\n}\n\n/** Put a snapshot back at its old position (clamped to the current siblings). */\nexport function restoreSubtree(model: EditorModel, snap: SubtreeSnapshot): EditorModel {\n const siblings = [...(model.children[snap.parentId] ?? [])].filter((x) => x !== snap.id);\n siblings.splice(Math.max(0, Math.min(snap.index, siblings.length)), 0, snap.id);\n return {\n ...model,\n blocks: { ...model.blocks, ...snap.blocks },\n children: { ...model.children, ...snap.children, [snap.parentId]: siblings },\n };\n}\n\n/** A block to create with its nested children (one appendChildren call, client ids). */\nexport interface NewBlockTree {\n id: string;\n type: string;\n properties: Record<string, unknown>;\n children?: NewBlockTree[];\n}\n\n/** Web \"N columns\": a column_list of N equal columns, each starting with an empty paragraph. */\nexport function columnLayout(n: number, newId: () => string = newBlockId): NewBlockTree {\n const ratio = Math.round((1 / n) * 1000) / 1000;\n return {\n id: newId(),\n type: 'column_list',\n properties: {},\n children: Array.from({ length: n }, () => ({\n id: newId(),\n type: 'column',\n properties: { widthRatio: ratio },\n children: [{ id: newId(), type: 'paragraph', properties: { title: [] } }],\n })),\n };\n}\n\n/** Insert a new block tree locally (after `afterId` under `parentId`). */\nexport function insertTree(\n model: EditorModel,\n tree: NewBlockTree,\n parentId: string,\n afterId?: string | null,\n): EditorModel {\n let next = insertAfter(model, emptyBlock(tree.id, tree.type, parentId, tree.properties), afterId);\n let last: string | null = null;\n (tree.children ?? []).forEach((child) => {\n next = insertTree(next, child, tree.id, last);\n last = child.id;\n });\n if (!(tree.children ?? []).length)\n next = { ...next, children: { ...next.children, [tree.id]: next.children[tree.id] ?? [] } };\n return next;\n}\n\n/** The appendChildren input for a tree (children carry their own parent refs). */\nexport function treeInput(tree: NewBlockTree, parentId: string): Record<string, unknown> {\n return {\n id: tree.id,\n type: tree.type,\n parent: { type: 'block', id: parentId },\n properties: tree.properties,\n ...(tree.children?.length ? { children: tree.children.map((c) => treeInput(c, tree.id)) } : {}),\n };\n}\n\n/** First text block inside a tree (where the caret goes after inserting columns). */\nexport function firstTextId(tree: NewBlockTree): string | null {\n if (TEXT_TYPES.includes(tree.type)) return tree.id;\n for (const c of tree.children ?? []) {\n const hit = firstTextId(c);\n if (hit) return hit;\n }\n return null;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCO,MAAM,UAAgC,GAAA,CAAC,WAAa,EAAA,MAAA,EAAQ,WAAa,EAAA,WAAA,EAAa,WAAa,EAAA,eAAA,EAAiB,eAAiB,EAAA,MAAA,EAAQ,QAAU,EAAA,OAAA,EAAS,WAAW,MAAM;AAGjL,MAAM,YAIR,CAAC;AAAA,EACJ,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,MAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAG,EAAA;AAAA,EACD,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,WAAA;A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SAAU,IAAK,CAAA,EAAA;AAChD,EAAA,KAAA,MAAW,CAAK,IAAA,CAAA,EAAA,GAAA,IAAA,CAAK,QAAL,KAAA,IAAA,GAAA,EAAA,GAAiB,EAAI,EAAA;AACnC,IAAM,MAAA,GAAA,GAAM,YAAY,CAAC,CAAA;AACzB,IAAA,IAAI,KAAY,OAAA,GAAA;AAAA;AAElB,EAAO,OAAA,IAAA;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx}from'react/jsx-runtime';import {useLayoutEffect,useCallback,useEffect}from'react';import {SafeAreaView}from'react-native-safe-area-context';import {Alert,StyleSheet}from'react-native';import {useNavigation,useRoute}from'@react-navigation/native';import'../../features/games/vendored/core/engine/palette.js';import'../../features/games/vendored/core/lessons/lessons.js';import'../../features/games/vendored/core/cubeforge/items.js';import'../../features/games/vendored/core/cubeforge/recipes.js';import {YantraGames}from'../../features/games/vendored/ui/GamesRoot.js';import
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import {useLayoutEffect,useCallback,useEffect}from'react';import {SafeAreaView}from'react-native-safe-area-context';import {Alert,StyleSheet}from'react-native';import {useNavigation,useRoute}from'@react-navigation/native';import'../../features/games/vendored/core/engine/palette.js';import'../../features/games/vendored/core/lessons/lessons.js';import'../../features/games/vendored/core/cubeforge/items.js';import'../../features/games/vendored/core/cubeforge/recipes.js';import {YantraGames}from'../../features/games/vendored/ui/GamesRoot.js';import {cubeforgeFriendsSupported,cubeforge3DComponent,deleteCubeforgeSave}from'../../features/games/cubeforge3D.js';import {useCubeforgeFriends}from'../../features/games/useCubeforgeFriends.js';import {config}from'../../config/env-config.js';import {usePrerequisiteIds}from'../../hooks/usePrerequisiteIds.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -74,8 +74,8 @@ const HOME_SUGGESTIONS = [{
|
|
|
74
74
|
id: "notion",
|
|
75
75
|
icon: "notebook-outline",
|
|
76
76
|
label: "Write it up in Notion",
|
|
77
|
-
hint: "Findings land as a
|
|
78
|
-
prompt: "Research [a topic] and write the findings up as a Notion
|
|
77
|
+
hint: "Findings land as a page in Yantra Notion",
|
|
78
|
+
prompt: "Research [a topic] and write the findings up as a page in Yantra Notion with sources.",
|
|
79
79
|
blanks: [{
|
|
80
80
|
ask: "What topic?",
|
|
81
81
|
suggestions: ["the four-day work week", "onboarding remote teams", "home solar payback"]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homeCatalog.js","sources":["../../../../src/screens/Home/components/homeCatalog.ts"],"sourcesContent":["/**\n * The chat home's pure parts, kept apart from the components so they run under jest: the\n * \"Start something\" catalogue and draw (the web's YANTRA_SUGGESTIONS / useHomeSuggestions) and\n * the greeting (the web's HomeHero `greetingFor`).\n */\nimport type { ComponentProps } from 'react';\nimport type { MaterialCommunityIcons } from '@expo/vector-icons';\nimport type { BlankGuide } from '../../../features/chat/promptBlanks';\nimport type { RoutingMode } from '../types';\n\ntype IconName = ComponentProps<typeof MaterialCommunityIcons>['name'];\n\nexport type HomeSuggestion = {\n id: string;\n label: string;\n /** What the row is for, on the line under its label. */\n hint: string;\n icon: IconName;\n prompt: string;\n mode?: RoutingMode;\n /** Navigate here instead of injecting the prompt, when the host wires navigation. */\n nativeRoute?: string;\n /**\n * The app this shortcut is for: a registry intent id, the one the brain answers with\n * (the web's `panel`). Chat opens it when the brain names no other app for the send.\n */\n app?: string;\n /** For each `[blank]` in the prompt, in order: what to ask, and answers one tap away. */\n blanks?: readonly BlankGuide[];\n};\n\n/** The web's YANTRA_SUGGESTIONS, in its order. */\nexport const HOME_SUGGESTIONS: readonly HomeSuggestion[] = [\n {\n id: 'design',\n icon: 'palette-outline',\n label: 'Design a landing page',\n hint: 'Chat-driven design canvas — iterate on a real page, not a mockup',\n prompt: 'Design a landing page for [your product]. Start with the hero and the pricing section.',\n blanks: [\n {\n ask: \"What's the product?\",\n suggestions: ['a dog-walking app', 'a coffee subscription', 'a yoga studio'],\n },\n ],\n app: 'design',\n },\n {\n id: 'webbuilder',\n icon: 'web',\n label: 'Build a working web app',\n hint: 'Scaffold and edit a real app from a prompt',\n prompt: 'Build me a small web app with a form that stores submissions and a page that lists them.',\n app: 'webbuilder',\n },\n {\n id: 'poster',\n icon: 'post-outline',\n label: 'Turn a paper into a poster',\n hint: 'A paper PDF or arXiv link → an editable, print-ready conference poster',\n prompt: 'Turn [arXiv link or paper title] into a 48 x 36 inch conference poster I can edit and print.',\n blanks: [{ ask: 'Paste the arXiv link or paper title' }],\n app: 'poster',\n },\n {\n id: 'canvas',\n icon: 'view-grid-outline',\n label: 'Open a canvas',\n hint: 'Spread images, video and audio out and work on them together',\n prompt: 'Open a canvas and help me lay out the assets for this project.',\n nativeRoute: 'MainStack.CanvasNative',\n },\n {\n id: 'workflow',\n icon: 'sitemap-outline',\n label: 'Automate something repetitive',\n hint: 'A visual workflow across 1,000+ connectors',\n prompt: 'Build a workflow that runs every morning and sends me a summary of [what to keep an eye on].',\n blanks: [\n {\n ask: 'What should it summarize?',\n suggestions: ['new support emails', 'overnight sales', \"today's calendar\"],\n },\n ],\n app: 'workflow-studio',\n },\n {\n id: 'computer',\n icon: 'monitor',\n label: 'Drive my browser',\n hint: 'The CLI runs your OS and browser for you',\n prompt: 'Open my browser, find the pricing pages of [3 competitors], and put them side by side.',\n blanks: [{ ask: 'Which 3 competitors?' }],\n },\n {\n id: 'connect-apps',\n icon: 'puzzle-outline',\n label: 'Connect your apps',\n hint: 'Link a tool once, then just @-mention it in any chat',\n prompt: 'Show me which apps I can connect, and help me connect the ones I use daily.',\n },\n {\n id: 'research',\n icon: 'magnify',\n label: 'Research a market',\n hint: 'Deep multi-source research, written up',\n prompt: 'Research the market for [your idea] - who the players are, how they price, and where the gaps are.',\n blanks: [\n {\n ask: \"What's the idea?\",\n suggestions: ['a dog-walking app', 'an AI tutor for kids', 'a meal-prep service'],\n },\n ],\n mode: 'deep-search',\n },\n {\n id: 'notion',\n icon: 'notebook-outline',\n label: 'Write it up in Notion',\n hint: 'Findings land as a real Notion page',\n prompt: 'Research [a topic] and write the findings up as a Notion page with sources.',\n blanks: [\n {\n ask: 'What topic?',\n suggestions: ['the four-day work week', 'onboarding remote teams', 'home solar payback'],\n },\n ],\n app: 'notion',\n },\n {\n id: 'shopping',\n icon: 'shopping-outline',\n label: 'Compare products',\n hint: 'Search across sources and line them up',\n prompt: 'Compare the best [product] options and show me the tradeoffs.',\n blanks: [\n {\n ask: 'What are you shopping for?',\n suggestions: ['noise-cancelling headphones', 'robot vacuums', 'carry-on luggage'],\n },\n ],\n app: 'shopping',\n },\n {\n id: 'travel',\n icon: 'airplane',\n label: 'Plan a trip',\n hint: 'Flights, hotels and a day-by-day plan',\n prompt: 'Plan a 4-day trip to [destination] for me - flights, somewhere to stay, and what to do each day.',\n blanks: [{ ask: 'Where to?', suggestions: ['Lisbon', 'Tokyo', 'Mexico City', 'Reykjavik'] }],\n app: 'travel',\n },\n {\n id: 'meetings',\n icon: 'microphone-outline',\n label: 'Send a notetaker to a meeting',\n hint: 'Records, transcribes, and writes the notes up',\n prompt: 'Send the notetaker to my next meeting and write up the notes and action items afterwards.',\n app: 'meetings',\n },\n {\n id: 'inbox',\n icon: 'inbox-outline',\n label: 'Get to inbox zero',\n hint: 'Triage the inbox and draft the replies',\n prompt: 'Go through my inbox, tell me what actually needs a reply, and draft those replies.',\n app: 'inbox',\n },\n {\n id: 'crm',\n icon: 'account-group-outline',\n label: 'Chase my pipeline',\n hint: 'See what is stalling and what to do next',\n prompt: 'Look at my pipeline and tell me which deals are going cold and what I should send them.',\n app: 'crm',\n },\n {\n id: 'invoices',\n icon: 'file-document-outline',\n label: 'Get paid',\n hint: 'Invoice a customer and see what is still owed',\n prompt: 'Show me which invoices are unpaid, and send a reminder for the overdue ones.',\n app: 'invoices',\n },\n {\n id: 'expenses',\n icon: 'receipt',\n label: 'Sort out expenses',\n hint: 'Claims, budgets, and card spend in one place',\n prompt: 'Summarise my spend this month and flag anything unusual.',\n app: 'expenses',\n },\n {\n id: 'mailcampaign',\n icon: 'bullhorn-outline',\n label: 'Send a campaign',\n hint: 'Write it, segment it, send it',\n prompt: 'Draft an email campaign announcing [what you shipped or launched].',\n blanks: [\n { ask: 'What did you launch?', suggestions: ['our new mobile app', 'a spring sale', 'a new pricing plan'] },\n ],\n app: 'mailcampaign',\n },\n {\n id: 'smscampaign',\n icon: 'message-text-outline',\n label: 'Text your customers',\n hint: 'SMS campaigns with replies',\n prompt: \"Write a short text reminding my customers about [this week's offer], then send it to my VIP list.\",\n blanks: [\n {\n ask: \"What's the offer?\",\n suggestions: ['20% off this weekend', 'free shipping until Sunday', 'buy one, get one free'],\n },\n ],\n app: 'smscampaign',\n },\n];\n\n/** `count` distinct entries, drawn at random (the web's draw, without its welcome-answer weights). */\nexport function drawSuggestions(\n count: number,\n pool: readonly HomeSuggestion[] = HOME_SUGGESTIONS,\n random: () => number = Math.random,\n): HomeSuggestion[] {\n const remaining = [...pool];\n const picked: HomeSuggestion[] = [];\n while (picked.length < count && remaining.length > 0) {\n picked.push(remaining.splice(Math.floor(random() * remaining.length), 1)[0]);\n }\n return picked;\n}\n\n/** Same boundaries as the web's `greetingFor`; anything past ten at night reads as late. */\nexport function greetingFor(hour: number): string {\n if (hour >= 5 && hour < 12) return 'Good morning';\n if (hour >= 12 && hour < 17) return 'Good afternoon';\n if (hour >= 17 && hour < 22) return 'Good evening';\n return 'Working late';\n}\n"],"names":[],"mappings":"AA8BO,MAAM,mBAA8C,CAAC;AAAA,EAC1D,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA,iBAAA;AAAA,EACN,KAAO,EAAA,uBAAA;AAAA,EACP,IAAM,EAAA,uEAAA;AAAA,EACN,MAAQ,EAAA,wFAAA;AAAA,EACR,QAAQ,CAAC;AAAA,IACP,GA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IAAQ,IAAA,CAAA,IAAK,IAAO,GAAA,EAAA,EAAW,OAAA,cAAA;AACnC,EAAA,IAAI,IAAQ,IAAA,EAAA,IAAM,IAAO,GAAA,EAAA,EAAW,OAAA,gBAAA;AACpC,EAAA,IAAI,IAAQ,IAAA,EAAA,IAAM,IAAO,GAAA,EAAA,EAAW,OAAA,cAAA;AACpC,EAAO,OAAA,cAAA;AACT"}
|
|
1
|
+
{"version":3,"file":"homeCatalog.js","sources":["../../../../src/screens/Home/components/homeCatalog.ts"],"sourcesContent":["/**\n * The chat home's pure parts, kept apart from the components so they run under jest: the\n * \"Start something\" catalogue and draw (the web's YANTRA_SUGGESTIONS / useHomeSuggestions) and\n * the greeting (the web's HomeHero `greetingFor`).\n */\nimport type { ComponentProps } from 'react';\nimport type { MaterialCommunityIcons } from '@expo/vector-icons';\nimport type { BlankGuide } from '../../../features/chat/promptBlanks';\nimport type { RoutingMode } from '../types';\n\ntype IconName = ComponentProps<typeof MaterialCommunityIcons>['name'];\n\nexport type HomeSuggestion = {\n id: string;\n label: string;\n /** What the row is for, on the line under its label. */\n hint: string;\n icon: IconName;\n prompt: string;\n mode?: RoutingMode;\n /** Navigate here instead of injecting the prompt, when the host wires navigation. */\n nativeRoute?: string;\n /**\n * The app this shortcut is for: a registry intent id, the one the brain answers with\n * (the web's `panel`). Chat opens it when the brain names no other app for the send.\n */\n app?: string;\n /** For each `[blank]` in the prompt, in order: what to ask, and answers one tap away. */\n blanks?: readonly BlankGuide[];\n};\n\n/** The web's YANTRA_SUGGESTIONS, in its order. */\nexport const HOME_SUGGESTIONS: readonly HomeSuggestion[] = [\n {\n id: 'design',\n icon: 'palette-outline',\n label: 'Design a landing page',\n hint: 'Chat-driven design canvas — iterate on a real page, not a mockup',\n prompt: 'Design a landing page for [your product]. Start with the hero and the pricing section.',\n blanks: [\n {\n ask: \"What's the product?\",\n suggestions: ['a dog-walking app', 'a coffee subscription', 'a yoga studio'],\n },\n ],\n app: 'design',\n },\n {\n id: 'webbuilder',\n icon: 'web',\n label: 'Build a working web app',\n hint: 'Scaffold and edit a real app from a prompt',\n prompt: 'Build me a small web app with a form that stores submissions and a page that lists them.',\n app: 'webbuilder',\n },\n {\n id: 'poster',\n icon: 'post-outline',\n label: 'Turn a paper into a poster',\n hint: 'A paper PDF or arXiv link → an editable, print-ready conference poster',\n prompt: 'Turn [arXiv link or paper title] into a 48 x 36 inch conference poster I can edit and print.',\n blanks: [{ ask: 'Paste the arXiv link or paper title' }],\n app: 'poster',\n },\n {\n id: 'canvas',\n icon: 'view-grid-outline',\n label: 'Open a canvas',\n hint: 'Spread images, video and audio out and work on them together',\n prompt: 'Open a canvas and help me lay out the assets for this project.',\n nativeRoute: 'MainStack.CanvasNative',\n },\n {\n id: 'workflow',\n icon: 'sitemap-outline',\n label: 'Automate something repetitive',\n hint: 'A visual workflow across 1,000+ connectors',\n prompt: 'Build a workflow that runs every morning and sends me a summary of [what to keep an eye on].',\n blanks: [\n {\n ask: 'What should it summarize?',\n suggestions: ['new support emails', 'overnight sales', \"today's calendar\"],\n },\n ],\n app: 'workflow-studio',\n },\n {\n id: 'computer',\n icon: 'monitor',\n label: 'Drive my browser',\n hint: 'The CLI runs your OS and browser for you',\n prompt: 'Open my browser, find the pricing pages of [3 competitors], and put them side by side.',\n blanks: [{ ask: 'Which 3 competitors?' }],\n },\n {\n id: 'connect-apps',\n icon: 'puzzle-outline',\n label: 'Connect your apps',\n hint: 'Link a tool once, then just @-mention it in any chat',\n prompt: 'Show me which apps I can connect, and help me connect the ones I use daily.',\n },\n {\n id: 'research',\n icon: 'magnify',\n label: 'Research a market',\n hint: 'Deep multi-source research, written up',\n prompt: 'Research the market for [your idea] - who the players are, how they price, and where the gaps are.',\n blanks: [\n {\n ask: \"What's the idea?\",\n suggestions: ['a dog-walking app', 'an AI tutor for kids', 'a meal-prep service'],\n },\n ],\n mode: 'deep-search',\n },\n {\n id: 'notion',\n icon: 'notebook-outline',\n label: 'Write it up in Notion',\n hint: 'Findings land as a page in Yantra Notion',\n prompt: 'Research [a topic] and write the findings up as a page in Yantra Notion with sources.',\n blanks: [\n {\n ask: 'What topic?',\n suggestions: ['the four-day work week', 'onboarding remote teams', 'home solar payback'],\n },\n ],\n app: 'notion',\n },\n {\n id: 'shopping',\n icon: 'shopping-outline',\n label: 'Compare products',\n hint: 'Search across sources and line them up',\n prompt: 'Compare the best [product] options and show me the tradeoffs.',\n blanks: [\n {\n ask: 'What are you shopping for?',\n suggestions: ['noise-cancelling headphones', 'robot vacuums', 'carry-on luggage'],\n },\n ],\n app: 'shopping',\n },\n {\n id: 'travel',\n icon: 'airplane',\n label: 'Plan a trip',\n hint: 'Flights, hotels and a day-by-day plan',\n prompt: 'Plan a 4-day trip to [destination] for me - flights, somewhere to stay, and what to do each day.',\n blanks: [{ ask: 'Where to?', suggestions: ['Lisbon', 'Tokyo', 'Mexico City', 'Reykjavik'] }],\n app: 'travel',\n },\n {\n id: 'meetings',\n icon: 'microphone-outline',\n label: 'Send a notetaker to a meeting',\n hint: 'Records, transcribes, and writes the notes up',\n prompt: 'Send the notetaker to my next meeting and write up the notes and action items afterwards.',\n app: 'meetings',\n },\n {\n id: 'inbox',\n icon: 'inbox-outline',\n label: 'Get to inbox zero',\n hint: 'Triage the inbox and draft the replies',\n prompt: 'Go through my inbox, tell me what actually needs a reply, and draft those replies.',\n app: 'inbox',\n },\n {\n id: 'crm',\n icon: 'account-group-outline',\n label: 'Chase my pipeline',\n hint: 'See what is stalling and what to do next',\n prompt: 'Look at my pipeline and tell me which deals are going cold and what I should send them.',\n app: 'crm',\n },\n {\n id: 'invoices',\n icon: 'file-document-outline',\n label: 'Get paid',\n hint: 'Invoice a customer and see what is still owed',\n prompt: 'Show me which invoices are unpaid, and send a reminder for the overdue ones.',\n app: 'invoices',\n },\n {\n id: 'expenses',\n icon: 'receipt',\n label: 'Sort out expenses',\n hint: 'Claims, budgets, and card spend in one place',\n prompt: 'Summarise my spend this month and flag anything unusual.',\n app: 'expenses',\n },\n {\n id: 'mailcampaign',\n icon: 'bullhorn-outline',\n label: 'Send a campaign',\n hint: 'Write it, segment it, send it',\n prompt: 'Draft an email campaign announcing [what you shipped or launched].',\n blanks: [\n { ask: 'What did you launch?', suggestions: ['our new mobile app', 'a spring sale', 'a new pricing plan'] },\n ],\n app: 'mailcampaign',\n },\n {\n id: 'smscampaign',\n icon: 'message-text-outline',\n label: 'Text your customers',\n hint: 'SMS campaigns with replies',\n prompt: \"Write a short text reminding my customers about [this week's offer], then send it to my VIP list.\",\n blanks: [\n {\n ask: \"What's the offer?\",\n suggestions: ['20% off this weekend', 'free shipping until Sunday', 'buy one, get one free'],\n },\n ],\n app: 'smscampaign',\n },\n];\n\n/** `count` distinct entries, drawn at random (the web's draw, without its welcome-answer weights). */\nexport function drawSuggestions(\n count: number,\n pool: readonly HomeSuggestion[] = HOME_SUGGESTIONS,\n random: () => number = Math.random,\n): HomeSuggestion[] {\n const remaining = [...pool];\n const picked: HomeSuggestion[] = [];\n while (picked.length < count && remaining.length > 0) {\n picked.push(remaining.splice(Math.floor(random() * remaining.length), 1)[0]);\n }\n return picked;\n}\n\n/** Same boundaries as the web's `greetingFor`; anything past ten at night reads as late. */\nexport function greetingFor(hour: number): string {\n if (hour >= 5 && hour < 12) return 'Good morning';\n if (hour >= 12 && hour < 17) return 'Good afternoon';\n if (hour >= 17 && hour < 22) return 'Good evening';\n return 'Working late';\n}\n"],"names":[],"mappings":"AA8BO,MAAM,mBAA8C,CAAC;AAAA,EAC1D,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA,iBAAA;AAAA,EACN,KAAO,EAAA,uBAAA;AAAA,EACP,IAAM,EAAA,uEAAA;AAAA,EACN,MAAQ,EAAA,wFAAA;AAAA,EACR,QAAQ,CAAC;AAAA,IACP,GAAK,EAAA,qBAAA;AAAA,IACL,WAAa,EAAA,CAAC,mBAAqB,EAAA,uBAAA,EAAyB,eAAe;AAAA,GAC5E,CAAA;AAAA,EACD,GAAK,EAAA;AACP,CAAG,E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gBAAA;AACpC,EAAA,IAAI,IAAQ,IAAA,EAAA,IAAM,IAAO,GAAA,EAAA,EAAW,OAAA,cAAA;AACpC,EAAO,OAAA,cAAA;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminide-stack/yantra-mobile",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.173",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"uuid": "^9.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"common": "12.0.170
|
|
30
|
+
"common": "12.0.170",
|
|
31
31
|
"libphonenumber-js": "^1.13.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@messenger-box/platform-mobile": "*",
|
|
46
46
|
"@react-native-async-storage/async-storage": "*",
|
|
47
47
|
"@react-navigation/native": "*",
|
|
48
|
-
"common": "12.0.170
|
|
48
|
+
"common": "12.0.170",
|
|
49
49
|
"expo-background-task": "*",
|
|
50
50
|
"expo-constants": "*",
|
|
51
51
|
"expo-secure-store": "*",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"typescript": {
|
|
68
68
|
"definition": "lib/index.d.ts"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "e45db4cb7a39f7187564f7e99004fb1d4b4f99e2"
|
|
71
71
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
const PERMISSION_LEVELS = ["visitor", "member", "operator"];
|
|
21
|
-
const PERMISSION_LABELS = {
|
|
22
|
-
visitor: "Visitor",
|
|
23
|
-
member: "Member",
|
|
24
|
-
operator: "Operator"
|
|
25
|
-
};
|
|
26
|
-
const PERMISSION_DESCRIPTIONS = {
|
|
27
|
-
visitor: "Can look around and interact, but cannot build.",
|
|
28
|
-
member: "Can build, break, and use items.",
|
|
29
|
-
operator: "Full control: build anywhere, teleport, use commands, and manage others."
|
|
30
|
-
};
|
|
31
|
-
function baseCapabilities(level) {
|
|
32
|
-
switch (level) {
|
|
33
|
-
case "visitor":
|
|
34
|
-
return {
|
|
35
|
-
canInteract: true,
|
|
36
|
-
canBuild: false,
|
|
37
|
-
canUseItems: false,
|
|
38
|
-
canTeleport: false,
|
|
39
|
-
canUseCommands: false,
|
|
40
|
-
canManagePermissions: false
|
|
41
|
-
};
|
|
42
|
-
case "member":
|
|
43
|
-
return {
|
|
44
|
-
canInteract: true,
|
|
45
|
-
canBuild: true,
|
|
46
|
-
canUseItems: true,
|
|
47
|
-
canTeleport: false,
|
|
48
|
-
canUseCommands: false,
|
|
49
|
-
canManagePermissions: false
|
|
50
|
-
};
|
|
51
|
-
case "operator":
|
|
52
|
-
return {
|
|
53
|
-
canInteract: true,
|
|
54
|
-
canBuild: true,
|
|
55
|
-
canUseItems: true,
|
|
56
|
-
canTeleport: true,
|
|
57
|
-
canUseCommands: true,
|
|
58
|
-
canManagePermissions: true
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function effectiveCapabilities(level, settings) {
|
|
63
|
-
const caps = baseCapabilities(level);
|
|
64
|
-
if (settings.immutableWorld && level !== "operator") {
|
|
65
|
-
return __spreadProps(__spreadValues({}, caps), {
|
|
66
|
-
canBuild: false
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return caps;
|
|
70
|
-
}
|
|
71
|
-
function defaultPermissionModel() {
|
|
72
|
-
return {
|
|
73
|
-
hostEnabled: false,
|
|
74
|
-
defaultLevel: "member"
|
|
75
|
-
};
|
|
76
|
-
}export{PERMISSION_DESCRIPTIONS,PERMISSION_LABELS,PERMISSION_LEVELS,baseCapabilities,defaultPermissionModel,effectiveCapabilities};//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sources":["../../../../../../src/features/games/vendored/core/classroom/permissions.ts"],"sourcesContent":["/**\n * Player permission model.\n *\n * A world host can set a default permission level for players who join, and each\n * level grants a fixed set of capabilities. \"Immutable world\" additionally\n * removes build rights from everyone below Operator, so a teacher can lock a\n * world for a demo while keeping their own ability to edit it.\n */\n\nimport type { WorldSettings } from './worldSettings';\n\nexport type PermissionLevel = 'visitor' | 'member' | 'operator';\n\nexport const PERMISSION_LEVELS: readonly PermissionLevel[] = ['visitor', 'member', 'operator'];\n\nexport const PERMISSION_LABELS: Record<PermissionLevel, string> = {\n visitor: 'Visitor',\n member: 'Member',\n operator: 'Operator',\n};\n\nexport const PERMISSION_DESCRIPTIONS: Record<PermissionLevel, string> = {\n visitor: 'Can look around and interact, but cannot build.',\n member: 'Can build, break, and use items.',\n operator: 'Full control: build anywhere, teleport, use commands, and manage others.',\n};\n\nexport interface Capabilities {\n /** Interact with blocks (buttons, doors) without changing the world. */\n canInteract: boolean;\n /** Place and break blocks. */\n canBuild: boolean;\n /** Use items from the palette. */\n canUseItems: boolean;\n canTeleport: boolean;\n canUseCommands: boolean;\n canManagePermissions: boolean;\n}\n\nexport function baseCapabilities(level: PermissionLevel): Capabilities {\n switch (level) {\n case 'visitor':\n return {\n canInteract: true,\n canBuild: false,\n canUseItems: false,\n canTeleport: false,\n canUseCommands: false,\n canManagePermissions: false,\n };\n case 'member':\n return {\n canInteract: true,\n canBuild: true,\n canUseItems: true,\n canTeleport: false,\n canUseCommands: false,\n canManagePermissions: false,\n };\n case 'operator':\n return {\n canInteract: true,\n canBuild: true,\n canUseItems: true,\n canTeleport: true,\n canUseCommands: true,\n canManagePermissions: true,\n };\n }\n}\n\n/** Capabilities after world rules are applied (e.g. immutable world). */\nexport function effectiveCapabilities(level: PermissionLevel, settings: WorldSettings): Capabilities {\n const caps = baseCapabilities(level);\n if (settings.immutableWorld && level !== 'operator') {\n return { ...caps, canBuild: false };\n }\n return caps;\n}\n\nexport interface PermissionModel {\n /** Whether the host has opened the world for others to join. */\n hostEnabled: boolean;\n /** The permission level assigned to players by default. */\n defaultLevel: PermissionLevel;\n}\n\nexport function defaultPermissionModel(): PermissionModel {\n return { hostEnabled: false, defaultLevel: 'member' };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAAgD,GAAA,CAAC,SAAW,EAAA,QAAA,EAAU,UAAU;AACtF,MAAM,iBAAqD,GAAA;AAAA,EAChE,OAAS,EAAA,SAAA;AAAA,EACT,MAAQ,EAAA,QAAA;AAAA,EACR,QAAU,EAAA;AACZ;AACO,MAAM,uBAA2D,GAAA;AAAA,EACtE,OAAS,EAAA,iDAAA;AAAA,EACT,MAAQ,EAAA,kCAAA;AAAA,EACR,QAAU,EAAA;AACZ;AAYO,SAAS,iBAAiB,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 48;
|
|
3
|
-
function emptyResourceLink() {
|
|
4
|
-
return {
|
|
5
|
-
buttonName: "",
|
|
6
|
-
url: ""
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
const ALLOWED_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
10
|
-
function validateResourceLinkUrl(raw) {
|
|
11
|
-
const trimmed = raw.trim();
|
|
12
|
-
if (trimmed === "") return {
|
|
13
|
-
ok: true,
|
|
14
|
-
url: "",
|
|
15
|
-
empty: true
|
|
16
|
-
};
|
|
17
|
-
if (trimmed.length > RESOURCE_LINK_MAX_URL) {
|
|
18
|
-
return {
|
|
19
|
-
ok: false,
|
|
20
|
-
code: "too-long",
|
|
21
|
-
message: `Link must be ${RESOURCE_LINK_MAX_URL} characters or fewer.`
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
let parsed;
|
|
25
|
-
try {
|
|
26
|
-
parsed = new URL(trimmed);
|
|
27
|
-
} catch (e) {
|
|
28
|
-
return {
|
|
29
|
-
ok: false,
|
|
30
|
-
code: "invalid-url",
|
|
31
|
-
message: "Enter a full web address, like https://example.com/page."
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if (!ALLOWED_SCHEMES.has(parsed.protocol)) {
|
|
35
|
-
return {
|
|
36
|
-
ok: false,
|
|
37
|
-
code: "unsupported-scheme",
|
|
38
|
-
message: "Only http and https links are allowed."
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const host = parsed.hostname.toLowerCase();
|
|
42
|
-
if (host === "") {
|
|
43
|
-
return {
|
|
44
|
-
ok: false,
|
|
45
|
-
code: "missing-host",
|
|
46
|
-
message: "The link is missing a website address."
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (isBlockedHost(host)) {
|
|
50
|
-
return {
|
|
51
|
-
ok: false,
|
|
52
|
-
code: "blocked-host",
|
|
53
|
-
message: "Internal and private addresses are not allowed for student links."
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
ok: true,
|
|
58
|
-
url: parsed.toString(),
|
|
59
|
-
empty: false
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function normalizeResourceLink(link) {
|
|
63
|
-
const validation = validateResourceLinkUrl(link.url);
|
|
64
|
-
const url = validation.ok && !validation.empty ? validation.url : "";
|
|
65
|
-
const buttonName = link.buttonName.trim().slice(0, RESOURCE_LINK_MAX_BUTTON_NAME);
|
|
66
|
-
return {
|
|
67
|
-
buttonName,
|
|
68
|
-
url
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function isBlockedHost(host) {
|
|
72
|
-
const h = host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
|
|
73
|
-
if (h === "localhost" || h.endsWith(".localhost")) return true;
|
|
74
|
-
if (h.endsWith(".local")) return true;
|
|
75
|
-
if (h === "::1" || h === "::" || h.startsWith("fe80:") || h.startsWith("fc") || h.startsWith("fd")) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
const v4 = parseIpv4(h);
|
|
79
|
-
if (v4) {
|
|
80
|
-
const [a, b] = v4;
|
|
81
|
-
if (a === 10) return true;
|
|
82
|
-
if (a === 127) return true;
|
|
83
|
-
if (a === 0) return true;
|
|
84
|
-
if (a === 169 && b === 254) return true;
|
|
85
|
-
if (a === 192 && b === 168) return true;
|
|
86
|
-
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
function parseIpv4(host) {
|
|
91
|
-
const parts = host.split(".");
|
|
92
|
-
if (parts.length !== 4) return null;
|
|
93
|
-
const octets = [];
|
|
94
|
-
for (const part of parts) {
|
|
95
|
-
if (!/^\d{1,3}$/.test(part)) return null;
|
|
96
|
-
const n = Number(part);
|
|
97
|
-
if (n > 255) return null;
|
|
98
|
-
octets.push(n);
|
|
99
|
-
}
|
|
100
|
-
return [octets[0], octets[1], octets[2], octets[3]];
|
|
101
|
-
}export{RESOURCE_LINK_MAX_BUTTON_NAME,RESOURCE_LINK_MAX_URL,emptyResourceLink,normalizeResourceLink,validateResourceLinkUrl};//# sourceMappingURL=resourceLink.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceLink.js","sources":["../../../../../../src/features/games/vendored/core/classroom/resourceLink.ts"],"sourcesContent":["/**\n * The teacher resource link.\n *\n * A teacher can set a button name plus a URL; students see that button in the\n * in-world menu and tapping it opens the link. The feature study of a comparable\n * classroom product found its UI shipped with NO scheme/host validation on this\n * field (only a 1024-char cap), leaving it to a native handler. Yantra Games\n * validates here, in shared logic, so an unsafe link can never be stored:\n *\n * - only http / https are accepted (javascript:, data:, file:, etc. are rejected);\n * - loopback, link-local, and private-network hosts are rejected so a link can\n * never point students at an internal/admin address;\n * - the URL is length-capped.\n */\n\nexport interface ResourceLink {\n /** Teacher-chosen button label. Empty => a sensible default label is shown. */\n buttonName: string;\n /** The URL to open. Empty => no resource-link button is shown. */\n url: string;\n}\n\nexport const RESOURCE_LINK_MAX_URL = 1024;\nexport const RESOURCE_LINK_MAX_BUTTON_NAME = 48;\nexport const RESOURCE_LINK_DEFAULT_BUTTON_NAME = 'Open Link';\n\nexport function emptyResourceLink(): ResourceLink {\n return { buttonName: '', url: '' };\n}\n\nexport type ResourceLinkErrorCode = 'too-long' | 'invalid-url' | 'unsupported-scheme' | 'missing-host' | 'blocked-host';\n\nexport type ResourceLinkValidation =\n | { ok: true; url: string; empty: boolean }\n | { ok: false; code: ResourceLinkErrorCode; message: string };\n\nconst ALLOWED_SCHEMES = new Set(['http:', 'https:']);\n\n/**\n * Validate a resource-link URL. An empty string is valid and means \"no link\".\n */\nexport function validateResourceLinkUrl(raw: string): ResourceLinkValidation {\n const trimmed = raw.trim();\n if (trimmed === '') return { ok: true, url: '', empty: true };\n\n if (trimmed.length > RESOURCE_LINK_MAX_URL) {\n return {\n ok: false,\n code: 'too-long',\n message: `Link must be ${RESOURCE_LINK_MAX_URL} characters or fewer.`,\n };\n }\n\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n return {\n ok: false,\n code: 'invalid-url',\n message: 'Enter a full web address, like https://example.com/page.',\n };\n }\n\n if (!ALLOWED_SCHEMES.has(parsed.protocol)) {\n return {\n ok: false,\n code: 'unsupported-scheme',\n message: 'Only http and https links are allowed.',\n };\n }\n\n const host = parsed.hostname.toLowerCase();\n if (host === '') {\n return { ok: false, code: 'missing-host', message: 'The link is missing a website address.' };\n }\n if (isBlockedHost(host)) {\n return {\n ok: false,\n code: 'blocked-host',\n message: 'Internal and private addresses are not allowed for student links.',\n };\n }\n\n return { ok: true, url: parsed.toString(), empty: false };\n}\n\n/** The label to show on the resource-link button. */\nexport function resourceLinkButtonLabel(link: ResourceLink): string {\n const name = link.buttonName.trim();\n return name === '' ? RESOURCE_LINK_DEFAULT_BUTTON_NAME : name;\n}\n\n/** Whether the resource link is set and valid (and therefore shown to students). */\nexport function isResourceLinkActive(link: ResourceLink): boolean {\n const result = validateResourceLinkUrl(link.url);\n return result.ok && !result.empty;\n}\n\n/**\n * Normalise a resource link for storage: a valid URL is canonicalised, the\n * button name is capped, and an invalid or empty URL collapses to \"no link\".\n */\nexport function normalizeResourceLink(link: ResourceLink): ResourceLink {\n const validation = validateResourceLinkUrl(link.url);\n const url = validation.ok && !validation.empty ? validation.url : '';\n const buttonName = link.buttonName.trim().slice(0, RESOURCE_LINK_MAX_BUTTON_NAME);\n return { buttonName, url };\n}\n\n/** Reject loopback, link-local, and private-network hosts. */\nfunction isBlockedHost(host: string): boolean {\n // Strip IPv6 brackets if present.\n const h = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host;\n\n if (h === 'localhost' || h.endsWith('.localhost')) return true;\n if (h.endsWith('.local')) return true;\n if (h === '::1' || h === '::' || h.startsWith('fe80:') || h.startsWith('fc') || h.startsWith('fd')) {\n return true;\n }\n\n const v4 = parseIpv4(h);\n if (v4) {\n const [a, b] = v4;\n if (a === 10) return true; // 10.0.0.0/8\n if (a === 127) return true; // loopback\n if (a === 0) return true; // 0.0.0.0/8\n if (a === 169 && b === 254) return true; // link-local\n if (a === 192 && b === 168) return true; // private\n if (a === 172 && b >= 16 && b <= 31) return true; // private\n }\n return false;\n}\n\n/** Parse a dotted IPv4 string into four octets, or null if it is not one. */\nfunction parseIpv4(host: string): [number, number, number, number] | null {\n const parts = host.split('.');\n if (parts.length !== 4) return null;\n const octets: number[] = [];\n for (const part of parts) {\n if (!/^\\d{1,3}$/.test(part)) return null;\n const n = Number(part);\n if (n > 255) return null;\n octets.push(n);\n }\n return [octets[0]!, octets[1]!, octets[2]!, octets[3]!];\n}\n"],"names":[],"mappings":"AAqBO,MAAM,qBAAwB,GAAA;AAC9B,MAAM,6BAAgC,GAAA;AAEtC,SAAS,iBAAkC,GAAA;AAChD,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,EAAA;AAAA,IACZ,GAAK,EAAA;AAAA,GACP;AACF;AAWA,MAAM,kCAAsB,IAAA,GAAA,CAAI,CAAC,OAAA,EAAS,QAAQ,CAAC,CAAA;AAK5C,SAAS,wBAAwB,GAAqC,EAAA;AAC3E,EAAM,MAAA,OAAA,GAAU,IAAI,IAAK,EAAA;AACzB,EAAI,IAAA,OAAA,KAAY,IAAW,OAAA;AAAA,IACzB,EAAI,EAAA,IAAA;AAAA,IACJ,GAAK,EAAA,EAAA;AAAA,IACL,KAAO,EAAA;AAAA,GACT;AACA,EAAI,IAAA,OAAA,CAAQ,SAAS,qBAAuB,EAAA;AAC1C,IAAO,OAAA;AAAA,MACL,EAAI,EAAA,KAAA;AAAA,MACJ,IAAM,EAAA,UAAA;AAAA,MACN,OAAA,EAAS,gBAAgB,qBAAqB,CAAA,qBAAA;AAAA,KAChD;AAAA;AAEF,EAAI,IAAA,MAAA;AACJ,EAAI,IAAA;AACF,IAAS,MAAA,GAAA,IAAI,IAAI,OAAO,CAAA;AAAA,GAClB,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,O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AAU,OAAA,IAAA;AAC/B,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAA,KAAA,MAAW,QAAQ,KAAO,EAAA;AACxB,IAAA,IAAI,CAAC,WAAA,CAAY,IAAK,CAAA,IAAI,GAAU,OAAA,IAAA;AACpC,IAAM,MAAA,CAAA,GAAI,OAAO,IAAI,CAAA;AACrB,IAAI,IAAA,CAAA,GAAI,KAAY,OAAA,IAAA;AACpB,IAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA;AAEf,EAAA,OAAO,CAAC,MAAA,CAAO,CAAC,CAAA,EAAI,MAAO,CAAA,CAAC,CAAI,EAAA,MAAA,CAAO,CAAC,CAAA,EAAI,MAAO,CAAA,CAAC,CAAE,CAAA;AACxD"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {BOOLEAN_SETTING_KEYS}from'./worldSettings.js';var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
const COUPLINGS = [{
|
|
21
|
-
parent: "destructiveItems",
|
|
22
|
-
when: false,
|
|
23
|
-
children: ["tntExplodes", "respawnBlocksExplode", "fireSpreads"],
|
|
24
|
-
force: false,
|
|
25
|
-
reason: "Destructive items are turned off"
|
|
26
|
-
}, {
|
|
27
|
-
parent: "playerDamage",
|
|
28
|
-
when: false,
|
|
29
|
-
children: ["pvp", "friendlyFire"],
|
|
30
|
-
force: false,
|
|
31
|
-
reason: "Player damage is turned off"
|
|
32
|
-
}, {
|
|
33
|
-
parent: "mobsRestricted",
|
|
34
|
-
when: true,
|
|
35
|
-
children: ["mobSpawning"],
|
|
36
|
-
force: false,
|
|
37
|
-
reason: "Mobs are restricted"
|
|
38
|
-
}, {
|
|
39
|
-
parent: "perfectWeather",
|
|
40
|
-
when: true,
|
|
41
|
-
children: ["weatherCycle"],
|
|
42
|
-
force: false,
|
|
43
|
-
reason: "Perfect weather is on"
|
|
44
|
-
}];
|
|
45
|
-
function evaluateRules(settings) {
|
|
46
|
-
const result = {};
|
|
47
|
-
for (const key of BOOLEAN_SETTING_KEYS) {
|
|
48
|
-
result[key] = {
|
|
49
|
-
value: settings[key],
|
|
50
|
-
locked: false
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
for (const coupling of COUPLINGS) {
|
|
54
|
-
if (settings[coupling.parent] !== coupling.when) continue;
|
|
55
|
-
for (const child of coupling.children) {
|
|
56
|
-
result[child] = {
|
|
57
|
-
value: coupling.force,
|
|
58
|
-
locked: true,
|
|
59
|
-
lockedReason: coupling.reason
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
function applyRuleConstraints(settings) {
|
|
66
|
-
const rules = evaluateRules(settings);
|
|
67
|
-
let next = null;
|
|
68
|
-
for (const key of BOOLEAN_SETTING_KEYS) {
|
|
69
|
-
const state = rules[key];
|
|
70
|
-
if (state.locked && settings[key] !== state.value) {
|
|
71
|
-
if (!next) next = __spreadValues({}, settings);
|
|
72
|
-
next[key] = state.value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return next != null ? next : settings;
|
|
76
|
-
}
|
|
77
|
-
function setBooleanSetting(settings, key, value) {
|
|
78
|
-
if (evaluateRules(settings)[key].locked) return settings;
|
|
79
|
-
if (settings[key] === value) return applyRuleConstraints(settings);
|
|
80
|
-
return applyRuleConstraints(__spreadProps(__spreadValues({}, settings), {
|
|
81
|
-
[key]: value
|
|
82
|
-
}));
|
|
83
|
-
}export{applyRuleConstraints,evaluateRules,setBooleanSetting};//# sourceMappingURL=rules.js.map
|