@dxos/plugin-template 0.8.4-main.84f28bd → 0.8.4-main.8baae0fced
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/TemplatePlugin.mjs +24 -0
- package/dist/lib/neutral/TemplatePlugin.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +9 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3GJBJD5H.mjs +21 -0
- package/dist/lib/neutral/chunk-3GJBJD5H.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AITG64J5.mjs +19 -0
- package/dist/lib/neutral/chunk-AITG64J5.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +14 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-YYTSDVP3.mjs +25 -0
- package/dist/lib/neutral/create-object-YYTSDVP3.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +11 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +7 -0
- package/dist/lib/neutral/plugin.mjs +11 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-SYA2674P.mjs +21 -0
- package/dist/lib/neutral/react-surface-SYA2674P.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +27 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +7 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/TemplatePlugin.d.ts +3 -1
- package/dist/types/src/TemplatePlugin.d.ts.map +1 -1
- package/dist/types/src/TemplatePlugin.test.d.ts +2 -0
- package/dist/types/src/TemplatePlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/TemplatePanel/TemplatePanel.d.ts +6 -0
- package/dist/types/src/components/TemplatePanel/TemplatePanel.d.ts.map +1 -0
- package/dist/types/src/components/TemplatePanel/index.d.ts +2 -0
- package/dist/types/src/components/TemplatePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +22 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +12 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +77 -38
- package/src/TemplatePlugin.test.ts +26 -0
- package/src/TemplatePlugin.tsx +15 -54
- package/src/capabilities/create-object.ts +30 -0
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/react-surface.tsx +20 -15
- package/src/components/TemplatePanel/TemplatePanel.tsx +21 -0
- package/src/components/TemplatePanel/index.ts +5 -0
- package/src/components/index.ts +1 -1
- package/src/index.ts +1 -1
- package/src/meta.ts +10 -5
- package/src/plugin.ts +9 -0
- package/src/translations.ts +13 -9
- package/src/types/index.ts +5 -0
- package/src/types/schema.ts +26 -0
- package/dist/lib/browser/chunk-FARPQI2D.mjs +0 -49
- package/dist/lib/browser/chunk-FARPQI2D.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -85
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AYJTEW6K.mjs +0 -22
- package/dist/lib/browser/intent-resolver-AYJTEW6K.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-H7UCIT3M.mjs +0 -39
- package/dist/lib/browser/react-surface-H7UCIT3M.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -11
- package/dist/lib/node-esm/chunk-B3O6VLCP.mjs +0 -51
- package/dist/lib/node-esm/chunk-B3O6VLCP.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -86
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KY2OPU2S.mjs +0 -23
- package/dist/lib/node-esm/intent-resolver-KY2OPU2S.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-VJDBNR3U.mjs +0 -40
- package/dist/lib/node-esm/react-surface-VJDBNR3U.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -12
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/TemplateContainer.d.ts +0 -7
- package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -27
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -19
- package/src/components/TemplateContainer.tsx +0 -19
- package/src/types.ts +0 -36
- /package/dist/lib/{browser/types.mjs.map → neutral/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types.mjs.map → neutral/meta.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,65 +1,104 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-template",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.8baae0fced",
|
|
4
4
|
"description": "Template for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": {
|
|
17
|
+
"source": "./src/capabilities/index.ts",
|
|
18
|
+
"types": "./dist/types/src/capabilities/index.d.ts",
|
|
19
|
+
"default": "./dist/lib/neutral/capabilities/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"#components": {
|
|
22
|
+
"source": "./src/components/index.ts",
|
|
23
|
+
"types": "./dist/types/src/components/index.d.ts",
|
|
24
|
+
"default": "./dist/lib/neutral/components/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"#meta": {
|
|
27
|
+
"source": "./src/meta.ts",
|
|
28
|
+
"types": "./dist/types/src/meta.d.ts",
|
|
29
|
+
"default": "./dist/lib/neutral/meta.mjs"
|
|
30
|
+
},
|
|
31
|
+
"#plugin": {
|
|
32
|
+
"source": "./src/TemplatePlugin.tsx",
|
|
33
|
+
"types": "./dist/types/src/TemplatePlugin.d.ts",
|
|
34
|
+
"default": "./dist/lib/neutral/TemplatePlugin.mjs"
|
|
35
|
+
},
|
|
36
|
+
"#translations": {
|
|
37
|
+
"source": "./src/translations.ts",
|
|
38
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
39
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
40
|
+
},
|
|
41
|
+
"#types": {
|
|
42
|
+
"source": "./src/types/index.ts",
|
|
43
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
44
|
+
"default": "./dist/lib/neutral/types/index.mjs"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
11
47
|
"exports": {
|
|
12
48
|
".": {
|
|
49
|
+
"source": "./src/index.ts",
|
|
13
50
|
"types": "./dist/types/src/index.d.ts",
|
|
14
|
-
"
|
|
51
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./plugin": {
|
|
54
|
+
"source": "./src/plugin.ts",
|
|
55
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
56
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
15
57
|
},
|
|
16
|
-
"./
|
|
17
|
-
"
|
|
18
|
-
"
|
|
58
|
+
"./translations": {
|
|
59
|
+
"source": "./src/translations.ts",
|
|
60
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
61
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
19
62
|
}
|
|
20
63
|
},
|
|
21
64
|
"types": "dist/types/src/index.d.ts",
|
|
22
|
-
"typesVersions": {
|
|
23
|
-
"*": {
|
|
24
|
-
"types": [
|
|
25
|
-
"dist/types/src/types.d.ts"
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
65
|
"files": [
|
|
30
66
|
"dist",
|
|
31
67
|
"src"
|
|
32
68
|
],
|
|
33
69
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/echo
|
|
41
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
42
|
-
"@dxos/plugin-graph": "0.8.4-main.
|
|
43
|
-
"@dxos/plugin-space": "0.8.4-main.
|
|
44
|
-
"@dxos/react-client": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
70
|
+
"@radix-ui/react-context": "1.1.1",
|
|
71
|
+
"effect": "3.20.0",
|
|
72
|
+
"@dxos/app-framework": "0.8.4-main.8baae0fced",
|
|
73
|
+
"@dxos/async": "0.8.4-main.8baae0fced",
|
|
74
|
+
"@dxos/app-toolkit": "0.8.4-main.8baae0fced",
|
|
75
|
+
"@dxos/compute": "0.8.4-main.8baae0fced",
|
|
76
|
+
"@dxos/echo": "0.8.4-main.8baae0fced",
|
|
77
|
+
"@dxos/plugin-client": "0.8.4-main.8baae0fced",
|
|
78
|
+
"@dxos/plugin-graph": "0.8.4-main.8baae0fced",
|
|
79
|
+
"@dxos/plugin-space": "0.8.4-main.8baae0fced",
|
|
80
|
+
"@dxos/react-client": "0.8.4-main.8baae0fced",
|
|
81
|
+
"@dxos/util": "0.8.4-main.8baae0fced",
|
|
82
|
+
"@dxos/react-ui-stack": "0.8.4-main.8baae0fced",
|
|
83
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.8baae0fced"
|
|
46
84
|
},
|
|
47
85
|
"devDependencies": {
|
|
48
|
-
"@types/react": "~
|
|
49
|
-
"@types/react-dom": "~
|
|
50
|
-
"react": "~
|
|
51
|
-
"react-dom": "~
|
|
52
|
-
"vite": "
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
86
|
+
"@types/react": "~19.2.7",
|
|
87
|
+
"@types/react-dom": "~19.2.3",
|
|
88
|
+
"react": "~19.2.3",
|
|
89
|
+
"react-dom": "~19.2.3",
|
|
90
|
+
"vite": "^8.0.13",
|
|
91
|
+
"@dxos/plugin-testing": "0.8.4-main.8baae0fced",
|
|
92
|
+
"@dxos/react-ui": "0.8.4-main.8baae0fced",
|
|
93
|
+
"@dxos/storybook-utils": "0.8.4-main.8baae0fced",
|
|
94
|
+
"@dxos/ui-theme": "0.8.4-main.8baae0fced"
|
|
56
95
|
},
|
|
57
96
|
"peerDependencies": {
|
|
58
|
-
"effect": "
|
|
59
|
-
"react": "~
|
|
60
|
-
"react-dom": "~
|
|
61
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
62
|
-
"@dxos/
|
|
97
|
+
"effect": "3.20.0",
|
|
98
|
+
"react": "~19.2.3",
|
|
99
|
+
"react-dom": "~19.2.3",
|
|
100
|
+
"@dxos/react-ui": "0.8.4-main.8baae0fced",
|
|
101
|
+
"@dxos/ui-theme": "0.8.4-main.8baae0fced"
|
|
63
102
|
},
|
|
64
103
|
"publishConfig": {
|
|
65
104
|
"access": "public"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ClientPlugin } from '@dxos/plugin-client/plugin';
|
|
8
|
+
import { createComposerTestApp } from '@dxos/plugin-testing/harness';
|
|
9
|
+
|
|
10
|
+
import { TemplatePlugin } from '#plugin';
|
|
11
|
+
|
|
12
|
+
import { meta } from './meta';
|
|
13
|
+
|
|
14
|
+
const moduleId = (name: string) => `${meta.id}.module.${name}`;
|
|
15
|
+
|
|
16
|
+
describe('TemplatePlugin', () => {
|
|
17
|
+
test('modules activate on the expected events', async ({ expect }) => {
|
|
18
|
+
await using harness = await createComposerTestApp({
|
|
19
|
+
plugins: [ClientPlugin({}), TemplatePlugin()],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(harness.manager.getActive()).toEqual(
|
|
23
|
+
expect.arrayContaining([moduleId('CreateObject'), moduleId('schema'), moduleId('ReactSurface')]),
|
|
24
|
+
);
|
|
25
|
+
}, 20_000);
|
|
26
|
+
});
|
package/src/TemplatePlugin.tsx
CHANGED
|
@@ -2,59 +2,20 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
8
|
-
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
9
7
|
|
|
10
|
-
import {
|
|
11
|
-
import { meta } from '
|
|
12
|
-
import { translations } from '
|
|
13
|
-
import {
|
|
8
|
+
import { CreateObject, ReactSurface } from '#capabilities';
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { translations } from '#translations';
|
|
11
|
+
import { Template } from '#types';
|
|
14
12
|
|
|
15
|
-
export const TemplatePlugin = ()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
activatesOn: Events.SetupMetadata,
|
|
25
|
-
activate: () =>
|
|
26
|
-
contributes(Capabilities.Metadata, {
|
|
27
|
-
id: TemplateType.typename,
|
|
28
|
-
metadata: {
|
|
29
|
-
icon: 'ph--asterisk--regular',
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
}),
|
|
33
|
-
defineModule({
|
|
34
|
-
id: `${meta.id}/module/object-form`,
|
|
35
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
36
|
-
activate: () =>
|
|
37
|
-
contributes(
|
|
38
|
-
SpaceCapabilities.ObjectForm,
|
|
39
|
-
defineObjectForm({
|
|
40
|
-
objectSchema: TemplateType,
|
|
41
|
-
getIntent: () => createIntent(TemplateAction.Create),
|
|
42
|
-
}),
|
|
43
|
-
),
|
|
44
|
-
}),
|
|
45
|
-
defineModule({
|
|
46
|
-
id: `${meta.id}/module/schema`,
|
|
47
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
48
|
-
activate: () => contributes(ClientCapabilities.Schema, [TemplateType]),
|
|
49
|
-
}),
|
|
50
|
-
defineModule({
|
|
51
|
-
id: `${meta.id}/module/react-surface`,
|
|
52
|
-
activatesOn: Events.SetupReactSurface,
|
|
53
|
-
activate: ReactSurface,
|
|
54
|
-
}),
|
|
55
|
-
defineModule({
|
|
56
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
57
|
-
activatesOn: Events.SetupIntentResolver,
|
|
58
|
-
activate: IntentResolver,
|
|
59
|
-
}),
|
|
60
|
-
]);
|
|
13
|
+
export const TemplatePlugin = Plugin.define(meta).pipe(
|
|
14
|
+
AppPlugin.addCreateObjectModule({ activate: CreateObject }),
|
|
15
|
+
AppPlugin.addSchemaModule({ schema: [Template.Data] }),
|
|
16
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
17
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
18
|
+
Plugin.make,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default TemplatePlugin;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { SpaceOperation } from '@dxos/plugin-space';
|
|
10
|
+
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
11
|
+
|
|
12
|
+
import { Template } from '#types';
|
|
13
|
+
|
|
14
|
+
export default Capability.makeModule(
|
|
15
|
+
Effect.fnUntraced(function* () {
|
|
16
|
+
return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {
|
|
17
|
+
id: Template.Data.typename,
|
|
18
|
+
createObject: (props, options) =>
|
|
19
|
+
Effect.gen(function* () {
|
|
20
|
+
const object = Template.make(props);
|
|
21
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
22
|
+
object,
|
|
23
|
+
target: options.target,
|
|
24
|
+
hidden: true,
|
|
25
|
+
targetNodeId: options.targetNodeId,
|
|
26
|
+
});
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
7
|
+
export const CreateObject = Capability.lazy('CreateObject', () => import('./create-object'));
|
|
8
|
+
export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
|
|
@@ -2,22 +2,27 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
11
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { isObject } from '../types';
|
|
12
|
+
import { TemplatePanel } from '#components';
|
|
13
|
+
import { Template } from '#types';
|
|
13
14
|
|
|
14
|
-
export default () =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
export default Capability.makeModule(() =>
|
|
16
|
+
Effect.succeed(
|
|
17
|
+
Capability.contributes(
|
|
18
|
+
Capabilities.ReactSurface,
|
|
19
|
+
Surface.create({
|
|
20
|
+
id: 'root',
|
|
21
|
+
filter: AppSurface.object(AppSurface.Article, Template.Data),
|
|
22
|
+
component: ({ data, role }) => (
|
|
23
|
+
<TemplatePanel role={role} subject={data.subject} attendableId={data.attendableId} />
|
|
24
|
+
),
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { Panel } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
export type TemplatePanelProps = AppSurface.ObjectArticleProps<Obj.Unknown>;
|
|
12
|
+
|
|
13
|
+
export const TemplatePanel = ({ role, subject: object, attendableId: _attendableId }: TemplatePanelProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<Panel.Root role={role} className='dx-document'>
|
|
16
|
+
<Panel.Content>
|
|
17
|
+
<span>{Obj.getDXN(object).toString()}</span>
|
|
18
|
+
</Panel.Content>
|
|
19
|
+
</Panel.Root>
|
|
20
|
+
);
|
|
21
|
+
};
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: TEMPLATE_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.template',
|
|
11
10
|
name: 'Template',
|
|
11
|
+
author: 'DXOS',
|
|
12
|
+
description: trim`
|
|
13
|
+
Create reusable templates for documents, tables, and other objects.
|
|
14
|
+
Define structured patterns that can be quickly instantiated with pre-configured content and settings.
|
|
15
|
+
`,
|
|
12
16
|
icon: 'ph--asterisk--regular',
|
|
17
|
+
iconHue: 'sky',
|
|
13
18
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-template',
|
|
14
19
|
};
|
package/src/plugin.ts
ADDED
package/src/translations.ts
CHANGED
|
@@ -4,21 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import {
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
import { Template } from '#types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object
|
|
13
|
+
[Template.Data.typename]: {
|
|
14
|
+
'typename.label': 'Template',
|
|
15
|
+
'typename.label_zero': 'Templates',
|
|
16
|
+
'typename.label_one': 'Template',
|
|
17
|
+
'typename.label_other': 'Templates',
|
|
18
|
+
'object-name.placeholder': 'New template',
|
|
19
|
+
'add-object.label': 'Add template',
|
|
20
|
+
'rename-object.label': 'Rename template',
|
|
21
|
+
'delete-object.label': 'Delete template',
|
|
22
|
+
'object-deleted.label': 'Template deleted',
|
|
19
23
|
},
|
|
20
24
|
[meta.id]: {
|
|
21
|
-
'plugin
|
|
25
|
+
'plugin.name': 'Template',
|
|
22
26
|
},
|
|
23
27
|
},
|
|
24
28
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
8
|
+
|
|
9
|
+
export namespace Template {
|
|
10
|
+
export const Data = Schema.Struct({
|
|
11
|
+
name: Schema.optional(Schema.String),
|
|
12
|
+
}).pipe(
|
|
13
|
+
Type.object({
|
|
14
|
+
typename: 'org.dxos.type.data',
|
|
15
|
+
version: '0.1.0',
|
|
16
|
+
}),
|
|
17
|
+
Annotation.IconAnnotation.set({
|
|
18
|
+
icon: 'ph--asterisk--regular',
|
|
19
|
+
hue: 'sky',
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type Data = Schema.Schema.Type<typeof Data>;
|
|
24
|
+
|
|
25
|
+
export const make = (props: Partial<Data>) => Obj.make(Data, props);
|
|
26
|
+
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// src/types.ts
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { Obj } from "@dxos/echo";
|
|
4
|
-
import { TypedObject } from "@dxos/echo-schema";
|
|
5
|
-
import { ReactiveObjectSchema } from "@dxos/react-client/echo";
|
|
6
|
-
|
|
7
|
-
// src/meta.ts
|
|
8
|
-
var TEMPLATE_PLUGIN = "dxos.org/plugin/template";
|
|
9
|
-
var meta = {
|
|
10
|
-
id: TEMPLATE_PLUGIN,
|
|
11
|
-
name: "Template",
|
|
12
|
-
icon: "ph--asterisk--regular",
|
|
13
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-template"
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
(function(TemplateAction2) {
|
|
18
|
-
const TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;
|
|
19
|
-
class Create extends Schema.TaggedClass()(`${TEMPLATE_ACTION}/create`, {
|
|
20
|
-
input: Schema.Struct({
|
|
21
|
-
name: Schema.optional(Schema.String)
|
|
22
|
-
}),
|
|
23
|
-
output: Schema.Struct({
|
|
24
|
-
object: ReactiveObjectSchema
|
|
25
|
-
})
|
|
26
|
-
}) {
|
|
27
|
-
}
|
|
28
|
-
TemplateAction2.Create = Create;
|
|
29
|
-
})(TemplateAction || (TemplateAction = {}));
|
|
30
|
-
var isObject = (object) => {
|
|
31
|
-
return Obj.isObject(object) && object.type === "template";
|
|
32
|
-
};
|
|
33
|
-
var TemplateType = class extends TypedObject({
|
|
34
|
-
typename: "dxos.org/type/Template",
|
|
35
|
-
version: "0.1.0"
|
|
36
|
-
})({
|
|
37
|
-
name: Schema.optional(Schema.String)
|
|
38
|
-
}) {
|
|
39
|
-
};
|
|
40
|
-
var TemplateAction;
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
TEMPLATE_PLUGIN,
|
|
44
|
-
meta,
|
|
45
|
-
isObject,
|
|
46
|
-
TemplateType,
|
|
47
|
-
TemplateAction
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=chunk-FARPQI2D.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Obj } from '@dxos/echo';\nimport { TypedObject } from '@dxos/echo-schema';\nimport { ReactiveObjectSchema } from '@dxos/react-client/echo';\n\nimport { TEMPLATE_PLUGIN } from './meta';\n\nexport namespace TemplateAction {\n const TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;\n\n export class Create extends Schema.TaggedClass<Create>()(`${TEMPLATE_ACTION}/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: ReactiveObjectSchema,\n }),\n }) {}\n}\n\nexport const isObject = (object: unknown): object is Obj.Any => {\n // TODO(dmaretskyi): Can this be Obj.instanceOf(TemplateType)?\n return Obj.isObject(object) && (object as any).type === 'template';\n};\n\nexport class TemplateType extends TypedObject({\n typename: 'dxos.org/type/Template',\n version: '0.1.0',\n})({\n name: Schema.optional(Schema.String),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const TEMPLATE_PLUGIN = 'dxos.org/plugin/template';\n\nexport const meta: PluginMeta = {\n id: TEMPLATE_PLUGIN,\n name: 'Template',\n icon: 'ph--asterisk--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-template',\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,WAAW;AACpB,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B;;;ACF9B,IAAMC,kBAAkB;AAExB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;;;UDDiBC,iBAAAA;AACf,QAAMC,kBAAkB,GAAGC,eAAAA;EAEpB,MAAMC,eAAeC,OAAOC,YAAW,EAAW,GAAGJ,eAAAA,WAA0B;IACpFK,OAAOF,OAAOG,OAAO;MACnBC,MAAMJ,OAAOK,SAASL,OAAOM,MAAM;IACrC,CAAA;IACAC,QAAQP,OAAOG,OAAO;MACpBK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;kBAPSV,SAAAA;AAQf,GAXiBH,mBAAAA,iBAAAA,CAAAA,EAAAA;AAaV,IAAMc,WAAW,CAACF,WAAAA;AAEvB,SAAOG,IAAID,SAASF,MAAAA,KAAYA,OAAeI,SAAS;AAC1D;AAEO,IAAMC,eAAN,cAA2BC,YAAY;EAC5CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDZ,MAAMJ,OAAOK,SAASL,OAAOM,MAAM;AACrC,CAAA,EAAA;AAAI;;",
|
|
6
|
-
"names": ["Schema", "Obj", "TypedObject", "ReactiveObjectSchema", "TEMPLATE_PLUGIN", "meta", "id", "name", "icon", "source", "TemplateAction", "TEMPLATE_ACTION", "TEMPLATE_PLUGIN", "Create", "Schema", "TaggedClass", "input", "Struct", "name", "optional", "String", "output", "object", "ReactiveObjectSchema", "isObject", "Obj", "type", "TemplateType", "TypedObject", "typename", "version"]
|
|
7
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TEMPLATE_PLUGIN,
|
|
3
|
-
TemplateAction,
|
|
4
|
-
TemplateType,
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-FARPQI2D.mjs";
|
|
7
|
-
|
|
8
|
-
// src/TemplatePlugin.tsx
|
|
9
|
-
import { createIntent, Capabilities, contributes, Events, defineModule, definePlugin } from "@dxos/app-framework";
|
|
10
|
-
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
11
|
-
import { SpaceCapabilities } from "@dxos/plugin-space";
|
|
12
|
-
import { defineObjectForm } from "@dxos/plugin-space/types";
|
|
13
|
-
|
|
14
|
-
// src/capabilities/index.ts
|
|
15
|
-
import { lazy } from "@dxos/app-framework";
|
|
16
|
-
var IntentResolver = lazy(() => import("./intent-resolver-AYJTEW6K.mjs"));
|
|
17
|
-
var ReactSurface = lazy(() => import("./react-surface-H7UCIT3M.mjs"));
|
|
18
|
-
|
|
19
|
-
// src/translations.ts
|
|
20
|
-
var translations = [
|
|
21
|
-
{
|
|
22
|
-
"en-US": {
|
|
23
|
-
[TemplateType.typename]: {
|
|
24
|
-
"typename label": "Template",
|
|
25
|
-
"typename label_zero": "Templates",
|
|
26
|
-
"typename label_one": "Template",
|
|
27
|
-
"typename label_other": "Templates",
|
|
28
|
-
"object name placeholder": "New template"
|
|
29
|
-
},
|
|
30
|
-
[meta.id]: {
|
|
31
|
-
"plugin name": "Template"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
// src/TemplatePlugin.tsx
|
|
38
|
-
var TemplatePlugin = () => definePlugin(meta, [
|
|
39
|
-
defineModule({
|
|
40
|
-
id: `${meta.id}/module/translations`,
|
|
41
|
-
activatesOn: Events.SetupTranslations,
|
|
42
|
-
activate: () => contributes(Capabilities.Translations, translations)
|
|
43
|
-
}),
|
|
44
|
-
defineModule({
|
|
45
|
-
id: `${meta.id}/module/metadata`,
|
|
46
|
-
activatesOn: Events.SetupMetadata,
|
|
47
|
-
activate: () => contributes(Capabilities.Metadata, {
|
|
48
|
-
id: TemplateType.typename,
|
|
49
|
-
metadata: {
|
|
50
|
-
icon: "ph--asterisk--regular"
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
}),
|
|
54
|
-
defineModule({
|
|
55
|
-
id: `${meta.id}/module/object-form`,
|
|
56
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
57
|
-
activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
|
|
58
|
-
objectSchema: TemplateType,
|
|
59
|
-
getIntent: () => createIntent(TemplateAction.Create)
|
|
60
|
-
}))
|
|
61
|
-
}),
|
|
62
|
-
defineModule({
|
|
63
|
-
id: `${meta.id}/module/schema`,
|
|
64
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
65
|
-
activate: () => contributes(ClientCapabilities.Schema, [
|
|
66
|
-
TemplateType
|
|
67
|
-
])
|
|
68
|
-
}),
|
|
69
|
-
defineModule({
|
|
70
|
-
id: `${meta.id}/module/react-surface`,
|
|
71
|
-
activatesOn: Events.SetupReactSurface,
|
|
72
|
-
activate: ReactSurface
|
|
73
|
-
}),
|
|
74
|
-
defineModule({
|
|
75
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
76
|
-
activatesOn: Events.SetupIntentResolver,
|
|
77
|
-
activate: IntentResolver
|
|
78
|
-
})
|
|
79
|
-
]);
|
|
80
|
-
export {
|
|
81
|
-
TEMPLATE_PLUGIN,
|
|
82
|
-
TemplatePlugin,
|
|
83
|
-
meta
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/TemplatePlugin.tsx", "../../../src/capabilities/index.ts", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { createIntent, Capabilities, contributes, Events, defineModule, definePlugin } from '@dxos/app-framework';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\n\nimport { ReactSurface, IntentResolver } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { TemplateAction, TemplateType } from './types';\n\nexport const TemplatePlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: TemplateType.typename,\n metadata: {\n icon: 'ph--asterisk--regular',\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: TemplateType,\n getIntent: () => createIntent(TemplateAction.Create),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () => contributes(ClientCapabilities.Schema, [TemplateType]),\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\nimport { TemplateType } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [TemplateType.typename]: {\n 'typename label': 'Template',\n 'typename label_zero': 'Templates',\n 'typename label_one': 'Template',\n 'typename label_other': 'Templates',\n 'object name placeholder': 'New template',\n },\n [meta.id]: {\n 'plugin name': 'Template',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,SAASA,cAAcC,cAAcC,aAAaC,QAAQC,cAAcC,oBAAoB;AAC5F,SAASC,oBAAoBC,oBAAoB;AACjD,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;;;ACHjC,SAASC,YAAY;AAEd,IAAMC,iBAAiBC,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMC,eAAeD,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ACEvC,IAAME,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,aAAaC,QAAQ,GAAG;QACvB,kBAAkB;QAClB,uBAAuB;QACvB,sBAAsB;QACtB,wBAAwB;QACxB,2BAA2B;MAC7B;MACA,CAACC,KAAKC,EAAE,GAAG;QACT,eAAe;MACjB;IACF;EACF;;;;AFTK,IAAMC,iBAAiB,MAC5BC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,MAAMC,YAAYC,aAAaC,cAAcC,YAAAA;EACzD,CAAA;EACAT,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOO;IACpBL,UAAU,MACRC,YAAYC,aAAaI,UAAU;MACjCV,IAAIW,aAAaC;MACjBC,UAAU;QACRC,MAAM;MACR;IACF,CAAA;EACJ,CAAA;EACAf,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAac,aAAaC;IAC1BZ,UAAU,MACRC,YACEY,kBAAkBC,YAClBC,iBAAiB;MACfC,cAAcT;MACdU,WAAW,MAAMC,aAAaC,eAAeC,MAAM;IACrD,CAAA,CAAA;EAEN,CAAA;EACAzB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAac,aAAaC;IAC1BZ,UAAU,MAAMC,YAAYoB,mBAAmBC,QAAQ;MAACf;KAAa;EACvE,CAAA;EACAZ,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOyB;IACpBvB,UAAUwB;EACZ,CAAA;EACA7B,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO2B;IACpBzB,UAAU0B;EACZ,CAAA;CACD;",
|
|
6
|
-
"names": ["createIntent", "Capabilities", "contributes", "Events", "defineModule", "definePlugin", "ClientCapabilities", "ClientEvents", "SpaceCapabilities", "defineObjectForm", "lazy", "IntentResolver", "lazy", "ReactSurface", "translations", "TemplateType", "typename", "meta", "id", "TemplatePlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "TemplateType", "typename", "metadata", "icon", "ClientEvents", "SetupSchema", "SpaceCapabilities", "ObjectForm", "defineObjectForm", "objectSchema", "getIntent", "createIntent", "TemplateAction", "Create", "ClientCapabilities", "Schema", "SetupReactSurface", "ReactSurface", "SetupIntentResolver", "IntentResolver"]
|
|
7
|
-
}
|