@dxos/app-framework 0.3.9-main.cea1d3b → 0.3.9-main.ee9a520

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.
Files changed (31) hide show
  1. package/dist/lib/browser/{chunk-WDA7VA54.mjs → chunk-MNFAM2GF.mjs} +1 -1
  2. package/dist/lib/browser/{chunk-WDA7VA54.mjs.map → chunk-MNFAM2GF.mjs.map} +2 -2
  3. package/dist/lib/browser/index.mjs +33 -7
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/{plugin-XEJ5RYCP.mjs → plugin-JDIMDLDU.mjs} +2 -2
  7. package/dist/lib/node/{chunk-YDKX45O3.cjs → chunk-DC3GU6QR.cjs} +4 -4
  8. package/dist/lib/node/chunk-DC3GU6QR.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +38 -13
  10. package/dist/lib/node/index.cjs.map +4 -4
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/{plugin-RCAOZKNL.cjs → plugin-JGSJGRMS.cjs} +8 -8
  13. package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts +2 -0
  14. package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +1 -1
  15. package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts +10 -2
  16. package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts.map +1 -1
  17. package/dist/types/src/plugins/SurfacePlugin/helpers.d.ts +21 -0
  18. package/dist/types/src/plugins/SurfacePlugin/helpers.d.ts.map +1 -0
  19. package/dist/types/src/plugins/SurfacePlugin/index.d.ts +1 -0
  20. package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +1 -1
  21. package/dist/types/src/plugins/common/graph.d.ts +2 -2
  22. package/dist/types/src/plugins/common/graph.d.ts.map +1 -1
  23. package/package.json +7 -7
  24. package/src/plugins/SurfacePlugin/Surface.tsx +34 -5
  25. package/src/plugins/SurfacePlugin/SurfaceRootContext.tsx +15 -2
  26. package/src/plugins/SurfacePlugin/helpers.ts +22 -0
  27. package/src/plugins/SurfacePlugin/index.ts +1 -0
  28. package/src/plugins/common/graph.ts +2 -2
  29. package/dist/lib/node/chunk-YDKX45O3.cjs.map +0 -7
  30. /package/dist/lib/browser/{plugin-XEJ5RYCP.mjs.map → plugin-JDIMDLDU.mjs.map} +0 -0
  31. /package/dist/lib/node/{plugin-RCAOZKNL.cjs.map → plugin-JGSJGRMS.cjs.map} +0 -0
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ /**
6
+ * Checks if the given data is an object and not null.
7
+ *
8
+ * Useful inside surface component resolvers as a type guard.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const old =
13
+ * data.content &&
14
+ * typeof data.content === 'object' &&
15
+ * 'id' in data.content &&
16
+ * typeof data.content.id === 'string';
17
+ *
18
+ * // becomes
19
+ * const new = isObject(data.content) && typeof data.content.id === 'string';
20
+ * ```
21
+ */
22
+ export const isObject = (data: unknown): data is { [key: string]: unknown } => !!data && typeof data === 'object';
@@ -2,6 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './helpers';
5
6
  export * from './provides';
6
7
 
7
8
  export * from './ErrorBoundary';
@@ -10,7 +10,7 @@ import type { Plugin } from '../PluginHost';
10
10
  /**
11
11
  * Provides for a plugin that exposes the application graph.
12
12
  */
13
- export type GraphPluginProvides = {
13
+ export type GraphProvides = {
14
14
  graph: Graph;
15
15
  };
16
16
 
@@ -24,7 +24,7 @@ export type GraphBuilderProvides = {
24
24
  * Type guard for graph plugins.
25
25
  */
26
26
  export const parseGraphPlugin = (plugin: Plugin) =>
27
- (plugin.provides as any).graph?.root ? (plugin as Plugin<GraphPluginProvides>) : undefined;
27
+ (plugin.provides as any).graph?.root ? (plugin as Plugin<GraphProvides>) : undefined;
28
28
 
29
29
  /**
30
30
  * Type guard for graph builder plugins.
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/provides.ts", "../../../src/plugins/SurfacePlugin/SurfaceRootContext.tsx", "../../../src/plugins/SurfacePlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../PluginHost';\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type Context, type Provider, type ReactNode, type ForwardedRef } from 'react';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (props: SurfaceComponentProps, forwardedRef: ForwardedRef<HTMLElement>) => ReactNode;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n};\n\nconst SurfaceRootContext: Context<SurfaceRootContext> = createContext<SurfaceRootContext>({ components: {} });\n\nexport const useSurface = () => useContext(SurfaceRootContext);\n\nexport const SurfaceProvider: Provider<SurfaceRootContext> = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAA0G;ADgBnG,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;ACExF,IAAMG,qBAAkDC,gDAAkC;EAAEL,YAAY,CAAC;AAAE,CAAA;AAEpG,IAAMM,aAAa,UAAMC,yBAAWH,kBAAAA;AAEpC,IAAMI,kBAAgDJ,mBAAmBK;AC1BhF,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "SurfaceRootContext", "createContext", "useSurface", "useContext", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
- }