@dxos/plugin-sheet 0.6.12-main.ed7cda7 → 0.6.12-main.f9d0246
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/dist/lib/browser/{SheetContainer-V4GCCZTX.mjs → SheetContainer-VISF3VUB.mjs} +6 -6
- package/dist/lib/browser/{SheetContainer-V4GCCZTX.mjs.map → SheetContainer-VISF3VUB.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-T3NJFTD4.mjs → chunk-WZMOZKQZ.mjs} +2 -2
- package/dist/lib/browser/{chunk-T3NJFTD4.mjs.map → chunk-WZMOZKQZ.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-6ZMQVB4Z.mjs → chunk-Z2XOOC2R.mjs} +81 -62
- package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +7 -0
- package/dist/lib/browser/{chunk-U2JHW3L6.mjs → chunk-ZLJ2GRE2.mjs} +173 -42
- package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +7 -0
- package/dist/lib/browser/{graph-T27BOBOV.mjs → graph-4XFKIHRL.mjs} +4 -4
- package/dist/lib/browser/index.mjs +15 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-3ZY7MPWJ.cjs → SheetContainer-2MEALQWW.cjs} +14 -14
- package/dist/lib/node/{SheetContainer-3ZY7MPWJ.cjs.map → SheetContainer-2MEALQWW.cjs.map} +3 -3
- package/dist/lib/node/{chunk-OTTD7FBK.cjs → chunk-6DQABRGJ.cjs} +192 -60
- package/dist/lib/node/chunk-6DQABRGJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-Q3HBHPRL.cjs → chunk-AOP42UAA.cjs} +5 -5
- package/dist/lib/node/{chunk-Q3HBHPRL.cjs.map → chunk-AOP42UAA.cjs.map} +3 -3
- package/dist/lib/node/{chunk-DD6FIXWC.cjs → chunk-P5QYYEHQ.cjs} +86 -67
- package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +7 -0
- package/dist/lib/node/{graph-SPKGX7W4.cjs → graph-2LRDUXBZ.cjs} +14 -14
- package/dist/lib/node/graph-2LRDUXBZ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +25 -24
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +8 -8
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-PXSJX6XK.mjs → SheetContainer-RPSUSXWS.mjs} +6 -6
- package/dist/lib/node-esm/{SheetContainer-PXSJX6XK.mjs.map → SheetContainer-RPSUSXWS.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-D6KU5MI7.mjs → chunk-4MM7THJW.mjs} +81 -62
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7HVSOTGA.mjs → chunk-5RLTCIE2.mjs} +173 -42
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BMNA27EX.mjs → chunk-RR2AO4SM.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-BMNA27EX.mjs.map → chunk-RR2AO4SM.mjs.map} +3 -3
- package/dist/lib/node-esm/{graph-U67IO4UC.mjs → graph-WG5EKOMO.mjs} +4 -4
- package/dist/lib/node-esm/index.mjs +15 -13
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +3 -3
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/defs/types.d.ts.map +1 -1
- package/dist/types/src/defs/util.d.ts +1 -1
- package/dist/types/src/defs/util.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +5 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/async-function.d.ts +7 -1
- package/dist/types/src/graph/async-function.d.ts.map +1 -1
- package/dist/types/src/graph/compute-graph.d.ts +12 -9
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +9 -2
- package/dist/types/src/graph/compute-node.d.ts.map +1 -1
- package/dist/types/src/graph/edge-function.d.ts.map +1 -1
- package/dist/types/src/graph/{custom-function.d.ts → testing/custom-function.d.ts} +3 -1
- package/dist/types/src/graph/testing/custom-function.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +2 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +2 -2
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +3 -3
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +4 -5
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -3
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/SheetPlugin.tsx +9 -7
- package/src/components/CellEditor/CellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +5 -4
- package/src/components/GridSheet/GridSheet.tsx +4 -4
- package/src/components/Sheet/Sheet.stories.tsx +21 -20
- package/src/components/Sheet/sheet-context.tsx +4 -4
- package/src/components/SheetContainer.tsx +2 -2
- package/src/defs/types.ts +1 -0
- package/src/defs/util.ts +19 -3
- package/src/extensions/compute.stories.tsx +18 -16
- package/src/extensions/compute.ts +72 -39
- package/src/graph/async-function.ts +13 -6
- package/src/graph/compute-graph.stories.tsx +4 -3
- package/src/graph/compute-graph.test.ts +127 -0
- package/src/graph/compute-graph.ts +64 -41
- package/src/graph/compute-node.ts +16 -5
- package/src/graph/edge-function.ts +1 -2
- package/src/graph/{custom-function.ts → testing/custom-function.ts} +10 -2
- package/src/graph/testing/index.ts +5 -0
- package/src/hooks/hooks.stories.tsx +3 -3
- package/src/hooks/useComputeGraph.ts +2 -1
- package/src/hooks/useSheetModel.ts +4 -7
- package/src/model/sheet-model.ts +44 -29
- package/src/testing/testing.tsx +17 -15
- package/src/types.ts +3 -3
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +0 -7
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +0 -7
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +0 -7
- package/dist/lib/node/graph-SPKGX7W4.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +0 -7
- package/dist/types/src/graph/compute-graph.browser.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/graph/custom-function.d.ts.map +0 -1
- package/src/graph/compute-graph.browser.test.ts +0 -104
- /package/dist/lib/browser/{graph-T27BOBOV.mjs.map → graph-4XFKIHRL.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-U67IO4UC.mjs.map → graph-WG5EKOMO.mjs.map} +0 -0
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
Sheet,
|
|
3
3
|
addressToIndex,
|
|
4
4
|
useSheetContext
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ZLJ2GRE2.mjs";
|
|
6
|
+
import "./chunk-WZMOZKQZ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
SHEET_PLUGIN
|
|
9
9
|
} from "./chunk-QILRZNE5.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-Z2XOOC2R.mjs";
|
|
11
11
|
|
|
12
12
|
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
13
13
|
import React3, { useCallback } from "react";
|
|
@@ -211,7 +211,7 @@ var Toolbar = {
|
|
|
211
211
|
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
212
212
|
var attentionFragment = mx("group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface", "group-focus-within/editor:border-separator");
|
|
213
213
|
var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
|
|
214
|
-
var SheetContainer = ({
|
|
214
|
+
var SheetContainer = ({ graph, sheet, role }) => {
|
|
215
215
|
const dispatch = useIntentDispatcher();
|
|
216
216
|
const id = fullyQualifiedId(sheet);
|
|
217
217
|
const isDirectlyAttended = useIsDirectlyAttended(id);
|
|
@@ -236,7 +236,7 @@ var SheetContainer = ({ sheet, space, role }) => {
|
|
|
236
236
|
role: "none",
|
|
237
237
|
className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0
|
|
238
238
|
}, /* @__PURE__ */ React3.createElement(Sheet.Root, {
|
|
239
|
-
|
|
239
|
+
graph,
|
|
240
240
|
sheet
|
|
241
241
|
}, /* @__PURE__ */ React3.createElement("div", {
|
|
242
242
|
role: "none",
|
|
@@ -258,4 +258,4 @@ export {
|
|
|
258
258
|
SheetContainer_default as default,
|
|
259
259
|
sectionToolbarLayout
|
|
260
260
|
};
|
|
261
|
-
//# sourceMappingURL=SheetContainer-
|
|
261
|
+
//# sourceMappingURL=SheetContainer-VISF3VUB.mjs.map
|
package/dist/lib/browser/{SheetContainer-V4GCCZTX.mjs.map → SheetContainer-VISF3VUB.mjs.map}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/SheetContainer.tsx", "../../../src/components/Toolbar/Toolbar.tsx", "../../../src/components/Toolbar/common.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport { fullyQualifiedId } from '@dxos/react-client/echo';\nimport { useIsDirectlyAttended } from '@dxos/react-ui-attention';\nimport { focusRing, mx } from '@dxos/react-ui-theme';\n\nimport { Sheet, type SheetRootProps } from './Sheet';\nimport { Toolbar, type ToolbarAction } from './Toolbar';\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nconst attentionFragment = mx(\n 'group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface',\n 'group-focus-within/editor:border-separator',\n);\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nexport const sectionToolbarLayout =\n 'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';\n\nconst SheetContainer = ({ sheet, space, role }: SheetRootProps & { role?: string }) => {\n const dispatch = useIntentDispatcher();\n\n const id = fullyQualifiedId(sheet);\n const isDirectlyAttended = useIsDirectlyAttended(id);\n\n // TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.\n const handleAction = useCallback(\n (action: ToolbarAction) => {\n switch (action.type) {\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: action.anchor,\n name: action.cellContent,\n subject: sheet,\n },\n });\n }\n }\n },\n [sheet, dispatch],\n );\n\n return (\n <div role='none' className={role === 'article' ? 'row-span-2 grid grid-rows-subgrid' : undefined}>\n <Sheet.Root space={space} sheet={sheet}>\n <div role='none' className={mx('flex flex-0 justify-center overflow-x-auto')}>\n <Toolbar.Root\n onAction={handleAction}\n classNames={mx(\n role === 'section'\n ? ['z-[2] group-focus-within/section:visible', !isDirectlyAttended && 'invisible', sectionToolbarLayout]\n : 'group-focus-within/editor:border-separator group-[[aria-current]]/editor:border-separator',\n )}\n >\n {/* TODO(Zan): Restore some of this functionality */}\n {/* <Toolbar.Styles /> */}\n {/* <Toolbar.Format /> */}\n {/* <Toolbar.Alignment /> */}\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n </div>\n <div\n role='none'\n className={mx(\n role === 'section' && 'aspect-square border-is border-bs border-be border-separator',\n role === 'article' &&\n 'flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator',\n focusRing,\n attentionFragment,\n )}\n >\n <Sheet.Main />\n </div>\n </Sheet.Root>\n </div>\n );\n};\n\nexport default SheetContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type Icon,\n Calendar,\n ChatText,\n CurrencyDollar,\n Eraser,\n HighlighterCircle,\n TextAlignCenter,\n TextAlignLeft,\n TextAlignRight,\n} from '@phosphor-icons/react';\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n DensityProvider,\n ElevationProvider,\n Toolbar as NaturalToolbar,\n type ThemedClassName,\n useTranslation,\n} from '@dxos/react-ui';\nimport { nonNullable } from '@dxos/util';\n\nimport { ToolbarButton, ToolbarSeparator, ToolbarToggleButton } from './common';\nimport { addressToIndex } from '../../defs';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type Formatting } from '../../types';\nimport { useSheetContext } from '../Sheet/sheet-context';\n\n//\n// Root\n//\n\nexport type ToolbarAction =\n | { type: 'clear' }\n | { type: 'highlight' }\n | { type: 'left' }\n | { type: 'center' }\n | { type: 'right' }\n | { type: 'date' }\n | { type: 'currency' }\n | { type: 'comment'; anchor: string; cellContent?: string };\n\nexport type ToolbarActionType = ToolbarAction['type'];\n\nexport type ToolbarActionHandler = (action: ToolbarAction) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n onAction?: ToolbarActionHandler;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<ToolbarProps>('Toolbar');\n\nconst ToolbarRoot = ({ children, onAction, classNames }: ToolbarProps) => {\n return (\n <ToolbarContextProvider onAction={onAction}>\n <DensityProvider density='fine'>\n <ElevationProvider elevation='chrome'>\n <NaturalToolbar.Root classNames={['is-full shrink-0 overflow-x-auto overflow-y-hidden p-1', classNames]}>\n {children}\n </NaturalToolbar.Root>\n </ElevationProvider>\n </DensityProvider>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps = {\n type: ToolbarActionType;\n Icon: Icon;\n getState: (state: Formatting) => boolean;\n disabled?: (state: Formatting) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst formatOptions: ButtonProps[] = [\n { type: 'date', Icon: Calendar, getState: (state) => false },\n { type: 'currency', Icon: CurrencyDollar, getState: (state) => false },\n];\n\nconst Format = () => {\n const { onAction } = useToolbarContext('Format');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {formatOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst alignmentOptions: ButtonProps[] = [\n { type: 'left', Icon: TextAlignLeft, getState: (state) => false },\n { type: 'center', Icon: TextAlignCenter, getState: (state) => false },\n { type: 'right', Icon: TextAlignRight, getState: (state) => false },\n];\n\nconst Alignment = () => {\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {alignmentOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps[] = [\n { type: 'clear', Icon: Eraser, getState: (state) => false },\n { type: 'highlight', Icon: HighlighterCircle, getState: (state) => false },\n];\n\nconst Styles = () => {\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {styleOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursor, range, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursor) {\n return false;\n }\n return addressToIndex(model.sheet, cursor) === thread.anchor;\n });\n\n const hasCursor = !!cursor;\n const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;\n\n const tooltipLabelKey = !hasCursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : range\n ? 'comment ranges not supported label'\n : 'comment label';\n\n return (\n <ToolbarButton\n value='comment'\n Icon={ChatText}\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursor) {\n return;\n }\n return onAction?.({\n type: 'comment',\n anchor: addressToIndex(model.sheet, cursor),\n cellContent: model.getCellText(cursor),\n });\n }}\n disabled={!cursorOnly || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarButton>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Format,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Icon } from '@phosphor-icons/react';\nimport React from 'react';\n\nimport {\n Toolbar as NaturalToolbar,\n Tooltip,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n} from '@dxos/react-ui';\nimport { getSize } from '@dxos/react-ui-theme';\n\n// TODO(burdon): Factor out in common with react-ui-editor.\n\nexport const iconStyles = getSize(5);\nexport const buttonStyles = 'min-bs-0 p-2';\nexport const tooltipProps = { side: 'top' as const, classNames: 'z-10' };\n\nexport const ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarButton\n//\n\ntype ToolbarButtonProps = NaturalToolbarButtonProps & { Icon: Icon };\n\nexport const ToolbarButton = ({ Icon, children, ...props }: ToolbarButtonProps) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' {...props} classNames={buttonStyles}>\n <Icon className={iconStyles} />\n <span className='sr-only'>{children}</span>\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n\n//\n// ToolbarToggleButton\n//\n\nexport type ToolbarToggleButtonProps = NaturalToolbarToggleGroupItemProps & { Icon: Icon };\n\nexport const ToolbarToggleButton = ({ Icon, children, ...props }: ToolbarToggleButtonProps) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.ToggleGroupItem variant='ghost' {...props} classNames={buttonStyles}>\n <Icon className={iconStyles} />\n <span className='sr-only'>{children}</span>\n </NaturalToolbar.ToggleGroupItem>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAIA,OAAOA,UAASC,mBAAmB;AAEnC,SAASC,2BAA2B;AACpC,SAASC,wBAAwB;AACjC,SAASC,6BAA6B;AACtC,SAASC,WAAWC,UAAU;;;ACL9B,SAEEC,UACAC,UACAC,gBACAC,QACAC,mBACAC,iBACAC,eACAC,sBACK;AACP,SAASC,qBAAqB;AAC9B,OAAOC,YAAuC;AAE9C,SACEC,iBACAC,mBACAC,WAAWC,iBAEXC,sBACK;AACP,SAASC,mBAAmB;;;ACpB5B,OAAOC,WAAW;AAElB,SACEC,WAAWC,gBACXC,eAGK;AACP,SAASC,eAAe;AAIjB,IAAMC,aAAaC,QAAQ,CAAA;AAC3B,IAAMC,eAAe;AACrB,IAAMC,eAAe;EAAEC,MAAM;EA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ACd;AACpB,QAAMe,aAAaD,aAAa,CAACb,SAAS,CAACG;AAE3C,QAAMY,kBAAkB,CAACF,YACrB,oBACAV,wBACE,8CACAH,QACE,uCACA;AAER,SACE,gBAAAnC,OAAA,cAACmD,eAAAA;IACC7B,OAAM;IACNb,MAAM2C;IACNC,eAAY;IACZ9B,SAAS,MAAA;AACP,UAAI,CAACW,QAAQ;AACX;MACF;AACA,aAAOpC,WAAW;QAChBU,MAAM;QACNuC,QAAQD,eAAeV,MAAMG,OAAOL,MAAAA;QACpCoB,aAAalB,MAAMmB,YAAYrB,MAAAA;MACjC,CAAA;IACF;IACAsB,UAAU,CAACP,cAAcX;KAExBvB,EAAEmC,eAAAA,CAAAA;AAGT;AAEO,IAAMO,UAAU;EACrBnD,MAAMV;EACN8D,WAAWC;EACX/B;EACAd;EACAkB;EACAC;AACF;;;AD7NA,IAAM2B,oBAAoBC,GACxB,+FACA,4CAAA;AAIK,IAAMC,uBACX;AAEF,IAAMC,iBAAiB,CAAC,EAAEC,OAAOC,OAAOC,KAAI,MAAsC;AAChF,QAAMC,WAAWC,oBAAAA;AAEjB,QAAMC,KAAKC,
|
|
6
|
-
"names": ["React", "useCallback", "useIntentDispatcher", "fullyQualifiedId", "useIsDirectlyAttended", "focusRing", "mx", "Calendar", "ChatText", "CurrencyDollar", "Eraser", "HighlighterCircle", "TextAlignCenter", "TextAlignLeft", "TextAlignRight", "createContext", "React", "DensityProvider", "ElevationProvider", "Toolbar", "NaturalToolbar", "useTranslation", "nonNullable", "React", "Toolbar", "NaturalToolbar", "Tooltip", "getSize", "iconStyles", "getSize", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "div", "role", "className", "ToolbarButton", "Icon", "children", "props", "Tooltip", "Root", "Trigger", "asChild", "NaturalToolbar", "Button", "variant", "span", "Portal", "Content", "Arrow", "ToolbarToggleButton", "ToggleGroupItem", "ToolbarContextProvider", "useToolbarContext", "createContext", "ToolbarRoot", "children", "onAction", "classNames", "React", "DensityProvider", "density", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "formatOptions", "type", "Icon", "Calendar", "getState", "state", "CurrencyDollar", "Format", "t", "useTranslation", "SHEET_PLUGIN", "ToggleGroup", "map", "ToolbarToggleButton", "key", "value", "onClick", "alignmentOptions", "TextAlignLeft", "TextAlignCenter", "TextAlignRight", "Alignment", "styleOptions", "Eraser", "HighlighterCircle", "Styles", "Actions", "cursor", "range", "model", "useSheetContext", "overlapsCommentAnchor", "sheet", "threads", "filter", "nonNullable", "thread", "status", "some", "addressToIndex", "anchor", "hasCursor", "cursorOnly", "tooltipLabelKey", "ToolbarButton", "ChatText", "data-testid", "cellContent", "getCellText", "disabled", "Toolbar", "Separator", "ToolbarSeparator", "attentionFragment", "mx", "sectionToolbarLayout", "SheetContainer", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport { fullyQualifiedId } from '@dxos/react-client/echo';\nimport { useIsDirectlyAttended } from '@dxos/react-ui-attention';\nimport { focusRing, mx } from '@dxos/react-ui-theme';\n\nimport { Sheet, type SheetRootProps } from './Sheet';\nimport { Toolbar, type ToolbarAction } from './Toolbar';\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nconst attentionFragment = mx(\n 'group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface',\n 'group-focus-within/editor:border-separator',\n);\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nexport const sectionToolbarLayout =\n 'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';\n\nconst SheetContainer = ({ graph, sheet, role }: SheetRootProps & { role?: string }) => {\n const dispatch = useIntentDispatcher();\n\n const id = fullyQualifiedId(sheet);\n const isDirectlyAttended = useIsDirectlyAttended(id);\n\n // TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.\n const handleAction = useCallback(\n (action: ToolbarAction) => {\n switch (action.type) {\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: action.anchor,\n name: action.cellContent,\n subject: sheet,\n },\n });\n }\n }\n },\n [sheet, dispatch],\n );\n\n return (\n <div role='none' className={role === 'article' ? 'row-span-2 grid grid-rows-subgrid' : undefined}>\n <Sheet.Root graph={graph} sheet={sheet}>\n <div role='none' className={mx('flex flex-0 justify-center overflow-x-auto')}>\n <Toolbar.Root\n onAction={handleAction}\n classNames={mx(\n role === 'section'\n ? ['z-[2] group-focus-within/section:visible', !isDirectlyAttended && 'invisible', sectionToolbarLayout]\n : 'group-focus-within/editor:border-separator group-[[aria-current]]/editor:border-separator',\n )}\n >\n {/* TODO(Zan): Restore some of this functionality */}\n {/* <Toolbar.Styles /> */}\n {/* <Toolbar.Format /> */}\n {/* <Toolbar.Alignment /> */}\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n </div>\n <div\n role='none'\n className={mx(\n role === 'section' && 'aspect-square border-is border-bs border-be border-separator',\n role === 'article' &&\n 'flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator',\n focusRing,\n attentionFragment,\n )}\n >\n <Sheet.Main />\n </div>\n </Sheet.Root>\n </div>\n );\n};\n\nexport default SheetContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type Icon,\n Calendar,\n ChatText,\n CurrencyDollar,\n Eraser,\n HighlighterCircle,\n TextAlignCenter,\n TextAlignLeft,\n TextAlignRight,\n} from '@phosphor-icons/react';\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n DensityProvider,\n ElevationProvider,\n Toolbar as NaturalToolbar,\n type ThemedClassName,\n useTranslation,\n} from '@dxos/react-ui';\nimport { nonNullable } from '@dxos/util';\n\nimport { ToolbarButton, ToolbarSeparator, ToolbarToggleButton } from './common';\nimport { addressToIndex } from '../../defs';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type Formatting } from '../../types';\nimport { useSheetContext } from '../Sheet/sheet-context';\n\n//\n// Root\n//\n\nexport type ToolbarAction =\n | { type: 'clear' }\n | { type: 'highlight' }\n | { type: 'left' }\n | { type: 'center' }\n | { type: 'right' }\n | { type: 'date' }\n | { type: 'currency' }\n | { type: 'comment'; anchor: string; cellContent?: string };\n\nexport type ToolbarActionType = ToolbarAction['type'];\n\nexport type ToolbarActionHandler = (action: ToolbarAction) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n onAction?: ToolbarActionHandler;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<ToolbarProps>('Toolbar');\n\nconst ToolbarRoot = ({ children, onAction, classNames }: ToolbarProps) => {\n return (\n <ToolbarContextProvider onAction={onAction}>\n <DensityProvider density='fine'>\n <ElevationProvider elevation='chrome'>\n <NaturalToolbar.Root classNames={['is-full shrink-0 overflow-x-auto overflow-y-hidden p-1', classNames]}>\n {children}\n </NaturalToolbar.Root>\n </ElevationProvider>\n </DensityProvider>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps = {\n type: ToolbarActionType;\n Icon: Icon;\n getState: (state: Formatting) => boolean;\n disabled?: (state: Formatting) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst formatOptions: ButtonProps[] = [\n { type: 'date', Icon: Calendar, getState: (state) => false },\n { type: 'currency', Icon: CurrencyDollar, getState: (state) => false },\n];\n\nconst Format = () => {\n const { onAction } = useToolbarContext('Format');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {formatOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst alignmentOptions: ButtonProps[] = [\n { type: 'left', Icon: TextAlignLeft, getState: (state) => false },\n { type: 'center', Icon: TextAlignCenter, getState: (state) => false },\n { type: 'right', Icon: TextAlignRight, getState: (state) => false },\n];\n\nconst Alignment = () => {\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {alignmentOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps[] = [\n { type: 'clear', Icon: Eraser, getState: (state) => false },\n { type: 'highlight', Icon: HighlighterCircle, getState: (state) => false },\n];\n\nconst Styles = () => {\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {styleOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursor, range, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursor) {\n return false;\n }\n return addressToIndex(model.sheet, cursor) === thread.anchor;\n });\n\n const hasCursor = !!cursor;\n const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;\n\n const tooltipLabelKey = !hasCursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : range\n ? 'comment ranges not supported label'\n : 'comment label';\n\n return (\n <ToolbarButton\n value='comment'\n Icon={ChatText}\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursor) {\n return;\n }\n return onAction?.({\n type: 'comment',\n anchor: addressToIndex(model.sheet, cursor),\n cellContent: model.getCellText(cursor),\n });\n }}\n disabled={!cursorOnly || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarButton>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Format,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Icon } from '@phosphor-icons/react';\nimport React from 'react';\n\nimport {\n Toolbar as NaturalToolbar,\n Tooltip,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n} from '@dxos/react-ui';\nimport { getSize } from '@dxos/react-ui-theme';\n\n// TODO(burdon): Factor out in common with react-ui-editor.\n\nexport const iconStyles = getSize(5);\nexport const buttonStyles = 'min-bs-0 p-2';\nexport const tooltipProps = { side: 'top' as const, classNames: 'z-10' };\n\nexport const ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarButton\n//\n\ntype ToolbarButtonProps = NaturalToolbarButtonProps & { Icon: Icon };\n\nexport const ToolbarButton = ({ Icon, children, ...props }: ToolbarButtonProps) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' {...props} classNames={buttonStyles}>\n <Icon className={iconStyles} />\n <span className='sr-only'>{children}</span>\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n\n//\n// ToolbarToggleButton\n//\n\nexport type ToolbarToggleButtonProps = NaturalToolbarToggleGroupItemProps & { Icon: Icon };\n\nexport const ToolbarToggleButton = ({ Icon, children, ...props }: ToolbarToggleButtonProps) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.ToggleGroupItem variant='ghost' {...props} classNames={buttonStyles}>\n <Icon className={iconStyles} />\n <span className='sr-only'>{children}</span>\n </NaturalToolbar.ToggleGroupItem>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAIA,OAAOA,UAASC,mBAAmB;AAEnC,SAASC,2BAA2B;AACpC,SAASC,wBAAwB;AACjC,SAASC,6BAA6B;AACtC,SAASC,WAAWC,UAAU;;;ACL9B,SAEEC,UACAC,UACAC,gBACAC,QACAC,mBACAC,iBACAC,eACAC,sBACK;AACP,SAASC,qBAAqB;AAC9B,OAAOC,YAAuC;AAE9C,SACEC,iBACAC,mBACAC,WAAWC,iBAEXC,sBACK;AACP,SAASC,mBAAmB;;;ACpB5B,OAAOC,WAAW;AAElB,SACEC,WAAWC,gBACXC,eAGK;AACP,SAASC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AACxB;IAAcC;KACxB,gBAAAkB,OAAA,cAACC,OAAAA;IAAIlB,MAAK;IAAOmB,WAAWxB,GAAG,4CAAA;KAC7B,gBAAAsB,OAAA,cAACM,QAAQD,MAAI;IACXE,UAAUjB;IACVkB,YAAY9B,GACVK,SAAS,YACL;MAAC;MAA4C,CAACK,sBAAsB;MAAaT;QACjF,2FAAA;KAON,gBAAAqB,OAAA,cAACM,QAAQG,WAAS,IAAA,GAClB,gBAAAT,OAAA,cAACM,QAAQI,SAAO,IAAA,CAAA,CAAA,GAGpB,gBAAAV,OAAA,cAACC,OAAAA;IACClB,MAAK;IACLmB,WAAWxB,GACTK,SAAS,aAAa,gEACtBA,SAAS,aACP,gKACF4B,WACAlC,iBAAAA;KAGF,gBAAAuB,OAAA,cAACI,MAAMQ,MAAI,IAAA,CAAA,CAAA,CAAA;AAKrB;AAEA,IAAA,yBAAehC;",
|
|
6
|
+
"names": ["React", "useCallback", "useIntentDispatcher", "fullyQualifiedId", "useIsDirectlyAttended", "focusRing", "mx", "Calendar", "ChatText", "CurrencyDollar", "Eraser", "HighlighterCircle", "TextAlignCenter", "TextAlignLeft", "TextAlignRight", "createContext", "React", "DensityProvider", "ElevationProvider", "Toolbar", "NaturalToolbar", "useTranslation", "nonNullable", "React", "Toolbar", "NaturalToolbar", "Tooltip", "getSize", "iconStyles", "getSize", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "div", "role", "className", "ToolbarButton", "Icon", "children", "props", "Tooltip", "Root", "Trigger", "asChild", "NaturalToolbar", "Button", "variant", "span", "Portal", "Content", "Arrow", "ToolbarToggleButton", "ToggleGroupItem", "ToolbarContextProvider", "useToolbarContext", "createContext", "ToolbarRoot", "children", "onAction", "classNames", "React", "DensityProvider", "density", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "formatOptions", "type", "Icon", "Calendar", "getState", "state", "CurrencyDollar", "Format", "t", "useTranslation", "SHEET_PLUGIN", "ToggleGroup", "map", "ToolbarToggleButton", "key", "value", "onClick", "alignmentOptions", "TextAlignLeft", "TextAlignCenter", "TextAlignRight", "Alignment", "styleOptions", "Eraser", "HighlighterCircle", "Styles", "Actions", "cursor", "range", "model", "useSheetContext", "overlapsCommentAnchor", "sheet", "threads", "filter", "nonNullable", "thread", "status", "some", "addressToIndex", "anchor", "hasCursor", "cursorOnly", "tooltipLabelKey", "ToolbarButton", "ChatText", "data-testid", "cellContent", "getCellText", "disabled", "Toolbar", "Separator", "ToolbarSeparator", "attentionFragment", "mx", "sectionToolbarLayout", "SheetContainer", "graph", "sheet", "role", "dispatch", "useIntentDispatcher", "id", "fullyQualifiedId", "isDirectlyAttended", "useIsDirectlyAttended", "handleAction", "useCallback", "action", "type", "data", "cursor", "anchor", "name", "cellContent", "subject", "React", "div", "className", "undefined", "Sheet", "Root", "Toolbar", "onAction", "classNames", "Separator", "Actions", "focusRing", "Main"]
|
|
7
7
|
}
|
|
@@ -45,7 +45,7 @@ var SheetType = class extends TypedObject({
|
|
|
45
45
|
typename: "dxos.org/type/SheetType",
|
|
46
46
|
version: "0.1.0"
|
|
47
47
|
})({
|
|
48
|
-
|
|
48
|
+
name: S.optional(S.String),
|
|
49
49
|
// Sparse map of cells referenced by index.
|
|
50
50
|
cells: S.mutable(S.Record(S.String, S.mutable(CellValue))),
|
|
51
51
|
// Ordered row indices.
|
|
@@ -72,4 +72,4 @@ export {
|
|
|
72
72
|
RowColumnMeta,
|
|
73
73
|
SheetType
|
|
74
74
|
};
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
75
|
+
//# sourceMappingURL=chunk-WZMOZKQZ.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type MarkdownExtensionProvides } from '@dxos/plugin-markdown';\nimport { type SpaceInitProvides } from '@dxos/plugin-space';\nimport { ThreadType } from '@dxos/plugin-space/types';\nimport { type StackProvides } from '@dxos/plugin-stack';\n\nimport { SHEET_PLUGIN } from './meta';\n\nconst SHEET_ACTION = `${SHEET_PLUGIN}/action`;\n\nexport enum SheetAction {\n CREATE = `${SHEET_ACTION}/create`,\n}\n\n// TODO(Zan): Move this to the plugin-space plugin or another common location\n// when we implement comments in sheets.\n// This is currently duplicated in a few places.\ntype ThreadProvides<T> = {\n thread: {\n predicate: (obj: any) => obj is T;\n createSort: (obj: T) => (anchorA: string | undefined, anchorB: string | undefined) => number;\n };\n};\n\nexport type SheetPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MarkdownExtensionProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n SchemaProvides &\n SpaceInitProvides &\n StackProvides &\n ThreadProvides<SheetType>;\n\nexport type CellScalarValue = number | string | boolean | null;\n\nexport const CellValue = S.Struct({\n // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.\n // Consider import/export; natural access for other plugins. Special handling for currency (precision).\n // TODO(burdon): Automerge (long string) or short string or number.\n // TODO(burdon): Arrays?\n value: S.Any,\n});\n\nexport type CellValue = S.Schema.Type<typeof CellValue>;\n\n/**\n * https://www.tutorialsteacher.com/typescript/typescript-number\n */\n// TODO(burdon): Format vs. value.\nexport enum ValueTypeEnum {\n Null = 0,\n Number = 1,\n Boolean = 2,\n String = 3,\n\n // Special numbers.\n Percent = 10,\n Currency = 11,\n\n // Dates.\n DateTime = 20,\n Date = 21,\n Time = 22,\n\n // Validated string types.\n // TODO(burdon): Define effect types.\n URL = 30,\n DID = 31,\n}\n\nexport const ValueType = S.Enums(ValueTypeEnum);\n\nexport const Formatting = S.Struct({\n type: S.optional(ValueType),\n format: S.optional(S.String),\n precision: S.optional(S.Number),\n classNames: S.optional(S.Array(S.String)),\n});\n\nexport type Formatting = S.Schema.Type<typeof Formatting>;\n\n// TODO(burdon): Visibility, locked, frozen, etc.\nexport const RowColumnMeta = S.Struct({\n size: S.optional(S.Number),\n});\n\n// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.\n// TODO(wittjosiah): Migrate typename to remove `Type` suffix.\n// TODO(wittjosiah): Rename title to name to align with other schemas.\nexport class SheetType extends TypedObject({ typename: 'dxos.org/type/SheetType', version: '0.1.0' })({\n
|
|
5
|
-
"mappings": ";;;;;AAWA,SAASA,KAAKC,GAAGC,mBAAmB;AAIpC,SAASC,kBAAkB;AAK3B,IAAMC,eAAe,GAAGC,YAAAA;;UAEZC,cAAAA;wCACD,GAAGF,YAAAA,SAAqB,IAAA;GADvBE,gBAAAA,cAAAA,CAAAA,EAAAA;AA2BL,IAAMC,YAAYC,EAAEC,OAAO;;;;;EAKhCC,OAAOF,EAAEG;AACX,CAAA;;UAQYC,gBAAAA;;;;;;;;;;;;GAAAA,kBAAAA,gBAAAA,CAAAA,EAAAA;AAqBL,IAAMC,YAAYL,EAAEM,MAAMF,aAAAA;AAE1B,IAAMG,aAAaP,EAAEC,OAAO;EACjCO,MAAMR,EAAES,SAASJ,SAAAA;EACjBK,QAAQV,EAAES,SAAST,EAAEW,MAAM;EAC3BC,WAAWZ,EAAES,SAAST,EAAEa,MAAM;EAC9BC,YAAYd,EAAES,SAAST,EAAEe,MAAMf,EAAEW,MAAM,CAAA;AACzC,CAAA;AAKO,IAAMK,gBAAgBhB,EAAEC,OAAO;EACpCgB,MAAMjB,EAAES,SAAST,EAAEa,MAAM;AAC3B,CAAA;AAKO,IAAMK,YAAN,cAAwBC,YAAY;EAAEC,UAAU;EAA2BC,SAAS;AAAQ,CAAA,EAAG;EACpGC,
|
|
6
|
-
"names": ["ref", "S", "TypedObject", "ThreadType", "SHEET_ACTION", "SHEET_PLUGIN", "SheetAction", "CellValue", "S", "Struct", "value", "Any", "ValueTypeEnum", "ValueType", "Enums", "Formatting", "type", "optional", "format", "String", "precision", "Number", "classNames", "Array", "RowColumnMeta", "size", "SheetType", "TypedObject", "typename", "version", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type MarkdownExtensionProvides } from '@dxos/plugin-markdown';\nimport { type SpaceInitProvides } from '@dxos/plugin-space';\nimport { ThreadType } from '@dxos/plugin-space/types';\nimport { type StackProvides } from '@dxos/plugin-stack';\n\nimport { SHEET_PLUGIN } from './meta';\n\nconst SHEET_ACTION = `${SHEET_PLUGIN}/action`;\n\nexport enum SheetAction {\n CREATE = `${SHEET_ACTION}/create`,\n}\n\n// TODO(Zan): Move this to the plugin-space plugin or another common location\n// when we implement comments in sheets.\n// This is currently duplicated in a few places.\ntype ThreadProvides<T> = {\n thread: {\n predicate: (obj: any) => obj is T;\n createSort: (obj: T) => (anchorA: string | undefined, anchorB: string | undefined) => number;\n };\n};\n\nexport type SheetPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MarkdownExtensionProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n SchemaProvides &\n SpaceInitProvides &\n StackProvides &\n ThreadProvides<SheetType>;\n\nexport type CellScalarValue = number | string | boolean | null;\n\nexport const CellValue = S.Struct({\n // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.\n // Consider import/export; natural access for other plugins. Special handling for currency (precision).\n // TODO(burdon): Automerge (long string) or short string or number.\n // TODO(burdon): Arrays?\n value: S.Any,\n});\n\nexport type CellValue = S.Schema.Type<typeof CellValue>;\n\n/**\n * https://www.tutorialsteacher.com/typescript/typescript-number\n */\n// TODO(burdon): Format vs. value.\nexport enum ValueTypeEnum {\n Null = 0,\n Number = 1,\n Boolean = 2,\n String = 3,\n\n // Special numbers.\n Percent = 10,\n Currency = 11,\n\n // Dates.\n DateTime = 20,\n Date = 21,\n Time = 22,\n\n // Validated string types.\n // TODO(burdon): Define effect types.\n URL = 30,\n DID = 31,\n}\n\nexport const ValueType = S.Enums(ValueTypeEnum);\n\nexport const Formatting = S.Struct({\n type: S.optional(ValueType),\n format: S.optional(S.String),\n precision: S.optional(S.Number),\n classNames: S.optional(S.Array(S.String)),\n});\n\nexport type Formatting = S.Schema.Type<typeof Formatting>;\n\n// TODO(burdon): Visibility, locked, frozen, etc.\nexport const RowColumnMeta = S.Struct({\n size: S.optional(S.Number),\n});\n\n// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.\n// TODO(wittjosiah): Migrate typename to remove `Type` suffix.\n// TODO(wittjosiah): Rename title to name to align with other schemas.\nexport class SheetType extends TypedObject({ typename: 'dxos.org/type/SheetType', version: '0.1.0' })({\n name: S.optional(S.String),\n\n // Sparse map of cells referenced by index.\n cells: S.mutable(S.Record(S.String, S.mutable(CellValue))),\n\n // Ordered row indices.\n rows: S.mutable(S.Array(S.String)),\n\n // Ordered column indices.\n columns: S.mutable(S.Array(S.String)),\n\n // Row metadata referenced by index.\n rowMeta: S.mutable(S.Record(S.String, S.mutable(RowColumnMeta))),\n\n // Column metadata referenced by index.\n columnMeta: S.mutable(S.Record(S.String, S.mutable(RowColumnMeta))),\n\n // Cell formatting referenced by indexed range.\n formatting: S.mutable(S.Record(S.String, S.mutable(Formatting))),\n\n // Threads associated with the sheet\n threads: S.optional(S.mutable(S.Array(ref(ThreadType)))),\n}) {}\n\nexport type SheetSize = {\n rows: number;\n columns: number;\n};\n\nexport type CreateSheetOptions = {\n name?: string;\n cells?: Record<string, CellValue>;\n} & Partial<SheetSize>;\n"],
|
|
5
|
+
"mappings": ";;;;;AAWA,SAASA,KAAKC,GAAGC,mBAAmB;AAIpC,SAASC,kBAAkB;AAK3B,IAAMC,eAAe,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AEW,QAAQX,EAAEwB,QAAQjB,UAAAA,CAAAA,CAAAA;;EAGnDwB,SAAS/B,EAAES,SAAST,EAAEwB,QAAQxB,EAAEe,MAAMiB,IAAIC,UAAAA,CAAAA,CAAAA,CAAAA;AAC5C,CAAA,EAAA;AAAI;",
|
|
6
|
+
"names": ["ref", "S", "TypedObject", "ThreadType", "SHEET_ACTION", "SHEET_PLUGIN", "SheetAction", "CellValue", "S", "Struct", "value", "Any", "ValueTypeEnum", "ValueType", "Enums", "Formatting", "type", "optional", "format", "String", "precision", "Number", "classNames", "Array", "RowColumnMeta", "size", "SheetType", "TypedObject", "typename", "version", "name", "cells", "mutable", "Record", "rows", "columns", "rowMeta", "columnMeta", "formatting", "threads", "ref", "ThreadType"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// packages/plugins/plugin-sheet/src/graph/compute-graph.ts
|
|
2
|
+
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2
3
|
import { Event as Event2 } from "@dxos/async";
|
|
3
4
|
import { Filter as Filter2, fullyQualifiedId } from "@dxos/client/echo";
|
|
4
5
|
import { Resource as Resource2 } from "@dxos/context";
|
|
@@ -7,7 +8,7 @@ import { PublicKey } from "@dxos/keys";
|
|
|
7
8
|
import { log as log3 } from "@dxos/log";
|
|
8
9
|
import { FunctionType as FunctionType2 } from "@dxos/plugin-script/types";
|
|
9
10
|
import { nonNullable as nonNullable2 } from "@dxos/util";
|
|
10
|
-
import { HyperFormula } from "#hyperformula";
|
|
11
|
+
import { ExportedCellChange, HyperFormula } from "#hyperformula";
|
|
11
12
|
|
|
12
13
|
// packages/plugins/plugin-sheet/src/graph/async-function.ts
|
|
13
14
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
@@ -28,7 +29,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
28
29
|
...args
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
|
-
constructor(_hf, _space,
|
|
32
|
+
constructor(_hf, _space, _options) {
|
|
32
33
|
this._hf = _hf;
|
|
33
34
|
this._space = _space;
|
|
34
35
|
this._cache = /* @__PURE__ */ new Map();
|
|
@@ -36,12 +37,11 @@ var FunctionContext = class _FunctionContext {
|
|
|
36
37
|
this._subscriptions = /* @__PURE__ */ new Map();
|
|
37
38
|
this._invocations = {};
|
|
38
39
|
this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
|
|
39
|
-
this._onUpdate = debounce(() => {
|
|
40
|
+
this._onUpdate = debounce((update) => {
|
|
40
41
|
this._hf.resumeEvaluation();
|
|
41
|
-
onUpdate(
|
|
42
|
+
this._options.onUpdate?.(update);
|
|
42
43
|
}, this._options.recalculationDelay);
|
|
43
44
|
}
|
|
44
|
-
// TODO(burdon): Remove?
|
|
45
45
|
get space() {
|
|
46
46
|
return this._space;
|
|
47
47
|
}
|
|
@@ -90,18 +90,21 @@ var FunctionContext = class _FunctionContext {
|
|
|
90
90
|
value: value2
|
|
91
91
|
}, {
|
|
92
92
|
F: __dxlog_file,
|
|
93
|
-
L:
|
|
93
|
+
L: 145,
|
|
94
94
|
S: this,
|
|
95
95
|
C: (f, a) => f(...a)
|
|
96
96
|
});
|
|
97
|
-
this._onUpdate(
|
|
97
|
+
this._onUpdate({
|
|
98
|
+
name,
|
|
99
|
+
cell
|
|
100
|
+
});
|
|
98
101
|
} catch (err) {
|
|
99
102
|
log.warn("failed", {
|
|
100
103
|
cell,
|
|
101
104
|
err
|
|
102
105
|
}, {
|
|
103
106
|
F: __dxlog_file,
|
|
104
|
-
L:
|
|
107
|
+
L: 149,
|
|
105
108
|
S: this,
|
|
106
109
|
C: (f, a) => f(...a)
|
|
107
110
|
});
|
|
@@ -121,7 +124,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
121
124
|
cache: value
|
|
122
125
|
}, {
|
|
123
126
|
F: __dxlog_file,
|
|
124
|
-
L:
|
|
127
|
+
L: 157,
|
|
125
128
|
S: this,
|
|
126
129
|
C: (f, a) => f(...a)
|
|
127
130
|
});
|
|
@@ -152,12 +155,11 @@ var ComputeNode = class extends Resource {
|
|
|
152
155
|
this.sheetId = sheetId;
|
|
153
156
|
this.update = new Event();
|
|
154
157
|
}
|
|
155
|
-
// TODO(burdon): Remove?
|
|
156
158
|
get graph() {
|
|
157
159
|
return this._graph;
|
|
158
160
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
clear() {
|
|
162
|
+
this._graph.hf.clearSheet(this.sheetId);
|
|
161
163
|
}
|
|
162
164
|
getValue(cell) {
|
|
163
165
|
const value = this._graph.hf.getCellValue({
|
|
@@ -182,6 +184,8 @@ var ComputeNode = class extends Resource {
|
|
|
182
184
|
]
|
|
183
185
|
]);
|
|
184
186
|
}
|
|
187
|
+
async _open() {
|
|
188
|
+
}
|
|
185
189
|
};
|
|
186
190
|
|
|
187
191
|
// packages/plugins/plugin-sheet/src/graph/edge-function.ts
|
|
@@ -257,11 +261,7 @@ EdgeFunctionPlugin.implementedFunctions = {
|
|
|
257
261
|
{
|
|
258
262
|
argumentType: FunctionArgumentType.STRING
|
|
259
263
|
},
|
|
260
|
-
// Remote function arguments (currently supporting up to
|
|
261
|
-
{
|
|
262
|
-
argumentType: FunctionArgumentType.ANY,
|
|
263
|
-
optionalArg: true
|
|
264
|
-
},
|
|
264
|
+
// Remote function arguments (currently supporting up to 8).
|
|
265
265
|
{
|
|
266
266
|
argumentType: FunctionArgumentType.ANY,
|
|
267
267
|
optionalArg: true
|
|
@@ -2686,34 +2686,30 @@ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/s
|
|
|
2686
2686
|
var OBJECT_ID_LENGTH = 60;
|
|
2687
2687
|
var CUSTOM_FUNCTION = "ECHO";
|
|
2688
2688
|
var defaultOptions = {
|
|
2689
|
-
licenseKey: "gpl-v3"
|
|
2690
|
-
plugins: [
|
|
2691
|
-
{
|
|
2692
|
-
plugin: EdgeFunctionPlugin,
|
|
2693
|
-
translations: EdgeFunctionPluginTranslations
|
|
2694
|
-
}
|
|
2695
|
-
]
|
|
2689
|
+
licenseKey: "gpl-v3"
|
|
2696
2690
|
};
|
|
2691
|
+
var defaultPlugins = [
|
|
2692
|
+
{
|
|
2693
|
+
plugin: EdgeFunctionPlugin,
|
|
2694
|
+
translations: EdgeFunctionPluginTranslations
|
|
2695
|
+
}
|
|
2696
|
+
];
|
|
2697
2697
|
var PREFIX = "__";
|
|
2698
2698
|
var createSheetName = (id) => `${PREFIX}${id}`;
|
|
2699
2699
|
var getSheetId = (name) => name.startsWith(PREFIX) ? name.slice(PREFIX.length) : void 0;
|
|
2700
|
-
var createComputeGraphRegistry = (options = {}) => {
|
|
2701
|
-
return new ComputeGraphRegistry({
|
|
2702
|
-
...defaultOptions,
|
|
2703
|
-
...options
|
|
2704
|
-
});
|
|
2705
|
-
};
|
|
2706
2700
|
var ComputeGraphRegistry = class extends Resource2 {
|
|
2707
|
-
constructor(
|
|
2701
|
+
constructor(options = {
|
|
2702
|
+
plugins: defaultPlugins
|
|
2703
|
+
}) {
|
|
2708
2704
|
super();
|
|
2709
|
-
this.
|
|
2710
|
-
this.
|
|
2705
|
+
this._graphs = /* @__PURE__ */ new Map();
|
|
2706
|
+
this._options = defaultsDeep2({}, options, defaultOptions);
|
|
2711
2707
|
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
2712
2708
|
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
2713
2709
|
});
|
|
2714
2710
|
}
|
|
2715
2711
|
getGraph(spaceId) {
|
|
2716
|
-
return this.
|
|
2712
|
+
return this._graphs.get(spaceId);
|
|
2717
2713
|
}
|
|
2718
2714
|
async getOrCreateGraph(space) {
|
|
2719
2715
|
let graph = this.getGraph(space.id);
|
|
@@ -2722,7 +2718,7 @@ var ComputeGraphRegistry = class extends Resource2 {
|
|
|
2722
2718
|
space: space.id
|
|
2723
2719
|
}, {
|
|
2724
2720
|
F: __dxlog_file3,
|
|
2725
|
-
L:
|
|
2721
|
+
L: 93,
|
|
2726
2722
|
S: this,
|
|
2727
2723
|
C: (f, a) => f(...a)
|
|
2728
2724
|
});
|
|
@@ -2731,21 +2727,26 @@ var ComputeGraphRegistry = class extends Resource2 {
|
|
|
2731
2727
|
return graph;
|
|
2732
2728
|
}
|
|
2733
2729
|
async createGraph(space) {
|
|
2734
|
-
invariant(!this.
|
|
2730
|
+
invariant(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
2735
2731
|
F: __dxlog_file3,
|
|
2736
|
-
L:
|
|
2732
|
+
L: 101,
|
|
2737
2733
|
S: this,
|
|
2738
2734
|
A: [
|
|
2739
|
-
"!this.
|
|
2735
|
+
"!this._graphs.has(space.id)",
|
|
2740
2736
|
"`ComputeGraph already exists for space: ${space.id}`"
|
|
2741
2737
|
]
|
|
2742
2738
|
});
|
|
2743
2739
|
const hf = HyperFormula.buildEmpty(this._options);
|
|
2744
2740
|
const graph = new ComputeGraph(hf, space, this._options);
|
|
2745
|
-
|
|
2746
|
-
|
|
2741
|
+
this._graphs.set(space.id, graph);
|
|
2742
|
+
await graph.open();
|
|
2747
2743
|
return graph;
|
|
2748
2744
|
}
|
|
2745
|
+
async _close() {
|
|
2746
|
+
for (const graph of this._graphs.values()) {
|
|
2747
|
+
await graph.close();
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2749
2750
|
};
|
|
2750
2751
|
var ComputeGraph = class extends Resource2 {
|
|
2751
2752
|
constructor(_hf, _space, _options) {
|
|
@@ -2756,28 +2757,39 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2756
2757
|
this.id = `graph-${PublicKey.random().truncate()}`;
|
|
2757
2758
|
this._nodes = /* @__PURE__ */ new Map();
|
|
2758
2759
|
this._functions = [];
|
|
2759
|
-
this.context = new FunctionContext(this._hf, this._space, this.refresh.bind(this), this._options);
|
|
2760
2760
|
this.update = new Event2();
|
|
2761
|
+
this.context = new FunctionContext(this._hf, this._space, this._options);
|
|
2761
2762
|
this._hf.updateConfig({
|
|
2762
2763
|
context: this.context
|
|
2763
2764
|
});
|
|
2765
|
+
const onValuesUpdate = (changes) => {
|
|
2766
|
+
for (const change of changes) {
|
|
2767
|
+
if (change instanceof ExportedCellChange) {
|
|
2768
|
+
const { sheet } = change;
|
|
2769
|
+
const node = this._nodes.get(sheet);
|
|
2770
|
+
if (node) {
|
|
2771
|
+
node.update.emit({
|
|
2772
|
+
type: "valuesUpdated",
|
|
2773
|
+
change
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
};
|
|
2779
|
+
this._hf.on("valuesUpdated", onValuesUpdate);
|
|
2780
|
+
this._ctx.onDispose(() => this._hf.off("valuesUpdated", onValuesUpdate));
|
|
2764
2781
|
}
|
|
2765
|
-
// TODO(burdon): Remove.
|
|
2766
2782
|
get hf() {
|
|
2767
2783
|
return this._hf;
|
|
2768
2784
|
}
|
|
2769
|
-
refresh() {
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
});
|
|
2778
|
-
this.update.emit();
|
|
2779
|
-
}
|
|
2780
|
-
getFunctions({ standard = true, echo = true } = {}) {
|
|
2785
|
+
// refresh() {
|
|
2786
|
+
// log('refresh', { id: this.id });
|
|
2787
|
+
// this.update.emit();
|
|
2788
|
+
// }
|
|
2789
|
+
getFunctions({ standard, echo } = {
|
|
2790
|
+
standard: true,
|
|
2791
|
+
echo: true
|
|
2792
|
+
}) {
|
|
2781
2793
|
return [
|
|
2782
2794
|
...standard ? this._hf.getRegisteredFunctionNames().map((name) => defaultFunctions.find((fn) => fn.name === name) ?? {
|
|
2783
2795
|
name
|
|
@@ -2795,10 +2807,10 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2795
2807
|
// This would enable on-the-fly instantiation of new models when then are referenced.
|
|
2796
2808
|
// E.g., Cross-object reference would be stored as "ObjectId!A1"
|
|
2797
2809
|
// The graph would then load the object and create a ComputeNode (model) of the appropriate type.
|
|
2798
|
-
getOrCreateNode(name) {
|
|
2810
|
+
async getOrCreateNode(name) {
|
|
2799
2811
|
invariant(name.length, void 0, {
|
|
2800
2812
|
F: __dxlog_file3,
|
|
2801
|
-
L:
|
|
2813
|
+
L: 193,
|
|
2802
2814
|
S: this,
|
|
2803
2815
|
A: [
|
|
2804
2816
|
"name.length",
|
|
@@ -2811,17 +2823,16 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2811
2823
|
name
|
|
2812
2824
|
}, {
|
|
2813
2825
|
F: __dxlog_file3,
|
|
2814
|
-
L:
|
|
2826
|
+
L: 195,
|
|
2815
2827
|
S: this,
|
|
2816
2828
|
C: (f, a) => f(...a)
|
|
2817
2829
|
});
|
|
2818
2830
|
this._hf.addSheet(name);
|
|
2819
|
-
this.update.emit();
|
|
2820
2831
|
}
|
|
2821
2832
|
const sheetId = this._hf.getSheetId(name);
|
|
2822
2833
|
invariant(sheetId !== void 0, void 0, {
|
|
2823
2834
|
F: __dxlog_file3,
|
|
2824
|
-
L:
|
|
2835
|
+
L: 201,
|
|
2825
2836
|
S: this,
|
|
2826
2837
|
A: [
|
|
2827
2838
|
"sheetId !== undefined",
|
|
@@ -2829,6 +2840,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2829
2840
|
]
|
|
2830
2841
|
});
|
|
2831
2842
|
const node = new ComputeNode(this, sheetId);
|
|
2843
|
+
await node.open();
|
|
2832
2844
|
this._nodes.set(sheetId, node);
|
|
2833
2845
|
return node;
|
|
2834
2846
|
}
|
|
@@ -2903,21 +2915,28 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2903
2915
|
const query = this._space.db.query(Filter2.schema(FunctionType2));
|
|
2904
2916
|
const unsubscribe = query.subscribe(({ objects }) => {
|
|
2905
2917
|
this._functions = objects.filter(({ binding }) => binding);
|
|
2906
|
-
this.update.emit(
|
|
2918
|
+
this.update.emit({
|
|
2919
|
+
type: "functionsUpdated"
|
|
2920
|
+
});
|
|
2907
2921
|
});
|
|
2908
2922
|
this._ctx.onDispose(unsubscribe);
|
|
2909
2923
|
}
|
|
2910
2924
|
}
|
|
2925
|
+
async _close() {
|
|
2926
|
+
for (const node of this._nodes.values()) {
|
|
2927
|
+
await node.close();
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2911
2930
|
};
|
|
2912
2931
|
|
|
2913
2932
|
export {
|
|
2914
2933
|
ComputeNode,
|
|
2915
2934
|
defaultFunctions,
|
|
2916
2935
|
defaultOptions,
|
|
2936
|
+
defaultPlugins,
|
|
2917
2937
|
createSheetName,
|
|
2918
2938
|
getSheetId,
|
|
2919
|
-
createComputeGraphRegistry,
|
|
2920
2939
|
ComputeGraphRegistry,
|
|
2921
2940
|
ComputeGraph
|
|
2922
2941
|
};
|
|
2923
|
-
//# sourceMappingURL=chunk-
|
|
2942
|
+
//# sourceMappingURL=chunk-Z2XOOC2R.mjs.map
|