@dxos/plugin-template 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8
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-7RN2XYO6.mjs +21 -0
- package/dist/lib/neutral/chunk-7RN2XYO6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XVITFXCJ.mjs +18 -0
- package/dist/lib/neutral/chunk-XVITFXCJ.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-K2JXEGV4.mjs +26 -0
- package/dist/lib/neutral/create-object-K2JXEGV4.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/meta.mjs.map +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 +28 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/types/index.mjs +1 -1
- 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 -2
- 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 -2
- 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 -13
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +8 -23
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +71 -40
- package/src/TemplatePlugin.test.ts +26 -0
- package/src/TemplatePlugin.tsx +15 -54
- package/src/capabilities/create-object.ts +31 -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/{Example → TemplatePanel}/index.ts +1 -1
- package/src/components/index.ts +1 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +6 -4
- package/src/plugin.ts +9 -0
- package/src/translations.ts +14 -11
- package/src/types/schema.ts +8 -19
- package/dist/lib/browser/chunk-6T47OUOE.mjs +0 -49
- package/dist/lib/browser/chunk-6T47OUOE.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-4BJJ7NBA.mjs +0 -20
- package/dist/lib/browser/intent-resolver-4BJJ7NBA.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-7J6GGCX4.mjs +0 -68
- package/dist/lib/browser/react-surface-7J6GGCX4.mjs.map +0 -7
- 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/Example/Example.d.ts +0 -16
- package/dist/types/src/components/Example/Example.d.ts.map +0 -1
- package/dist/types/src/components/Example/Example.stories.d.ts +0 -19
- package/dist/types/src/components/Example/Example.stories.d.ts.map +0 -1
- package/dist/types/src/components/Example/index.d.ts +0 -2
- package/dist/types/src/components/Example/index.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/src/capabilities/intent-resolver.ts +0 -18
- package/src/components/Example/Example.stories.tsx +0 -32
- package/src/components/Example/Example.tsx +0 -54
- package/src/components/TemplateContainer.tsx +0 -18
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
package/package.json
CHANGED
|
@@ -1,68 +1,99 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-template",
|
|
3
|
-
"version": "0.8.4-
|
|
3
|
+
"version": "0.8.4-staging.60fe92afc8",
|
|
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
|
".": {
|
|
13
49
|
"source": "./src/index.ts",
|
|
14
50
|
"types": "./dist/types/src/index.d.ts",
|
|
15
|
-
"
|
|
51
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
16
52
|
},
|
|
17
|
-
"./
|
|
18
|
-
"source": "./src/
|
|
19
|
-
"types": "./dist/types/src/
|
|
20
|
-
"
|
|
53
|
+
"./plugin": {
|
|
54
|
+
"source": "./src/plugin.ts",
|
|
55
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
56
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
57
|
+
},
|
|
58
|
+
"./translations": {
|
|
59
|
+
"source": "./src/translations.ts",
|
|
60
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
61
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
21
62
|
}
|
|
22
63
|
},
|
|
23
64
|
"types": "dist/types/src/index.d.ts",
|
|
24
|
-
"typesVersions": {
|
|
25
|
-
"*": {
|
|
26
|
-
"types": [
|
|
27
|
-
"dist/types/src/types/index.d.ts"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
65
|
"files": [
|
|
32
66
|
"dist",
|
|
33
67
|
"src"
|
|
34
68
|
],
|
|
35
69
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/plugin-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/plugin-space": "0.8.4-main.fffef41",
|
|
46
|
-
"@dxos/react-client": "0.8.4-main.fffef41",
|
|
47
|
-
"@dxos/react-ui-stack": "0.8.4-main.fffef41",
|
|
48
|
-
"@dxos/util": "0.8.4-main.fffef41"
|
|
70
|
+
"effect": "3.21.3",
|
|
71
|
+
"@dxos/app-framework": "0.8.4-staging.60fe92afc8",
|
|
72
|
+
"@dxos/compute": "0.8.4-staging.60fe92afc8",
|
|
73
|
+
"@dxos/keys": "0.8.4-staging.60fe92afc8",
|
|
74
|
+
"@dxos/echo": "0.8.4-staging.60fe92afc8",
|
|
75
|
+
"@dxos/plugin-client": "0.8.4-staging.60fe92afc8",
|
|
76
|
+
"@dxos/util": "0.8.4-staging.60fe92afc8",
|
|
77
|
+
"@dxos/plugin-space": "0.8.4-staging.60fe92afc8",
|
|
78
|
+
"@dxos/app-toolkit": "0.8.4-staging.60fe92afc8"
|
|
49
79
|
},
|
|
50
80
|
"devDependencies": {
|
|
51
|
-
"@types/react": "~19.2.
|
|
52
|
-
"@types/react-dom": "~19.2.
|
|
53
|
-
"react": "~19.2.
|
|
54
|
-
"react-dom": "~19.2.
|
|
55
|
-
"vite": "
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
81
|
+
"@types/react": "~19.2.7",
|
|
82
|
+
"@types/react-dom": "~19.2.3",
|
|
83
|
+
"react": "~19.2.3",
|
|
84
|
+
"react-dom": "~19.2.3",
|
|
85
|
+
"vite": "^8.0.16",
|
|
86
|
+
"@dxos/plugin-testing": "0.8.4-staging.60fe92afc8",
|
|
87
|
+
"@dxos/react-ui": "0.8.4-staging.60fe92afc8",
|
|
88
|
+
"@dxos/storybook-utils": "0.8.4-staging.60fe92afc8",
|
|
89
|
+
"@dxos/ui-theme": "0.8.4-staging.60fe92afc8"
|
|
59
90
|
},
|
|
60
91
|
"peerDependencies": {
|
|
61
|
-
"effect": "
|
|
62
|
-
"react": "
|
|
63
|
-
"react-dom": "
|
|
64
|
-
"@dxos/react-ui": "0.8.4-
|
|
65
|
-
"@dxos/
|
|
92
|
+
"effect": "3.21.3",
|
|
93
|
+
"react": "~19.2.3",
|
|
94
|
+
"react-dom": "~19.2.3",
|
|
95
|
+
"@dxos/react-ui": "0.8.4-staging.60fe92afc8",
|
|
96
|
+
"@dxos/ui-theme": "0.8.4-staging.60fe92afc8"
|
|
66
97
|
},
|
|
67
98
|
"publishConfig": {
|
|
68
99
|
"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 { Template } from '
|
|
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
|
-
activate: () =>
|
|
25
|
-
contributes(Capabilities.Metadata, {
|
|
26
|
-
id: Template.Data.typename,
|
|
27
|
-
metadata: {
|
|
28
|
-
icon: 'ph--asterisk--regular',
|
|
29
|
-
iconHue: 'sky',
|
|
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: Template.Data,
|
|
41
|
-
getIntent: () => createIntent(Template.Create),
|
|
42
|
-
}),
|
|
43
|
-
),
|
|
44
|
-
}),
|
|
45
|
-
defineModule({
|
|
46
|
-
id: `${meta.id}/module/schema`,
|
|
47
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
48
|
-
activate: () => contributes(ClientCapabilities.Schema, [Template.Data]),
|
|
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,31 @@
|
|
|
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 { Type } from '@dxos/echo';
|
|
10
|
+
import { SpaceOperation } from '@dxos/plugin-space';
|
|
11
|
+
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
12
|
+
|
|
13
|
+
import { Template } from '#types';
|
|
14
|
+
|
|
15
|
+
export default Capability.makeModule(
|
|
16
|
+
Effect.fnUntraced(function* () {
|
|
17
|
+
return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {
|
|
18
|
+
id: Type.getTypename(Template.Data),
|
|
19
|
+
createObject: (props, options) =>
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
const object = Template.make(props);
|
|
22
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
23
|
+
object,
|
|
24
|
+
target: options.target,
|
|
25
|
+
hidden: true,
|
|
26
|
+
targetNodeId: options.targetNodeId,
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
@@ -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 { Template } 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.getURI(object)}</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,12 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { DXN } from '@dxos/keys';
|
|
6
7
|
import { trim } from '@dxos/util';
|
|
7
8
|
|
|
8
|
-
export const meta
|
|
9
|
-
|
|
9
|
+
export const meta = Plugin.makeMeta({
|
|
10
|
+
key: DXN.make('org.dxos.plugin.template'),
|
|
10
11
|
name: 'Template',
|
|
12
|
+
author: 'DXOS',
|
|
11
13
|
description: trim`
|
|
12
14
|
Create reusable templates for documents, tables, and other objects.
|
|
13
15
|
Define structured patterns that can be quickly instantiated with pre-configured content and settings.
|
|
@@ -15,4 +17,4 @@ export const meta: PluginMeta = {
|
|
|
15
17
|
icon: 'ph--asterisk--regular',
|
|
16
18
|
iconHue: 'sky',
|
|
17
19
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-template',
|
|
18
|
-
};
|
|
20
|
+
});
|
package/src/plugin.ts
ADDED
package/src/translations.ts
CHANGED
|
@@ -2,25 +2,28 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Type } from '@dxos/echo';
|
|
5
6
|
import { type Resource } from '@dxos/react-ui';
|
|
6
7
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import { Template } from '
|
|
8
|
+
import { meta } from '#meta';
|
|
9
|
+
import { Template } from '#types';
|
|
9
10
|
|
|
10
11
|
export const translations = [
|
|
11
12
|
{
|
|
12
13
|
'en-US': {
|
|
13
|
-
[Template.Data
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object
|
|
19
|
-
'
|
|
20
|
-
'
|
|
14
|
+
[Type.getTypename(Template.Data)]: {
|
|
15
|
+
'typename.label': 'Template',
|
|
16
|
+
'typename.label_zero': 'Templates',
|
|
17
|
+
'typename.label_one': 'Template',
|
|
18
|
+
'typename.label_other': 'Templates',
|
|
19
|
+
'object-name.placeholder': 'New template',
|
|
20
|
+
'add-object.label': 'Add template',
|
|
21
|
+
'rename-object.label': 'Rename template',
|
|
22
|
+
'delete-object.label': 'Delete template',
|
|
23
|
+
'object-deleted.label': 'Template deleted',
|
|
21
24
|
},
|
|
22
25
|
[meta.id]: {
|
|
23
|
-
'plugin
|
|
26
|
+
'plugin.name': 'Template',
|
|
24
27
|
},
|
|
25
28
|
},
|
|
26
29
|
},
|
package/src/types/schema.ts
CHANGED
|
@@ -4,28 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Obj } from '@dxos/echo';
|
|
8
|
-
import { TypedObject } from '@dxos/echo/internal';
|
|
9
|
-
import { ReactiveObjectSchema } from '@dxos/react-client/echo';
|
|
10
|
-
|
|
11
|
-
import { meta } from '../meta';
|
|
7
|
+
import { DXN, Annotation, Obj, Type } from '@dxos/echo';
|
|
12
8
|
|
|
13
9
|
export namespace Template {
|
|
14
|
-
export
|
|
15
|
-
input: Schema.Struct({
|
|
16
|
-
name: Schema.optional(Schema.String),
|
|
17
|
-
}),
|
|
18
|
-
output: Schema.Struct({
|
|
19
|
-
object: ReactiveObjectSchema,
|
|
20
|
-
}),
|
|
21
|
-
}) {}
|
|
22
|
-
|
|
23
|
-
export class Data extends TypedObject({
|
|
24
|
-
typename: 'dxos.org/type/Data',
|
|
25
|
-
version: '0.1.0',
|
|
26
|
-
})({
|
|
10
|
+
export const Data = Schema.Struct({
|
|
27
11
|
name: Schema.optional(Schema.String),
|
|
28
|
-
})
|
|
12
|
+
}).pipe(
|
|
13
|
+
Annotation.IconAnnotation.set({ icon: 'ph--asterisk--regular', hue: 'sky' }),
|
|
14
|
+
Type.makeObject(DXN.make('org.dxos.type.data', '0.1.0')),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export type Data = Type.InstanceType<typeof Data>;
|
|
29
18
|
|
|
30
19
|
export const make = (props: Partial<Data>) => Obj.make(Data, props);
|
|
31
20
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// src/types/schema.ts
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
|
-
import { Obj } from "@dxos/echo";
|
|
4
|
-
import { TypedObject } from "@dxos/echo/internal";
|
|
5
|
-
import { ReactiveObjectSchema } from "@dxos/react-client/echo";
|
|
6
|
-
|
|
7
|
-
// src/meta.ts
|
|
8
|
-
import { trim } from "@dxos/util";
|
|
9
|
-
var meta = {
|
|
10
|
-
id: "dxos.org/plugin/template",
|
|
11
|
-
name: "Template",
|
|
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
|
-
`,
|
|
16
|
-
icon: "ph--asterisk--regular",
|
|
17
|
-
iconHue: "sky",
|
|
18
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-template"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// src/types/schema.ts
|
|
22
|
-
(function(Template2) {
|
|
23
|
-
class Create extends Schema.TaggedClass()(`${meta.id}/action/create`, {
|
|
24
|
-
input: Schema.Struct({
|
|
25
|
-
name: Schema.optional(Schema.String)
|
|
26
|
-
}),
|
|
27
|
-
output: Schema.Struct({
|
|
28
|
-
object: ReactiveObjectSchema
|
|
29
|
-
})
|
|
30
|
-
}) {
|
|
31
|
-
}
|
|
32
|
-
Template2.Create = Create;
|
|
33
|
-
class Data extends TypedObject({
|
|
34
|
-
typename: "dxos.org/type/Data",
|
|
35
|
-
version: "0.1.0"
|
|
36
|
-
})({
|
|
37
|
-
name: Schema.optional(Schema.String)
|
|
38
|
-
}) {
|
|
39
|
-
}
|
|
40
|
-
Template2.Data = Data;
|
|
41
|
-
Template2.make = (props) => Obj.make(Data, props);
|
|
42
|
-
})(Template || (Template = {}));
|
|
43
|
-
var Template;
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
meta,
|
|
47
|
-
Template
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=chunk-6T47OUOE.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Obj } from '@dxos/echo';\nimport { TypedObject } from '@dxos/echo/internal';\nimport { ReactiveObjectSchema } from '@dxos/react-client/echo';\n\nimport { meta } from '../meta';\n\nexport namespace Template {\n export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: ReactiveObjectSchema,\n }),\n }) {}\n\n export class Data extends TypedObject({\n typename: 'dxos.org/type/Data',\n version: '0.1.0',\n })({\n name: Schema.optional(Schema.String),\n }) {}\n\n export const make = (props: Partial<Data>) => Obj.make(Data, props);\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/template',\n name: 'Template',\n description: trim`\n Create reusable templates for documents, tables, and other objects.\n Define structured patterns that can be quickly instantiated with pre-configured content and settings.\n `,\n icon: 'ph--asterisk--regular',\n iconHue: 'sky',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-template',\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,WAAW;AACpB,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B;;;ACHrC,SAASC,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;AACV;;;UDLiBC,WAAAA;EACR,MAAMC,eAAsBC,mBAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAcC,cAAO;MACnBC,MAAaC,gBAAgBC,aAAM;IACrC,CAAA;IACAC,QAAeJ,cAAO;MACpBK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;YAPSX,SAAAA;EASN,MAAMY,aAAaC,YAAY;IACpCC,UAAU;IACVC,SAAS;EACX,CAAA,EAAG;IACDT,MAAaC,gBAAgBC,aAAM;EACrC,CAAA,EAAA;EAAI;YALSI,OAAAA;YAOAI,OAAO,CAACC,UAAyBC,IAAIF,KAAKJ,MAAMK,KAAAA;AAC/D,GAlBiBlB,aAAAA,WAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "Obj", "TypedObject", "ReactiveObjectSchema", "trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "Template", "Create", "TaggedClass", "meta", "id", "input", "Struct", "name", "optional", "String", "output", "object", "ReactiveObjectSchema", "Data", "TypedObject", "typename", "version", "make", "props", "Obj"]
|
|
7
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Template,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-6T47OUOE.mjs";
|
|
5
|
-
|
|
6
|
-
// src/TemplatePlugin.tsx
|
|
7
|
-
import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from "@dxos/app-framework";
|
|
8
|
-
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
9
|
-
import { SpaceCapabilities } from "@dxos/plugin-space";
|
|
10
|
-
import { defineObjectForm } from "@dxos/plugin-space/types";
|
|
11
|
-
|
|
12
|
-
// src/capabilities/index.ts
|
|
13
|
-
import { lazy } from "@dxos/app-framework";
|
|
14
|
-
var IntentResolver = lazy(() => import("./intent-resolver-4BJJ7NBA.mjs"));
|
|
15
|
-
var ReactSurface = lazy(() => import("./react-surface-7J6GGCX4.mjs"));
|
|
16
|
-
|
|
17
|
-
// src/translations.ts
|
|
18
|
-
var translations = [
|
|
19
|
-
{
|
|
20
|
-
"en-US": {
|
|
21
|
-
[Template.Data.typename]: {
|
|
22
|
-
"typename label": "Template",
|
|
23
|
-
"typename label_zero": "Templates",
|
|
24
|
-
"typename label_one": "Template",
|
|
25
|
-
"typename label_other": "Templates",
|
|
26
|
-
"object name placeholder": "New template",
|
|
27
|
-
"rename object label": "Rename template",
|
|
28
|
-
"delete object label": "Delete 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: Template.Data.typename,
|
|
49
|
-
metadata: {
|
|
50
|
-
icon: "ph--asterisk--regular",
|
|
51
|
-
iconHue: "sky"
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}),
|
|
55
|
-
defineModule({
|
|
56
|
-
id: `${meta.id}/module/object-form`,
|
|
57
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
58
|
-
activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
|
|
59
|
-
objectSchema: Template.Data,
|
|
60
|
-
getIntent: () => createIntent(Template.Create)
|
|
61
|
-
}))
|
|
62
|
-
}),
|
|
63
|
-
defineModule({
|
|
64
|
-
id: `${meta.id}/module/schema`,
|
|
65
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
66
|
-
activate: () => contributes(ClientCapabilities.Schema, [
|
|
67
|
-
Template.Data
|
|
68
|
-
])
|
|
69
|
-
}),
|
|
70
|
-
defineModule({
|
|
71
|
-
id: `${meta.id}/module/react-surface`,
|
|
72
|
-
activatesOn: Events.SetupReactSurface,
|
|
73
|
-
activate: ReactSurface
|
|
74
|
-
}),
|
|
75
|
-
defineModule({
|
|
76
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
77
|
-
activatesOn: Events.SetupIntentResolver,
|
|
78
|
-
activate: IntentResolver
|
|
79
|
-
})
|
|
80
|
-
]);
|
|
81
|
-
export {
|
|
82
|
-
TemplatePlugin,
|
|
83
|
-
meta
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=index.mjs.map
|