@dxos/app-framework 0.7.4 → 0.7.5-main.9cb18ac
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/chunk-QG25ZU2N.mjs +320 -0
- package/dist/lib/browser/chunk-QG25ZU2N.mjs.map +7 -0
- package/dist/lib/browser/chunk-SPDTXTOV.mjs +163 -0
- package/dist/lib/browser/chunk-SPDTXTOV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-653Y45CL.mjs → chunk-WBOXEHBE.mjs} +12 -2
- package/dist/lib/browser/chunk-WBOXEHBE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +224 -109
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{plugin-intent-LU4KL2RO.mjs → plugin-intent-T7Y3MJ5C.mjs} +14 -4
- package/dist/lib/browser/{plugin-settings-OM3G2QFY.mjs → plugin-settings-5U2L2NRU.mjs} +6 -2
- package/dist/lib/browser/{plugin-surface-LECZMKSQ.mjs → plugin-surface-OKPF3EQI.mjs} +4 -4
- package/dist/lib/node/{chunk-SOVLKUWI.cjs → chunk-BW3RNEVI.cjs} +51 -102
- package/dist/lib/node/chunk-BW3RNEVI.cjs.map +7 -0
- package/dist/lib/node/{chunk-JZ2JVKRY.cjs → chunk-FCMHRU3M.cjs} +17 -5
- package/dist/lib/node/chunk-FCMHRU3M.cjs.map +7 -0
- package/dist/lib/node/chunk-VWHAALIN.cjs +344 -0
- package/dist/lib/node/chunk-VWHAALIN.cjs.map +7 -0
- package/dist/lib/node/index.cjs +232 -114
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs +53 -0
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs.map +7 -0
- package/dist/lib/node/{plugin-settings-OZ6IKAE5.cjs → plugin-settings-W6UHMH5M.cjs} +12 -8
- package/dist/lib/node/plugin-settings-W6UHMH5M.cjs.map +7 -0
- package/dist/lib/node/{plugin-surface-YWDRXQTD.cjs → plugin-surface-CCSIONYW.cjs} +15 -15
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YNU7FTGJ.mjs → chunk-3T5UIJY3.mjs} +12 -2
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs +164 -0
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs +321 -0
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +224 -109
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{plugin-intent-V7ER24Y6.mjs → plugin-intent-W2HQC6LC.mjs} +14 -4
- package/dist/lib/node-esm/{plugin-settings-37UVWF2V.mjs → plugin-settings-H5RHNFVC.mjs} +6 -2
- package/dist/lib/node-esm/{plugin-surface-TEU42XQN.mjs → plugin-surface-V3YET3UL.mjs} +4 -4
- package/dist/types/src/plugins/common/layout.d.ts +145 -171
- package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
- package/dist/types/src/plugins/common/navigation.d.ts +77 -30
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +2 -7
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-host/index.d.ts +2 -0
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts +7 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +7 -20
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-intent/index.d.ts +1 -0
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts +107 -0
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts +2 -0
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-intent/intent.d.ts +65 -58
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-intent/meta.d.ts +1 -0
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-intent/provides.d.ts +6 -10
- package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-settings/provides.d.ts +15 -2
- package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts +2 -57
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-surface/SurfaceContext.d.ts +85 -0
- package/dist/types/src/plugins/plugin-surface/SurfaceContext.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-surface/index.d.ts +1 -1
- package/dist/types/src/plugins/plugin-surface/index.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-surface/provides.d.ts +5 -4
- package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +14 -12
- package/src/plugins/common/layout.ts +125 -107
- package/src/plugins/common/navigation.ts +59 -30
- package/src/plugins/plugin-host/HostPlugin.tsx +2 -10
- package/src/plugins/plugin-host/PluginContainer.tsx +1 -1
- package/src/plugins/plugin-host/index.ts +4 -0
- package/src/plugins/plugin-host/plugin.ts +8 -1
- package/src/plugins/plugin-intent/IntentContext.tsx +13 -36
- package/src/plugins/plugin-intent/IntentPlugin.tsx +44 -120
- package/src/plugins/plugin-intent/index.ts +1 -0
- package/src/plugins/plugin-intent/intent-dispatcher.test.ts +279 -0
- package/src/plugins/plugin-intent/intent-dispatcher.ts +285 -0
- package/src/plugins/plugin-intent/intent.ts +126 -65
- package/src/plugins/plugin-intent/meta.ts +3 -1
- package/src/plugins/plugin-intent/provides.ts +8 -20
- package/src/plugins/plugin-settings/provides.ts +10 -5
- package/src/plugins/plugin-surface/Surface.tsx +25 -158
- package/src/plugins/plugin-surface/SurfaceContext.ts +112 -0
- package/src/plugins/plugin-surface/SurfacePlugin.tsx +19 -7
- package/src/plugins/plugin-surface/index.ts +1 -1
- package/src/plugins/plugin-surface/provides.ts +8 -7
- package/tsconfig.json +38 -1
- package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
- package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
- package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
- package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
- package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
- package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
- package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
- package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
- package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
- package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
- package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
- package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
- package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
- package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
- package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
- package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
- package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
- package/src/plugins/plugin-intent/helpers.ts +0 -11
- package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
- /package/dist/lib/browser/{plugin-intent-LU4KL2RO.mjs.map → plugin-intent-T7Y3MJ5C.mjs.map} +0 -0
- /package/dist/lib/browser/{plugin-settings-OM3G2QFY.mjs.map → plugin-settings-5U2L2NRU.mjs.map} +0 -0
- /package/dist/lib/browser/{plugin-surface-LECZMKSQ.mjs.map → plugin-surface-OKPF3EQI.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-intent-V7ER24Y6.mjs.map → plugin-intent-W2HQC6LC.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-settings-37UVWF2V.mjs.map → plugin-settings-H5RHNFVC.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-surface-TEU42XQN.mjs.map → plugin-surface-V3YET3UL.mjs.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/plugin-intent/IntentPlugin.tsx", "../../../src/plugins/plugin-intent/IntentContext.tsx", "../../../src/plugins/plugin-intent/intent-dispatcher.ts", "../../../src/plugins/plugin-intent/intent.ts", "../../../src/plugins/plugin-intent/meta.ts", "../../../src/plugins/plugin-intent/provides.ts", "../../../src/plugins/plugin-intent/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Effect } from 'effect';\nimport React from 'react';\n\nimport { create } from '@dxos/live-object';\n\nimport { IntentProvider } from './IntentContext';\nimport { createDispatcher, type AnyIntentResolver, type IntentContext } from './intent-dispatcher';\nimport IntentMeta from './meta';\nimport { type IntentPluginProvides, type ResolverDefinitions, parseIntentResolverPlugin } from './provides';\nimport { filterPlugins } from '../helpers';\nimport { type PluginDefinition } from '../plugin-host';\n\nconst defaultEffect = () => Effect.fail(new Error('Intent runtime not ready'));\nconst defaultPromise = () => Effect.runPromise(defaultEffect());\n\n/**\n * Allows plugins to register intent handlers and routes sent intents to the appropriate plugin.\n * Inspired by https://developer.android.com/reference/android/content/Intent.\n */\nexport const IntentPlugin = (): PluginDefinition<IntentPluginProvides> => {\n const state = create<IntentContext>({\n dispatch: defaultEffect,\n dispatchPromise: defaultPromise,\n undo: defaultEffect,\n undoPromise: defaultPromise,\n registerResolver: () => () => {},\n });\n\n return {\n meta: IntentMeta,\n ready: async ({ plugins }) => {\n const resolvers = Object.fromEntries(\n filterPlugins(plugins, parseIntentResolverPlugin).map((plugin): [string, AnyIntentResolver[]] => {\n const resolvers = reduceResolvers(\n plugin.provides.intent.resolvers({\n plugins,\n dispatch: (intent) => state.dispatch(intent),\n dispatchPromise: (intent) => state.dispatchPromise(intent),\n undo: () => state.undo(),\n undoPromise: () => state.undoPromise(),\n registerResolver: (id, resolver) => state.registerResolver(id, resolver),\n }),\n );\n return [plugin.meta.id, resolvers];\n }),\n );\n const { dispatch, dispatchPromise, undo, undoPromise, registerResolver } = createDispatcher(resolvers);\n\n state.dispatch = dispatch;\n state.dispatchPromise = dispatchPromise;\n state.undo = undo;\n state.undoPromise = undoPromise;\n state.registerResolver = registerResolver;\n },\n provides: {\n intent: state,\n context: ({ children }) => <IntentProvider value={state}>{children}</IntentProvider>,\n },\n };\n};\n\nconst reduceResolvers = (\n definitions: ResolverDefinitions,\n resolvers: AnyIntentResolver[] = [],\n): AnyIntentResolver[] => {\n if (Array.isArray(definitions)) {\n return definitions.reduce((acc: AnyIntentResolver[], definition) => reduceResolvers(definition, acc), resolvers);\n }\n\n return [...resolvers, definitions];\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider, useEffect } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { pick } from '@dxos/util';\n\nimport { type AnyIntentResolver, type IntentContext } from './intent-dispatcher';\n\nconst IntentContext: Context<IntentContext | undefined> = createContext<IntentContext | undefined>(undefined);\n\nexport const useIntentDispatcher = (): Pick<IntentContext, 'dispatch' | 'dispatchPromise'> => {\n const context = useContext(IntentContext) ?? raise(new Error('IntentContext not found'));\n return pick(context, ['dispatch', 'dispatchPromise']);\n};\n\nexport const useIntentResolver = (pluginId: string, resolver: AnyIntentResolver) => {\n const { registerResolver } = useContext(IntentContext) ?? raise(new Error('IntentContext not found'));\n useEffect(() => {\n return registerResolver(pluginId, resolver);\n }, [pluginId, resolver]);\n};\n\nexport const IntentProvider: Provider<IntentContext | undefined> = IntentContext.Provider;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Effect, Ref } from 'effect';\n\nimport { type MaybePromise, pick } from '@dxos/util';\n\nimport {\n createIntent,\n IntentAction,\n type AnyIntent,\n type AnyIntentChain,\n type Intent,\n type IntentChain,\n type IntentData,\n type IntentParams,\n type IntentResultData,\n type IntentSchema,\n type Label,\n} from './intent';\n\nconst EXECUTION_LIMIT = 100;\nconst HISTORY_LIMIT = 100;\n\n/**\n * The return value of an intent effect.\n */\nexport type IntentEffectResult<Fields extends IntentParams> = {\n /**\n * The output of the action that was performed.\n *\n * If the intent is apart of a chain of intents, the data will be passed to the next intent.\n */\n data?: IntentResultData<Fields>;\n\n /**\n * If provided, the action will be undoable.\n */\n undoable?: {\n /**\n * Message to display to the user when indicating that the action can be undone.\n */\n message: Label;\n\n /**\n * Will be merged with the original intent data when firing the undo intent.\n */\n data?: Partial<IntentData<Fields>>;\n };\n\n /**\n * An error that occurred while performing the action.\n *\n * If the intent is apart of a chain of intents and an error occurs, the chain will be aborted.\n */\n error?: Error;\n\n /**\n * Other intent chains to be triggered.\n */\n intents?: AnyIntentChain[];\n};\n\nexport type AnyIntentEffectResult = IntentEffectResult<any>;\n\n/**\n * The result of an intent dispatcher.\n */\nexport type IntentDispatcherResult<Fields extends IntentParams> = Pick<IntentEffectResult<Fields>, 'data' | 'error'>;\n\n/**\n * Determines the priority of the effect when multiple intent resolvers are matched.\n *\n * - `static` - The effect is selected in the order it was resolved.\n * - `hoist` - The effect is selected before `static` effects.\n * - `fallback` - The effect is selected after `static` effects.\n */\nexport type IntentDisposition = 'static' | 'hoist' | 'fallback';\n\n/**\n * The implementation of an intent effect.\n */\nexport type IntentEffectDefinition<Fields extends IntentParams> = (\n data: IntentData<Fields>,\n undo: boolean,\n) => MaybePromise<IntentEffectResult<Fields> | void> | Effect.Effect<IntentEffectResult<Fields> | void>;\n\n/**\n * Intent resolver to match intents to their effects.\n */\nexport type IntentResolver<Tag extends string, Fields extends IntentParams> = {\n action: Tag;\n disposition?: IntentDisposition;\n // TODO(wittjosiah): Would be nice to make this a guard for intents with optional data.\n filter?: (data: IntentData<Fields>) => boolean;\n effect: IntentEffectDefinition<Fields>;\n};\n\nexport type AnyIntentResolver = IntentResolver<any, any>;\n\n/**\n * Creates an intent resolver to match intents to their effects.\n * @param schema Schema of the intent. Must be a tagged class with input and output schemas.\n * @param effect Effect to be performed when the intent is resolved.\n * @param params.disposition Determines the priority of the resolver when multiple are resolved.\n * @param params.filter Optional filter to determine if the resolver should be used.\n */\nexport const createResolver = <Tag extends string, Fields extends IntentParams>(\n schema: IntentSchema<Tag, Fields>,\n effect: IntentEffectDefinition<Fields>,\n params: Pick<IntentResolver<Tag, Fields>, 'disposition' | 'filter'> = {},\n): IntentResolver<Tag, Fields> => ({\n action: schema._tag,\n effect,\n ...params,\n});\n\n/**\n * Invokes intents and returns the result.\n */\nexport type PromiseIntentDispatcher = <Fields extends IntentParams>(\n intent: IntentChain<any, any, any, Fields>,\n) => Promise<IntentDispatcherResult<Fields>>;\n\n/**\n * Creates an effect for intents.\n */\nexport type IntentDispatcher = <Fields extends IntentParams>(\n intent: IntentChain<any, any, any, Fields>,\n depth?: number,\n) => Effect.Effect<IntentDispatcherResult<Fields>, Error>;\n\ntype IntentResult<Tag extends string, Fields extends IntentParams> = IntentEffectResult<Fields> & {\n _intent: Intent<Tag, Fields>;\n};\n\ntype AnyIntentResult = IntentResult<any, any>;\n\n/**\n * Invokes the most recent undoable intent with undo flags.\n */\nexport type PromiseIntentUndo = () => Promise<IntentDispatcherResult<any> | undefined>;\n\n/**\n * Creates an effect which undoes the last intent.\n */\nexport type IntentUndo = () => Effect.Effect<IntentDispatcherResult<any> | undefined, Error>;\n\n/**\n * Check if a chain of results is undoable.\n */\nconst isUndoable = (historyEntry: AnyIntentResult[]): boolean =>\n historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n dispatchPromise: PromiseIntentDispatcher;\n undo: IntentUndo;\n undoPromise: PromiseIntentUndo;\n registerResolver: (id: string, resolver: AnyIntentResolver) => () => void;\n};\n\n/**\n * Sets of an intent dispatcher.\n *\n * @param resolvers An array of available intent resolvers.\n * @param params.historyLimit The maximum number of intent results to keep in history.\n * @param params.executionLimit The maximum recursion depth of intent chains.\n */\nexport const createDispatcher = (\n resolvers: Record<string, AnyIntentResolver[]>,\n { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {},\n): IntentContext => {\n const historyRef = Effect.runSync(Ref.make<AnyIntentResult[][]>([]));\n\n const handleIntent = (intent: AnyIntent) => {\n return Effect.gen(function* () {\n const candidates = Object.entries(resolvers)\n .filter(([id, _]) => (intent.plugin ? id === intent.plugin : true))\n .flatMap(([_, resolvers]) => resolvers)\n .filter((r) => r.action === intent.action)\n .filter((r) => !r.filter || r.filter(intent.data))\n .toSorted(({ disposition: a = 'static' }, { disposition: b = 'static' }) => {\n return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;\n });\n if (candidates.length === 0) {\n return {\n _intent: intent,\n error: new Error(`No resolver found for action: ${intent.action}`),\n } satisfies AnyIntentResult;\n }\n\n const effect = candidates[0].effect(intent.data, intent.undo ?? false);\n const result = Effect.isEffect(effect) ? yield* effect : yield* Effect.promise(async () => effect);\n return { _intent: intent, ...result } satisfies AnyIntentResult;\n });\n };\n\n const dispatch: IntentDispatcher = (intentChain, depth = 0) => {\n return Effect.gen(function* () {\n if (depth > executionLimit) {\n yield* Effect.fail(\n new Error('Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.'),\n );\n }\n\n const resultsRef = yield* Ref.make<AnyIntentResult[]>([]);\n for (const intent of intentChain.all) {\n const { data: prev } = (yield* resultsRef.get)[0] ?? {};\n const result = yield* handleIntent({ ...intent, data: { ...intent.data, ...prev } });\n yield* Ref.update(resultsRef, (results) => [result, ...results]);\n if (result.error) {\n break;\n }\n if (result.intents) {\n for (const intent of result.intents) {\n // Returned intents are dispatched but not yielded into results,\n // as such they cannot be undone.\n // TODO(wittjosiah): Use higher execution concurrency?\n yield* dispatch(intent, depth + 1);\n }\n }\n }\n\n const results = yield* resultsRef.get;\n const result = results[0];\n if (result) {\n yield* Ref.update(historyRef, (history) => {\n const next = [...history, results];\n if (next.length > historyLimit) {\n next.splice(0, next.length - historyLimit);\n }\n return next;\n });\n\n if (result.undoable && isUndoable(results)) {\n // TODO(wittjosiah): Is there a better way to handle showing undo for chains?\n yield* dispatch(createIntent(IntentAction.ShowUndo, { message: result.undoable.message }));\n }\n\n return pick(result, ['data', 'error']);\n } else {\n return { data: {}, error: new Error('No results') };\n }\n });\n };\n\n const dispatchPromise: PromiseIntentDispatcher = (intentChain) => {\n const program = dispatch(intentChain);\n return Effect.runPromise(program);\n };\n\n const undo: IntentUndo = () => {\n return Effect.gen(function* () {\n const history = yield* historyRef.get;\n const last = history.findLastIndex(isUndoable);\n const result = last !== -1 ? history[last] : undefined;\n if (result) {\n const all = result.map(({ _intent, undoable }): AnyIntent => {\n const data = _intent.data;\n const undoData = undoable?.data ?? {};\n return { ..._intent, data: { ...data, ...undoData }, undo: true } satisfies AnyIntent;\n });\n const intent = { first: all[0], last: all.at(-1)!, all } satisfies AnyIntentChain;\n yield* Ref.update(historyRef, (h) => h.filter((_, index) => index !== last));\n return yield* dispatch(intent);\n }\n });\n };\n\n const undoPromise: PromiseIntentUndo = () => {\n const program = undo();\n return Effect.runPromise(program);\n };\n\n const registerResolver = (id: string, resolver: AnyIntentResolver) => {\n resolvers[id] = [...(resolvers[id] ?? []), resolver];\n return () => {\n resolvers[id] = resolvers[id].filter((r) => r !== resolver);\n };\n };\n\n return { dispatch, dispatchPromise, undo, undoPromise, registerResolver };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { S } from '@dxos/echo-schema';\n\nimport { INTENT_PLUGIN } from './meta';\n\nexport type IntentParams = {\n readonly input: S.Schema.All;\n readonly output: S.Schema.All;\n};\n\nexport type IntentData<Fields extends IntentParams> =\n S.Schema.Type<S.Struct<Fields>> extends { readonly input: any } ? S.Schema.Type<S.Struct<Fields>>['input'] : any;\n\nexport type IntentResultData<Fields extends IntentParams> =\n S.Schema.Type<S.Struct<Fields>> extends { readonly output: any } ? S.Schema.Type<S.Struct<Fields>>['output'] : any;\n\nexport type IntentSchema<Tag extends string, Fields extends IntentParams> = S.TaggedClass<any, Tag, Fields>;\n\n/**\n * An intent is an abstract description of an operation to be performed.\n * Intents allow actions to be performed across plugins.\n */\nexport type Intent<Tag extends string, Fields extends IntentParams> = {\n _schema: IntentSchema<Tag, Fields>;\n\n /**\n * The action to perform.\n */\n action: Tag;\n\n /**\n * Any data needed to perform the desired action.\n */\n data: IntentData<Fields>;\n\n /**\n * Plugin ID.\n * If specified, the intent will be sent explicitly to the plugin.\n * Otherwise, the intent will be sent to all plugins, in order and the first to resolve a non-null value will be used.\n */\n plugin?: string;\n\n /**\n * Whether or not the intent is being undone.\n */\n undo?: boolean;\n};\n\nexport type AnyIntent = Intent<any, any>;\n\n/**\n * Chain of intents to be executed together.\n * The result of each intent is merged into the next intent's input data.\n */\nexport type IntentChain<\n FirstTag extends string,\n LastTag extends string,\n FirstFields extends IntentParams,\n LastFields extends IntentParams,\n> = {\n first: Intent<FirstTag, FirstFields>;\n last: Intent<LastTag, LastFields>;\n all: AnyIntent[];\n};\n\nexport type AnyIntentChain = IntentChain<any, any, any, any>;\n\n/**\n * Creates a typed intent.\n * @param schema Schema of the intent. Must be a tagged class with input and output schemas.\n * @param data Data fulfilling the input schema of the intent.\n * @param params.plugin Optional plugin ID to send the intent to.\n * @param params.undo Optional flag to indicate that the intent is being undone. Generally not set manually.\n */\nexport const createIntent = <Tag extends string, Fields extends IntentParams>(\n schema: IntentSchema<Tag, Fields>,\n data: IntentData<Fields> = {},\n params: Pick<AnyIntent, 'plugin' | 'undo'> = {},\n): IntentChain<Tag, Tag, Fields, Fields> => {\n // The output of validateSync breaks proxy objects so this is just used for validation.\n // TODO(wittjosiah): Is there a better way to make theses types align?\n const _ = S.validateSync(schema.fields.input as S.Schema<any, any, unknown>)(data);\n const intent = {\n ...params,\n _schema: schema,\n action: schema._tag,\n data,\n } satisfies Intent<Tag, Fields>;\n\n return {\n first: intent,\n last: intent,\n all: [intent],\n };\n};\n\n// TODO(wittjosiah): Add a function for mapping the output of one intent to the input of another.\n\n/**\n * Chain two intents together.\n *\n * NOTE: Chaining of intents depends on the data inputs and outputs being structs.\n */\nexport const chain =\n <\n FirstTag extends string,\n NextTag extends string,\n FirstFields extends IntentParams,\n LastFields extends IntentParams,\n NextFields extends IntentParams,\n >(\n schema: IntentSchema<NextTag, NextFields>,\n data: Omit<IntentData<NextFields>, keyof IntentResultData<LastFields>> = {},\n params: Pick<AnyIntent, 'plugin' | 'undo'> = {},\n ) =>\n (\n intent: IntentChain<FirstTag, any, FirstFields, LastFields>,\n ): IntentChain<FirstTag, NextTag, FirstFields, NextFields> => {\n const intents = 'all' in intent ? intent.all : [intent];\n const first = intents[0];\n const last = {\n ...params,\n _schema: schema,\n action: schema._tag,\n data,\n } satisfies Intent<NextTag, NextFields>;\n\n return {\n first,\n last,\n all: [...intents, last],\n };\n };\n\n//\n// Intents\n//\n\n// NOTE: Should maintain compatibility with `i18next` (and @dxos/react-ui).\n// TODO(wittjosiah): Making this immutable breaks type compatibility.\nexport const Label = S.Union(\n S.String,\n S.mutable(S.Tuple(S.String, S.mutable(S.Struct({ ns: S.String, count: S.optional(S.Number) })))),\n);\nexport type Label = S.Schema.Type<typeof Label>;\n\nexport const INTENT_ACTION = `${INTENT_PLUGIN}/action`;\n\nexport namespace IntentAction {\n /**\n * Fired after an intent is dispatched if the intent is undoable.\n */\n export class ShowUndo extends S.TaggedClass<ShowUndo>()(`${INTENT_ACTION}/show-undo`, {\n input: S.Struct({\n message: Label,\n }),\n output: S.Void,\n }) {}\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const INTENT_PLUGIN = 'dxos.org/plugin/intent';\n\nconst IntentMeta = {\n id: INTENT_PLUGIN,\n};\n\nexport default IntentMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type IntentContext, type AnyIntentResolver } from './intent-dispatcher';\nimport { type HostContext, type Plugin } from '../plugin-host';\n\ntype Context = HostContext & IntentContext;\n\nexport type ResolverDefinitions = AnyIntentResolver | AnyIntentResolver[] | ResolverDefinitions[];\n\nexport type IntentResolverProvides = {\n intent: {\n resolvers: (context: Context) => ResolverDefinitions;\n };\n};\n\nexport type IntentPluginProvides = {\n intent: IntentContext;\n};\n\nexport const parseIntentPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.dispatch ? (plugin as Plugin<IntentPluginProvides>) : undefined;\n\nexport const parseIntentResolverPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.resolvers ? (plugin as Plugin<IntentResolverProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { IntentPlugin } from './IntentPlugin';\n\nexport * from './intent';\nexport * from './intent-dispatcher';\nexport * from './provides';\n\nexport * from './IntentContext';\n\nexport default IntentPlugin;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAuB;AACvB,mBAAkB;AAElB,yBAAuB;ACHvB,IAAAA,gBAAkF;AAElF,mBAAsB;AACtB,kBAAqB;ACHrB,IAAAC,iBAA4B;AAE5B,IAAAC,eAAwC;ACFxC,yBAAkB;AFOlB,IAAMC,gBAAoDC,iDAAyCC,MAAAA;AAE5F,IAAMC,sBAAsB,MAAA;AACjC,QAAMC,cAAUC,0BAAWL,aAAAA,SAAkBM,oBAAM,IAAIC,MAAM,yBAAA,CAAA;AAC7D,aAAOC,kBAAKJ,SAAS;IAAC;IAAY;GAAkB;AACtD;AAEO,IAAMK,oBAAoB,CAACC,UAAkBC,aAAAA;AAClD,QAAM,EAAEC,iBAAgB,QAAKP,0BAAWL,aAAAA,SAAkBM,oBAAM,IAAIC,MAAM,yBAAA,CAAA;AAC1EM,+BAAU,MAAA;AACR,WAAOD,iBAAiBF,UAAUC,QAAAA;EACpC,GAAG;IAACD;IAAUC;GAAS;AACzB;AAEO,IAAMG,iBAAsDd,cAAce;AGrB1E,IAAMC,gBAAgB;AAE7B,IAAMC,aAAa;EACjBC,IAAIF;AACN;AAEA,IAAA,eAAeC;ADmER,IAAME,eAAe,CAC1BC,QACAC,OAA2B,CAAC,GAC5BC,SAA6C,CAAC,MAAC;AAI/C,QAAMC,IAAIC,qBAAEC,aAAaL,OAAOM,OAAOC,KAAK,EAAiCN,IAAAA;AAC7E,QAAMO,SAAS;IACb,GAAGN;IACHO,SAAST;IACTU,QAAQV,OAAOW;IACfV;EACF;AAEA,SAAO;IACLW,OAAOJ;IACPK,MAAML;IACNM,KAAK;MAACN;;EACR;AACF;AASO,IAAMO,QACX,CAOEf,QACAC,OAAyE,CAAC,GAC1EC,SAA6C,CAAC,MAEhD,CACEM,WAAAA;A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AAA;IAC5D;EACF;AACF;AAEA,IAAMD,kBAAkB,CACtBI,aACAlE,YAAiC,CAAA,MAAE;AAEnC,MAAImE,MAAMC,QAAQF,WAAAA,GAAc;AAC9B,WAAOA,YAAYG,OAAO,CAACC,KAA0BC,eAAeT,gBAAgBS,YAAYD,GAAAA,GAAMtE,SAAAA;EACxG;AAEA,SAAO;OAAIA;IAAWkE;;AACxB;AM9DA,IAAA,wBAAeZ;",
|
|
6
|
+
"names": ["import_react", "import_effect", "import_util", "IntentContext", "createContext", "undefined", "useIntentDispatcher", "context", "useContext", "raise", "Error", "pick", "useIntentResolver", "pluginId", "resolver", "registerResolver", "useEffect", "IntentProvider", "Provider", "INTENT_PLUGIN", "IntentMeta", "id", "createIntent", "schema", "data", "params", "_", "S", "validateSync", "fields", "input", "intent", "_schema", "action", "_tag", "first", "last", "all", "chain", "intents", "Label", "Union", "String", "mutable", "Tuple", "Struct", "ns", "count", "optional", "Number", "INTENT_ACTION", "IntentAction", "ShowUndo", "TaggedClass", "message", "output", "Void", "EXECUTION_LIMIT", "HISTORY_LIMIT", "createResolver", "effect", "isUndoable", "historyEntry", "length", "every", "undoable", "createDispatcher", "resolvers", "executionLimit", "historyLimit", "historyRef", "Effect", "runSync", "Ref", "make", "handleIntent", "gen", "candidates", "Object", "entries", "filter", "plugin", "flatMap", "r", "toSorted", "disposition", "a", "b", "_intent", "error", "undo", "result", "isEffect", "promise", "dispatch", "intentChain", "depth", "fail", "resultsRef", "prev", "get", "update", "results", "history", "next", "splice", "dispatchPromise", "program", "runPromise", "findLastIndex", "map", "undoData", "at", "h", "index", "undoPromise", "parseIntentPlugin", "provides", "parseIntentResolverPlugin", "defaultEffect", "defaultPromise", "IntentPlugin", "state", "create", "meta", "ready", "plugins", "fromEntries", "filterPlugins", "reduceResolvers", "children", "React", "value", "definitions", "Array", "isArray", "reduce", "acc", "definition"]
|
|
7
|
+
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -29,28 +29,41 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
31
|
ActiveParts: () => ActiveParts,
|
|
32
|
-
ErrorBoundary: () =>
|
|
32
|
+
ErrorBoundary: () => import_chunk_BW3RNEVI.ErrorBoundary,
|
|
33
33
|
HostPlugin: () => HostPlugin,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
INTENT_ACTION: () => import_chunk_VWHAALIN.INTENT_ACTION,
|
|
35
|
+
IntentAction: () => import_chunk_VWHAALIN.IntentAction,
|
|
36
|
+
IntentProvider: () => import_chunk_VWHAALIN.IntentProvider,
|
|
37
|
+
LAYOUT_ACTION: () => LAYOUT_ACTION,
|
|
38
|
+
LAYOUT_PLUGIN: () => LAYOUT_PLUGIN,
|
|
39
|
+
Label: () => import_chunk_VWHAALIN.Label,
|
|
36
40
|
Layout: () => Layout,
|
|
37
41
|
LayoutAction: () => LayoutAction,
|
|
42
|
+
NAVIGATION_ACTION: () => NAVIGATION_ACTION,
|
|
43
|
+
NAVIGATION_PLUGIN: () => NAVIGATION_PLUGIN,
|
|
38
44
|
NavigationAction: () => NavigationAction,
|
|
39
45
|
Plugin: () => Plugin,
|
|
40
46
|
PluginProvider: () => PluginProvider,
|
|
41
47
|
Resource: () => Resource,
|
|
42
48
|
ResourceKey: () => ResourceKey,
|
|
43
49
|
ResourceLanguage: () => ResourceLanguage,
|
|
50
|
+
SETTINGS_ACTION: () => import_chunk_FCMHRU3M.SETTINGS_ACTION,
|
|
51
|
+
SETTINGS_PLUGIN: () => import_chunk_FCMHRU3M.SETTINGS_PLUGIN,
|
|
44
52
|
SLUG_COLLECTION_INDICATOR: () => SLUG_COLLECTION_INDICATOR,
|
|
45
53
|
SLUG_ENTRY_SEPARATOR: () => SLUG_ENTRY_SEPARATOR,
|
|
46
54
|
SLUG_KEY_VALUE_SEPARATOR: () => SLUG_KEY_VALUE_SEPARATOR,
|
|
47
55
|
SLUG_LIST_SEPARATOR: () => SLUG_LIST_SEPARATOR,
|
|
48
56
|
SLUG_PATH_SEPARATOR: () => SLUG_PATH_SEPARATOR,
|
|
49
|
-
SettingsAction: () =>
|
|
50
|
-
Surface: () =>
|
|
51
|
-
SurfaceProvider: () =>
|
|
57
|
+
SettingsAction: () => import_chunk_FCMHRU3M.SettingsAction,
|
|
58
|
+
Surface: () => import_chunk_BW3RNEVI.Surface,
|
|
59
|
+
SurfaceProvider: () => import_chunk_BW3RNEVI.SurfaceProvider,
|
|
52
60
|
Toast: () => Toast,
|
|
61
|
+
chain: () => import_chunk_VWHAALIN.chain,
|
|
53
62
|
createApp: () => createApp,
|
|
63
|
+
createDispatcher: () => import_chunk_VWHAALIN.createDispatcher,
|
|
64
|
+
createIntent: () => import_chunk_VWHAALIN.createIntent,
|
|
65
|
+
createResolver: () => import_chunk_VWHAALIN.createResolver,
|
|
66
|
+
createSurface: () => import_chunk_BW3RNEVI.createSurface,
|
|
54
67
|
defaultFileTypes: () => defaultFileTypes,
|
|
55
68
|
definePlugin: () => import_chunk_QBM42OQ6.definePlugin,
|
|
56
69
|
filterPlugins: () => import_chunk_QBM42OQ6.filterPlugins,
|
|
@@ -61,45 +74,41 @@ __export(node_exports, {
|
|
|
61
74
|
isLayoutAdjustment: () => isLayoutAdjustment,
|
|
62
75
|
isLayoutMode: () => isLayoutMode,
|
|
63
76
|
isLayoutParts: () => isLayoutParts,
|
|
64
|
-
isObject: () =>
|
|
77
|
+
isObject: () => import_chunk_BW3RNEVI.isObject,
|
|
65
78
|
openIds: () => openIds,
|
|
66
79
|
parseFileManagerPlugin: () => parseFileManagerPlugin,
|
|
67
80
|
parseGraphBuilderPlugin: () => parseGraphBuilderPlugin,
|
|
68
81
|
parseGraphPlugin: () => parseGraphPlugin,
|
|
69
82
|
parseGraphSerializerPlugin: () => parseGraphSerializerPlugin,
|
|
70
|
-
parseIntentPlugin: () =>
|
|
71
|
-
parseIntentResolverPlugin: () =>
|
|
83
|
+
parseIntentPlugin: () => import_chunk_VWHAALIN.parseIntentPlugin,
|
|
84
|
+
parseIntentResolverPlugin: () => import_chunk_VWHAALIN.parseIntentResolverPlugin,
|
|
72
85
|
parseLayoutPlugin: () => parseLayoutPlugin,
|
|
73
86
|
parseMetadataRecordsPlugin: () => parseMetadataRecordsPlugin,
|
|
74
87
|
parseMetadataResolverPlugin: () => parseMetadataResolverPlugin,
|
|
75
88
|
parseNavigationPlugin: () => parseNavigationPlugin,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
parseSurfacePlugin: () => import_chunk_SOVLKUWI.parseSurfacePlugin,
|
|
89
|
+
parseRootSurfacePlugin: () => import_chunk_BW3RNEVI.parseRootSurfacePlugin,
|
|
90
|
+
parseSettingsPlugin: () => import_chunk_FCMHRU3M.parseSettingsPlugin,
|
|
91
|
+
parseSurfacePlugin: () => import_chunk_BW3RNEVI.parseSurfacePlugin,
|
|
80
92
|
parseTranslationsPlugin: () => parseTranslationsPlugin,
|
|
81
93
|
partLength: () => partLength,
|
|
82
94
|
resolvePlugin: () => import_chunk_QBM42OQ6.resolvePlugin,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
useIntentResolver: () => import_chunk_QSVP5HOW.useIntentResolver,
|
|
95
|
+
useIntentDispatcher: () => import_chunk_VWHAALIN.useIntentDispatcher,
|
|
96
|
+
useIntentResolver: () => import_chunk_VWHAALIN.useIntentResolver,
|
|
86
97
|
usePlugin: () => usePlugin,
|
|
87
98
|
usePlugins: () => usePlugins,
|
|
88
99
|
useResolvePlugin: () => useResolvePlugin,
|
|
89
100
|
useResolvePlugins: () => useResolvePlugins,
|
|
90
|
-
|
|
91
|
-
useSurfaceRoot: () => import_chunk_SOVLKUWI.useSurfaceRoot
|
|
101
|
+
useSurfaceRoot: () => import_chunk_BW3RNEVI.useSurfaceRoot
|
|
92
102
|
});
|
|
93
103
|
module.exports = __toCommonJS(node_exports);
|
|
94
|
-
var
|
|
95
|
-
var
|
|
104
|
+
var import_chunk_VWHAALIN = require("./chunk-VWHAALIN.cjs");
|
|
105
|
+
var import_chunk_BW3RNEVI = require("./chunk-BW3RNEVI.cjs");
|
|
96
106
|
var import_chunk_QBM42OQ6 = require("./chunk-QBM42OQ6.cjs");
|
|
97
|
-
var
|
|
98
|
-
var
|
|
107
|
+
var import_chunk_FCMHRU3M = require("./chunk-FCMHRU3M.cjs");
|
|
108
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
99
109
|
var import_schema = require("@effect/schema");
|
|
100
|
-
var import_zod2 = require("zod");
|
|
101
110
|
var import_util = require("@dxos/util");
|
|
102
|
-
var
|
|
111
|
+
var import_zod = require("zod");
|
|
103
112
|
var import_react = __toESM(require("react"));
|
|
104
113
|
var import_local_storage = require("@dxos/local-storage");
|
|
105
114
|
var import_react2 = __toESM(require("react"));
|
|
@@ -134,65 +143,116 @@ var parseFileManagerPlugin = (plugin) => {
|
|
|
134
143
|
var parseGraphPlugin = (plugin) => plugin.provides.graph?.root ? plugin : void 0;
|
|
135
144
|
var parseGraphBuilderPlugin = (plugin) => plugin.provides.graph?.builder ? plugin : void 0;
|
|
136
145
|
var parseGraphSerializerPlugin = (plugin) => plugin.provides.graph?.serializer ? plugin : void 0;
|
|
137
|
-
var Toast =
|
|
138
|
-
id:
|
|
139
|
-
title:
|
|
140
|
-
description:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
onAction:
|
|
146
|
+
var Toast = import_echo_schema.S.Struct({
|
|
147
|
+
id: import_echo_schema.S.String,
|
|
148
|
+
title: import_echo_schema.S.optional(import_chunk_VWHAALIN.Label),
|
|
149
|
+
description: import_echo_schema.S.optional(import_chunk_VWHAALIN.Label),
|
|
150
|
+
icon: import_echo_schema.S.optional(import_echo_schema.S.String),
|
|
151
|
+
duration: import_echo_schema.S.optional(import_echo_schema.S.Number),
|
|
152
|
+
closeLabel: import_echo_schema.S.optional(import_chunk_VWHAALIN.Label),
|
|
153
|
+
actionLabel: import_echo_schema.S.optional(import_chunk_VWHAALIN.Label),
|
|
154
|
+
actionAlt: import_echo_schema.S.optional(import_chunk_VWHAALIN.Label),
|
|
155
|
+
// TODO(wittjosiah): Make class with customizable method?
|
|
156
|
+
onAction: import_echo_schema.S.optional(import_echo_schema.S.Any)
|
|
148
157
|
});
|
|
149
|
-
var LayoutMode =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var Layout = import_zod.z.object({
|
|
156
|
-
layoutMode: import_zod.z.union([
|
|
157
|
-
import_zod.z.literal("deck"),
|
|
158
|
-
import_zod.z.literal("solo"),
|
|
159
|
-
import_zod.z.literal("fullscreen")
|
|
160
|
-
]),
|
|
161
|
-
sidebarOpen: import_zod.z.boolean(),
|
|
162
|
-
complementarySidebarOpen: import_zod.z.boolean(),
|
|
158
|
+
var LayoutMode = import_echo_schema.S.Union(import_echo_schema.S.Literal("deck"), import_echo_schema.S.Literal("solo"), import_echo_schema.S.Literal("fullscreen"));
|
|
159
|
+
var isLayoutMode = (value) => import_echo_schema.S.is(LayoutMode)(value);
|
|
160
|
+
var Layout = import_echo_schema.S.mutable(import_echo_schema.S.Struct({
|
|
161
|
+
layoutMode: LayoutMode,
|
|
162
|
+
sidebarOpen: import_echo_schema.S.Boolean,
|
|
163
|
+
complementarySidebarOpen: import_echo_schema.S.Boolean,
|
|
163
164
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
complementarySidebarContent:
|
|
167
|
-
dialogOpen:
|
|
168
|
-
|
|
165
|
+
* @deprecated Data to be passed to the complementary sidebar Surface.
|
|
166
|
+
*/
|
|
167
|
+
complementarySidebarContent: import_echo_schema.S.optional(import_echo_schema.S.Any),
|
|
168
|
+
dialogOpen: import_echo_schema.S.Boolean,
|
|
169
|
+
/**
|
|
170
|
+
* Data to be passed to the dialog Surface.
|
|
171
|
+
*/
|
|
172
|
+
dialogContent: import_echo_schema.S.optional(import_echo_schema.S.Any),
|
|
169
173
|
// TODO(wittjosiah): Custom properties?
|
|
170
|
-
dialogBlockAlign:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
scrollIntoView:
|
|
183
|
-
});
|
|
174
|
+
dialogBlockAlign: import_echo_schema.S.optional(import_echo_schema.S.Literal("start", "center")),
|
|
175
|
+
dialogType: import_echo_schema.S.optional(import_echo_schema.S.Literal("default", "alert")),
|
|
176
|
+
popoverOpen: import_echo_schema.S.Boolean,
|
|
177
|
+
/**
|
|
178
|
+
* Data to be passed to the popover Surface.
|
|
179
|
+
*/
|
|
180
|
+
popoverContent: import_echo_schema.S.optional(import_echo_schema.S.Any),
|
|
181
|
+
popoverAnchorId: import_echo_schema.S.optional(import_echo_schema.S.String),
|
|
182
|
+
toasts: import_echo_schema.S.mutable(import_echo_schema.S.Array(Toast)),
|
|
183
|
+
/**
|
|
184
|
+
* The identifier of a component to scroll into view when it is mounted.
|
|
185
|
+
*/
|
|
186
|
+
scrollIntoView: import_echo_schema.S.optional(import_echo_schema.S.String)
|
|
187
|
+
}));
|
|
184
188
|
var parseLayoutPlugin = (plugin) => {
|
|
185
|
-
const
|
|
189
|
+
const success = import_echo_schema.S.is(Layout)(plugin.provides.layout);
|
|
186
190
|
return success ? plugin : void 0;
|
|
187
191
|
};
|
|
188
192
|
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
189
193
|
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
190
194
|
var LayoutAction;
|
|
191
195
|
(function(LayoutAction2) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
class SetLayout extends import_echo_schema.S.TaggedClass()(`${LAYOUT_ACTION}/set-layout`, {
|
|
197
|
+
input: import_echo_schema.S.Struct({
|
|
198
|
+
/**
|
|
199
|
+
* Element to set the state of.
|
|
200
|
+
*/
|
|
201
|
+
element: import_echo_schema.S.Literal("fullscreen", "sidebar", "complementary", "dialog", "popover", "toast"),
|
|
202
|
+
/**
|
|
203
|
+
* Whether the element is on or off.
|
|
204
|
+
*
|
|
205
|
+
* If omitted, the element's state will be toggled or set based on other provided data.
|
|
206
|
+
* For example, if `component` is provided, the state will be set to `true`.
|
|
207
|
+
*/
|
|
208
|
+
state: import_echo_schema.S.optional(import_echo_schema.S.Boolean),
|
|
209
|
+
/**
|
|
210
|
+
* Component to render in the dialog or popover.
|
|
211
|
+
*/
|
|
212
|
+
component: import_echo_schema.S.optional(import_echo_schema.S.String),
|
|
213
|
+
/**
|
|
214
|
+
* Data to be passed to the dialog or popover Surface.
|
|
215
|
+
*/
|
|
216
|
+
subject: import_echo_schema.S.optional(import_echo_schema.S.Any),
|
|
217
|
+
/**
|
|
218
|
+
* Anchor ID for the popover.
|
|
219
|
+
*/
|
|
220
|
+
anchorId: import_echo_schema.S.optional(import_echo_schema.S.String),
|
|
221
|
+
// TODO(wittjosiah): Custom properties?
|
|
222
|
+
/**
|
|
223
|
+
* Block alignment for the dialog.
|
|
224
|
+
*/
|
|
225
|
+
dialogBlockAlign: import_echo_schema.S.optional(import_echo_schema.S.Literal("start", "center")),
|
|
226
|
+
/**
|
|
227
|
+
* Type of dialog.
|
|
228
|
+
*/
|
|
229
|
+
dialogType: import_echo_schema.S.optional(import_echo_schema.S.Literal("default", "alert"))
|
|
230
|
+
}),
|
|
231
|
+
output: import_echo_schema.S.Void
|
|
232
|
+
}) {
|
|
233
|
+
}
|
|
234
|
+
LayoutAction2.SetLayout = SetLayout;
|
|
235
|
+
class SetLayoutMode extends import_echo_schema.S.TaggedClass()(`${LAYOUT_ACTION}/set-layout-mode`, {
|
|
236
|
+
input: import_echo_schema.S.Union(import_echo_schema.S.Struct({
|
|
237
|
+
layoutMode: LayoutMode
|
|
238
|
+
}), import_echo_schema.S.Struct({
|
|
239
|
+
revert: import_echo_schema.S.Literal(true)
|
|
240
|
+
})),
|
|
241
|
+
output: import_echo_schema.S.Void
|
|
242
|
+
}) {
|
|
243
|
+
}
|
|
244
|
+
LayoutAction2.SetLayoutMode = SetLayoutMode;
|
|
245
|
+
class ScrollIntoView extends import_echo_schema.S.TaggedClass()(`${LAYOUT_ACTION}/scroll-into-view`, {
|
|
246
|
+
input: import_echo_schema.S.Struct({
|
|
247
|
+
id: import_echo_schema.S.optional(import_echo_schema.S.String),
|
|
248
|
+
// TODO(wittjosiah): Factor out to thread scroll into view action?
|
|
249
|
+
cursor: import_echo_schema.S.optional(import_echo_schema.S.String),
|
|
250
|
+
ref: import_echo_schema.S.optional(import_echo_schema.S.String)
|
|
251
|
+
}),
|
|
252
|
+
output: import_echo_schema.S.Void
|
|
253
|
+
}) {
|
|
254
|
+
}
|
|
255
|
+
LayoutAction2.ScrollIntoView = ScrollIntoView;
|
|
196
256
|
})(LayoutAction || (LayoutAction = {}));
|
|
197
257
|
var parseMetadataRecordsPlugin = (plugin) => {
|
|
198
258
|
return plugin.provides.metadata?.records ? plugin : void 0;
|
|
@@ -218,15 +278,15 @@ var LayoutCoordinateSchema = import_schema.Schema.mutable(import_schema.Schema.S
|
|
|
218
278
|
part: LayoutPartSchema,
|
|
219
279
|
entryId: import_schema.Schema.String
|
|
220
280
|
}));
|
|
221
|
-
var PartAdjustmentSchema = import_schema.Schema.Union(import_schema.Schema.Literal("increment-start"), import_schema.Schema.Literal("increment-end"), import_schema.Schema.Literal("solo"));
|
|
281
|
+
var PartAdjustmentSchema = import_schema.Schema.Union(import_schema.Schema.Literal("increment-start"), import_schema.Schema.Literal("increment-end"), import_schema.Schema.Literal("pin-start"), import_schema.Schema.Literal("pin-end"), import_schema.Schema.Literal("close"), import_schema.Schema.Literal("solo"));
|
|
222
282
|
var LayoutAdjustmentSchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
|
|
223
283
|
layoutCoordinate: LayoutCoordinateSchema,
|
|
224
284
|
type: PartAdjustmentSchema
|
|
225
285
|
}));
|
|
226
|
-
var ActiveParts =
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
286
|
+
var ActiveParts = import_schema.Schema.Record({
|
|
287
|
+
key: import_schema.Schema.String,
|
|
288
|
+
value: import_schema.Schema.Union(import_schema.Schema.String, import_schema.Schema.mutable(import_schema.Schema.Array(import_schema.Schema.String)))
|
|
289
|
+
});
|
|
230
290
|
var LocationProvidesSchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
|
|
231
291
|
location: import_schema.Schema.Struct({
|
|
232
292
|
active: LayoutPartsSchema,
|
|
@@ -277,31 +337,71 @@ var NAVIGATION_PLUGIN = "dxos.org/plugin/navigation";
|
|
|
277
337
|
var NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
|
|
278
338
|
var NavigationAction;
|
|
279
339
|
(function(NavigationAction2) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
340
|
+
class Open extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/open`, {
|
|
341
|
+
input: import_schema.Schema.Struct({
|
|
342
|
+
activeParts: ActiveParts,
|
|
343
|
+
noToggle: import_schema.Schema.optional(import_schema.Schema.Boolean)
|
|
344
|
+
}),
|
|
345
|
+
output: import_schema.Schema.Struct({
|
|
346
|
+
open: import_schema.Schema.Array(import_schema.Schema.String)
|
|
347
|
+
})
|
|
348
|
+
}) {
|
|
349
|
+
}
|
|
350
|
+
NavigationAction2.Open = Open;
|
|
351
|
+
class AddToActive extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/add-to-active`, {
|
|
352
|
+
input: import_schema.Schema.Struct({
|
|
353
|
+
id: import_schema.Schema.String,
|
|
354
|
+
part: LayoutPartSchema,
|
|
355
|
+
scrollIntoView: import_schema.Schema.optional(import_schema.Schema.Boolean),
|
|
356
|
+
pivotId: import_schema.Schema.optional(import_schema.Schema.String),
|
|
357
|
+
positioning: import_schema.Schema.optional(import_schema.Schema.Literal("start", "end"))
|
|
358
|
+
}),
|
|
359
|
+
output: import_schema.Schema.Void
|
|
360
|
+
}) {
|
|
361
|
+
}
|
|
362
|
+
NavigationAction2.AddToActive = AddToActive;
|
|
363
|
+
class Set extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/set`, {
|
|
364
|
+
input: import_schema.Schema.Struct({
|
|
365
|
+
activeParts: ActiveParts
|
|
366
|
+
}),
|
|
367
|
+
output: import_schema.Schema.Void
|
|
368
|
+
}) {
|
|
369
|
+
}
|
|
370
|
+
NavigationAction2.Set = Set;
|
|
371
|
+
class Close extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/close`, {
|
|
372
|
+
input: import_schema.Schema.Struct({
|
|
373
|
+
activeParts: ActiveParts,
|
|
374
|
+
noToggle: import_schema.Schema.optional(import_schema.Schema.Boolean)
|
|
375
|
+
}),
|
|
376
|
+
output: import_schema.Schema.Void
|
|
377
|
+
}) {
|
|
378
|
+
}
|
|
379
|
+
NavigationAction2.Close = Close;
|
|
380
|
+
class Adjust extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/adjust`, {
|
|
381
|
+
input: LayoutAdjustmentSchema,
|
|
382
|
+
output: import_schema.Schema.Void
|
|
383
|
+
}) {
|
|
384
|
+
}
|
|
385
|
+
NavigationAction2.Adjust = Adjust;
|
|
386
|
+
class Expose extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/expose`, {
|
|
387
|
+
input: import_schema.Schema.Struct({
|
|
388
|
+
id: import_schema.Schema.String
|
|
389
|
+
}),
|
|
390
|
+
output: import_schema.Schema.Void
|
|
391
|
+
}) {
|
|
392
|
+
}
|
|
393
|
+
NavigationAction2.Expose = Expose;
|
|
286
394
|
})(NavigationAction || (NavigationAction = {}));
|
|
287
|
-
var ResourceKey =
|
|
288
|
-
|
|
289
|
-
|
|
395
|
+
var ResourceKey = import_zod.z.union([
|
|
396
|
+
import_zod.z.string(),
|
|
397
|
+
import_zod.z.record(import_zod.z.any())
|
|
290
398
|
]);
|
|
291
|
-
var ResourceLanguage =
|
|
292
|
-
var Resource =
|
|
399
|
+
var ResourceLanguage = import_zod.z.record(ResourceKey);
|
|
400
|
+
var Resource = import_zod.z.record(ResourceLanguage);
|
|
293
401
|
var parseTranslationsPlugin = (plugin) => {
|
|
294
|
-
const { success } =
|
|
402
|
+
const { success } = import_zod.z.array(Resource).safeParse(plugin.provides.translations);
|
|
295
403
|
return success ? plugin : void 0;
|
|
296
404
|
};
|
|
297
|
-
var Plugin;
|
|
298
|
-
(function(Plugin2) {
|
|
299
|
-
Plugin2.lazy = (p, props) => {
|
|
300
|
-
return () => p().then(({ default: definition }) => {
|
|
301
|
-
return definition(props);
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
})(Plugin || (Plugin = {}));
|
|
305
405
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/plugin-host/PluginContainer.tsx";
|
|
306
406
|
var PluginContainer = ({ plugins: definitions, core, state, placeholder }) => {
|
|
307
407
|
const [error, setError] = (0, import_react2.useState)();
|
|
@@ -352,7 +452,9 @@ var PluginContainer = ({ plugins: definitions, core, state, placeholder }) => {
|
|
|
352
452
|
S: void 0,
|
|
353
453
|
C: (f, a) => f(...a)
|
|
354
454
|
});
|
|
355
|
-
await Promise.all(enabled.map((plugin) => plugin.ready?.(
|
|
455
|
+
await Promise.all(enabled.map((plugin) => plugin.ready?.({
|
|
456
|
+
plugins: initialized
|
|
457
|
+
})));
|
|
356
458
|
(0, import_log.log)("plugins ready", {
|
|
357
459
|
plugins: initialized
|
|
358
460
|
}, {
|
|
@@ -429,7 +531,6 @@ var useResolvePlugins = (predicate) => {
|
|
|
429
531
|
]);
|
|
430
532
|
};
|
|
431
533
|
var PluginProvider = PluginContext.Provider;
|
|
432
|
-
var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
|
|
433
534
|
var HOST_PLUGIN = "dxos.org/plugin/host";
|
|
434
535
|
var HostPlugin = ({ plugins, meta, core, defaults = [], fallback = DefaultFallback, placeholder = null }) => {
|
|
435
536
|
const state = new import_local_storage.LocalStorageStore(HOST_PLUGIN, {
|
|
@@ -460,14 +561,13 @@ var HostPlugin = ({ plugins, meta, core, defaults = [], fallback = DefaultFallba
|
|
|
460
561
|
name: "Plugin host"
|
|
461
562
|
},
|
|
462
563
|
provides: {
|
|
463
|
-
plugins: state.values,
|
|
464
564
|
context: ({ children }) => {
|
|
465
565
|
return /* @__PURE__ */ import_react.default.createElement(PluginProvider, {
|
|
466
566
|
value: state.values
|
|
467
567
|
}, children);
|
|
468
568
|
},
|
|
469
569
|
root: () => {
|
|
470
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
570
|
+
return /* @__PURE__ */ import_react.default.createElement(import_chunk_BW3RNEVI.ErrorBoundary, {
|
|
471
571
|
fallback
|
|
472
572
|
}, /* @__PURE__ */ import_react.default.createElement(PluginContainer, {
|
|
473
573
|
plugins,
|
|
@@ -492,25 +592,33 @@ var DefaultFallback = ({ error }) => {
|
|
|
492
592
|
}
|
|
493
593
|
}, error.message), /* @__PURE__ */ import_react.default.createElement("pre", null, error.stack));
|
|
494
594
|
};
|
|
595
|
+
var Plugin;
|
|
596
|
+
(function(Plugin2) {
|
|
597
|
+
Plugin2.lazy = (p, props) => {
|
|
598
|
+
return () => p().then(({ default: definition }) => {
|
|
599
|
+
return definition(props);
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
})(Plugin || (Plugin = {}));
|
|
495
603
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
|
|
496
604
|
var createApp = ({ meta, plugins, core, ...params }) => {
|
|
497
605
|
const hostPlugin = HostPlugin({
|
|
498
606
|
plugins: {
|
|
499
607
|
...plugins,
|
|
500
|
-
[
|
|
501
|
-
[
|
|
502
|
-
[
|
|
608
|
+
[import_chunk_VWHAALIN.meta_default.id]: Plugin.lazy(() => import("./plugin-intent-F3TQZIUR.cjs")),
|
|
609
|
+
[import_chunk_FCMHRU3M.meta_default.id]: Plugin.lazy(() => import("./plugin-settings-W6UHMH5M.cjs")),
|
|
610
|
+
[import_chunk_BW3RNEVI.meta_default.id]: Plugin.lazy(() => import("./plugin-surface-CCSIONYW.cjs"))
|
|
503
611
|
},
|
|
504
612
|
meta: [
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
613
|
+
import_chunk_VWHAALIN.meta_default,
|
|
614
|
+
import_chunk_FCMHRU3M.meta_default,
|
|
615
|
+
import_chunk_BW3RNEVI.meta_default,
|
|
508
616
|
...meta
|
|
509
617
|
],
|
|
510
618
|
core: [
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
619
|
+
import_chunk_VWHAALIN.meta_default.id,
|
|
620
|
+
import_chunk_FCMHRU3M.meta_default.id,
|
|
621
|
+
import_chunk_BW3RNEVI.meta_default.id,
|
|
514
622
|
...core
|
|
515
623
|
],
|
|
516
624
|
...params
|
|
@@ -550,16 +658,24 @@ var createApp = ({ meta, plugins, core, ...params }) => {
|
|
|
550
658
|
ActiveParts,
|
|
551
659
|
ErrorBoundary,
|
|
552
660
|
HostPlugin,
|
|
661
|
+
INTENT_ACTION,
|
|
553
662
|
IntentAction,
|
|
554
663
|
IntentProvider,
|
|
664
|
+
LAYOUT_ACTION,
|
|
665
|
+
LAYOUT_PLUGIN,
|
|
666
|
+
Label,
|
|
555
667
|
Layout,
|
|
556
668
|
LayoutAction,
|
|
669
|
+
NAVIGATION_ACTION,
|
|
670
|
+
NAVIGATION_PLUGIN,
|
|
557
671
|
NavigationAction,
|
|
558
672
|
Plugin,
|
|
559
673
|
PluginProvider,
|
|
560
674
|
Resource,
|
|
561
675
|
ResourceKey,
|
|
562
676
|
ResourceLanguage,
|
|
677
|
+
SETTINGS_ACTION,
|
|
678
|
+
SETTINGS_PLUGIN,
|
|
563
679
|
SLUG_COLLECTION_INDICATOR,
|
|
564
680
|
SLUG_ENTRY_SEPARATOR,
|
|
565
681
|
SLUG_KEY_VALUE_SEPARATOR,
|
|
@@ -569,7 +685,12 @@ var createApp = ({ meta, plugins, core, ...params }) => {
|
|
|
569
685
|
Surface,
|
|
570
686
|
SurfaceProvider,
|
|
571
687
|
Toast,
|
|
688
|
+
chain,
|
|
572
689
|
createApp,
|
|
690
|
+
createDispatcher,
|
|
691
|
+
createIntent,
|
|
692
|
+
createResolver,
|
|
693
|
+
createSurface,
|
|
573
694
|
defaultFileTypes,
|
|
574
695
|
definePlugin,
|
|
575
696
|
filterPlugins,
|
|
@@ -592,21 +713,18 @@ var createApp = ({ meta, plugins, core, ...params }) => {
|
|
|
592
713
|
parseMetadataRecordsPlugin,
|
|
593
714
|
parseMetadataResolverPlugin,
|
|
594
715
|
parseNavigationPlugin,
|
|
595
|
-
parsePluginHost,
|
|
596
716
|
parseRootSurfacePlugin,
|
|
597
717
|
parseSettingsPlugin,
|
|
598
718
|
parseSurfacePlugin,
|
|
599
719
|
parseTranslationsPlugin,
|
|
600
720
|
partLength,
|
|
601
721
|
resolvePlugin,
|
|
602
|
-
useIntent,
|
|
603
722
|
useIntentDispatcher,
|
|
604
723
|
useIntentResolver,
|
|
605
724
|
usePlugin,
|
|
606
725
|
usePlugins,
|
|
607
726
|
useResolvePlugin,
|
|
608
727
|
useResolvePlugins,
|
|
609
|
-
useSurface,
|
|
610
728
|
useSurfaceRoot
|
|
611
729
|
});
|
|
612
730
|
//# sourceMappingURL=index.cjs.map
|