@dxos/plugin-preview 0.8.2-main.12df754

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 ADDED
@@ -0,0 +1,8 @@
1
+ MIT License
2
+ Copyright (c) 2022 DXOS
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @dxos/plugin-preview
@@ -0,0 +1,81 @@
1
+ // packages/plugins/plugin-preview/src/meta.ts
2
+ var PREVIEW_PLUGIN = "dxos.org/plugin/preview";
3
+ var meta = {
4
+ id: PREVIEW_PLUGIN,
5
+ name: "Preview",
6
+ icon: "ph--eye--regular",
7
+ source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
8
+ };
9
+
10
+ // packages/plugins/plugin-preview/src/PreviewPlugin.tsx
11
+ import { createIntent, Capabilities, contributes, Events, defineModule, definePlugin, LayoutAction } from "@dxos/app-framework";
12
+ import { addEventListener } from "@dxos/async";
13
+ import { resolveRef } from "@dxos/client";
14
+ import { parseId } from "@dxos/client/echo";
15
+ import { DXN } from "@dxos/keys";
16
+ import { log } from "@dxos/log";
17
+ import { ClientCapabilities } from "@dxos/plugin-client";
18
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-preview/src/PreviewPlugin.tsx";
19
+ var customEventOptions = {
20
+ capture: true,
21
+ passive: false
22
+ };
23
+ var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
24
+ const dxn = DXN.parse(ref);
25
+ if (!dxn) {
26
+ return null;
27
+ }
28
+ const object = await resolveRef(client, dxn, defaultSpace);
29
+ return {
30
+ label,
31
+ object
32
+ };
33
+ };
34
+ var PreviewPlugin = () => definePlugin(meta, [
35
+ defineModule({
36
+ id: `${meta.id}/module/preview-popoevr`,
37
+ activatesOn: Events.Startup,
38
+ activate: (context) => {
39
+ const handleDxRefTagActivate = async ({ ref, label, trigger }) => {
40
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
41
+ const client = context.requestCapability(ClientCapabilities.Client);
42
+ const [layout] = context.requestCapabilities(Capabilities.Layout);
43
+ const { spaceId } = parseId(layout.workspace);
44
+ const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
45
+ const result = await handlePreviewLookup(client, space, {
46
+ ref,
47
+ label
48
+ });
49
+ if (!result) {
50
+ return;
51
+ }
52
+ await dispatch(createIntent(LayoutAction.UpdatePopover, {
53
+ part: "popover",
54
+ subject: result.object,
55
+ options: {
56
+ state: true,
57
+ variant: "virtual",
58
+ anchor: trigger
59
+ }
60
+ }));
61
+ };
62
+ if (!document.defaultView) {
63
+ log.warn("No default view found", void 0, {
64
+ F: __dxlog_file,
65
+ L: 74,
66
+ S: void 0,
67
+ C: (f, a) => f(...a)
68
+ });
69
+ return [];
70
+ }
71
+ const cleanup = addEventListener(document.defaultView, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions);
72
+ return contributes(Capabilities.Null, null, () => cleanup());
73
+ }
74
+ })
75
+ ]);
76
+ export {
77
+ PREVIEW_PLUGIN,
78
+ PreviewPlugin,
79
+ meta
80
+ };
81
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts", "../../../src/PreviewPlugin.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';\n\nexport const meta: PluginMeta = {\n id: PREVIEW_PLUGIN,\n name: 'Preview',\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport {\n createIntent,\n Capabilities,\n contributes,\n Events,\n defineModule,\n definePlugin,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { resolveRef } from '@dxos/client';\nimport { parseId, type Space } from '@dxos/client/echo';\nimport { DXN } from '@dxos/keys';\nimport { type DxRefTagActivate } from '@dxos/lit-ui';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';\n\nimport { meta } from './meta';\n\nconst customEventOptions = { capture: true, passive: false };\n\nconst handlePreviewLookup = async (\n client: Client,\n defaultSpace: Space,\n { ref, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n const dxn = DXN.parse(ref);\n if (!dxn) {\n return null;\n }\n\n const object = await resolveRef(client, dxn, defaultSpace);\n return { label, object };\n};\n\nexport const PreviewPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/preview-popoevr`,\n activatesOn: Events.Startup,\n activate: (context) => {\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleDxRefTagActivate = async ({ ref, label, trigger }: DxRefTagActivate) => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n const client = context.requestCapability(ClientCapabilities.Client);\n const [layout] = context.requestCapabilities(Capabilities.Layout);\n const { spaceId } = parseId(layout.workspace);\n const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;\n const result = await handlePreviewLookup(client, space, { ref, label });\n if (!result) {\n return;\n }\n\n await dispatch(\n createIntent(LayoutAction.UpdatePopover, {\n part: 'popover',\n subject: result.object,\n options: {\n state: true,\n variant: 'virtual',\n anchor: trigger,\n },\n }),\n );\n };\n\n if (!document.defaultView) {\n log.warn('No default view found');\n return [];\n }\n\n const cleanup = addEventListener(\n document.defaultView,\n 'dx-ref-tag-activate',\n handleDxRefTagActivate,\n customEventOptions,\n );\n return contributes(Capabilities.Null, null, () => cleanup());\n },\n }),\n ]);\n"],
5
+ "mappings": ";AAMO,IAAMA,iBAAiB;AAEvB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;;;ACTA,SACEC,cACAC,cACAC,aACAC,QACAC,cACAC,cACAC,oBACK;AACP,SAASC,wBAAwB;AAEjC,SAASC,kBAAkB;AAC3B,SAASC,eAA2B;AACpC,SAASC,WAAW;AAEpB,SAASC,WAAW;AACpB,SAASC,0BAA0B;;AAKnC,IAAMC,qBAAqB;EAAEC,SAAS;EAAMC,SAAS;AAAM;AAE3D,IAAMC,sBAAsB,OAC1BC,QACAC,cACA,EAAEC,KAAKC,MAAK,MAAkB;AAE9B,QAAMC,MAAMC,IAAIC,MAAMJ,GAAAA;AACtB,MAAI,CAACE,KAAK;AACR,WAAO;EACT;AAEA,QAAMG,SAAS,MAAMC,WAAWR,QAAQI,KAAKH,YAAAA;AAC7C,SAAO;IAAEE;IAAOI;EAAO;AACzB;AAEO,IAAME,gBAAgB,MAC3BC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,CAACC,YAAAA;AAET,YAAMC,yBAAyB,OAAO,EAAEjB,KAAKC,OAAOiB,QAAO,MAAoB;AAC7E,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKJ,QAAQK,kBAAkBC,aAAaC,gBAAgB;AAC7F,cAAMzB,SAASkB,QAAQK,kBAAkBG,mBAAmBC,MAAM;AAClE,cAAM,CAACC,MAAAA,IAAUV,QAAQW,oBAAoBL,aAAaM,MAAM;AAChE,cAAM,EAAEC,QAAO,IAAKC,QAAQJ,OAAOK,SAAS;AAC5C,cAAMC,SAASH,WAAW/B,OAAOmC,OAAOC,IAAIL,OAAAA,MAAa/B,OAAOmC,OAAOE;AACvE,cAAMC,SAAS,MAAMvC,oBAAoBC,QAAQkC,OAAO;UAAEhC;UAAKC;QAAM,CAAA;AACrE,YAAI,CAACmC,QAAQ;AACX;QACF;AAEA,cAAMhB,SACJiB,aAAaC,aAAaC,eAAe;UACvCC,MAAM;UACNC,SAASL,OAAO/B;UAChBqC,SAAS;YACPC,OAAO;YACPC,SAAS;YACTC,QAAQ3B;UACV;QACF,CAAA,CAAA;MAEJ;AAEA,UAAI,CAAC4B,SAASC,aAAa;AACzBC,YAAIC,KAAK,yBAAA,QAAA;;;;;;AACT,eAAO,CAAA;MACT;AAEA,YAAMC,UAAUC,iBACdL,SAASC,aACT,uBACA9B,wBACAvB,kBAAAA;AAEF,aAAO0D,YAAY9B,aAAa+B,MAAM,MAAM,MAAMH,QAAAA,CAAAA;IACpD;EACF,CAAA;CACD;",
6
+ "names": ["PREVIEW_PLUGIN", "meta", "id", "name", "icon", "source", "createIntent", "Capabilities", "contributes", "Events", "defineModule", "definePlugin", "LayoutAction", "addEventListener", "resolveRef", "parseId", "DXN", "log", "ClientCapabilities", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "dxn", "DXN", "parse", "object", "resolveRef", "PreviewPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activate", "context", "handleDxRefTagActivate", "trigger", "dispatchPromise", "dispatch", "requestCapability", "Capabilities", "IntentDispatcher", "ClientCapabilities", "Client", "layout", "requestCapabilities", "Layout", "spaceId", "parseId", "workspace", "space", "spaces", "get", "default", "result", "createIntent", "LayoutAction", "UpdatePopover", "part", "subject", "options", "state", "variant", "anchor", "document", "defaultView", "log", "warn", "cleanup", "addEventListener", "contributes", "Null"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/plugins/plugin-preview/src/meta.ts":{"bytes":1296,"imports":[],"format":"esm"},"packages/plugins/plugin-preview/src/PreviewPlugin.tsx":{"bytes":10087,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-preview/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-preview/src/index.ts":{"bytes":596,"imports":[{"path":"packages/plugins/plugin-preview/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-preview/src/PreviewPlugin.tsx","kind":"import-statement","original":"./PreviewPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-preview/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5715},"packages/plugins/plugin-preview/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true}],"exports":["PREVIEW_PLUGIN","PreviewPlugin","meta"],"entryPoint":"packages/plugins/plugin-preview/src/index.ts","inputs":{"packages/plugins/plugin-preview/src/meta.ts":{"bytesInOutput":216},"packages/plugins/plugin-preview/src/index.ts":{"bytesInOutput":0},"packages/plugins/plugin-preview/src/PreviewPlugin.tsx":{"bytesInOutput":2307}},"bytes":2717}}}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var node_exports = {};
20
+ __export(node_exports, {
21
+ PREVIEW_PLUGIN: () => PREVIEW_PLUGIN,
22
+ PreviewPlugin: () => PreviewPlugin,
23
+ meta: () => meta
24
+ });
25
+ module.exports = __toCommonJS(node_exports);
26
+ var import_app_framework = require("@dxos/app-framework");
27
+ var import_async = require("@dxos/async");
28
+ var import_client = require("@dxos/client");
29
+ var import_echo = require("@dxos/client/echo");
30
+ var import_keys = require("@dxos/keys");
31
+ var import_log = require("@dxos/log");
32
+ var import_plugin_client = require("@dxos/plugin-client");
33
+ var PREVIEW_PLUGIN = "dxos.org/plugin/preview";
34
+ var meta = {
35
+ id: PREVIEW_PLUGIN,
36
+ name: "Preview",
37
+ icon: "ph--eye--regular",
38
+ source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
39
+ };
40
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-preview/src/PreviewPlugin.tsx";
41
+ var customEventOptions = {
42
+ capture: true,
43
+ passive: false
44
+ };
45
+ var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
46
+ const dxn = import_keys.DXN.parse(ref);
47
+ if (!dxn) {
48
+ return null;
49
+ }
50
+ const object = await (0, import_client.resolveRef)(client, dxn, defaultSpace);
51
+ return {
52
+ label,
53
+ object
54
+ };
55
+ };
56
+ var PreviewPlugin = () => (0, import_app_framework.definePlugin)(meta, [
57
+ (0, import_app_framework.defineModule)({
58
+ id: `${meta.id}/module/preview-popoevr`,
59
+ activatesOn: import_app_framework.Events.Startup,
60
+ activate: (context) => {
61
+ const handleDxRefTagActivate = async ({ ref, label, trigger }) => {
62
+ const { dispatchPromise: dispatch } = context.requestCapability(import_app_framework.Capabilities.IntentDispatcher);
63
+ const client = context.requestCapability(import_plugin_client.ClientCapabilities.Client);
64
+ const [layout] = context.requestCapabilities(import_app_framework.Capabilities.Layout);
65
+ const { spaceId } = (0, import_echo.parseId)(layout.workspace);
66
+ const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
67
+ const result = await handlePreviewLookup(client, space, {
68
+ ref,
69
+ label
70
+ });
71
+ if (!result) {
72
+ return;
73
+ }
74
+ await dispatch((0, import_app_framework.createIntent)(import_app_framework.LayoutAction.UpdatePopover, {
75
+ part: "popover",
76
+ subject: result.object,
77
+ options: {
78
+ state: true,
79
+ variant: "virtual",
80
+ anchor: trigger
81
+ }
82
+ }));
83
+ };
84
+ if (!document.defaultView) {
85
+ import_log.log.warn("No default view found", void 0, {
86
+ F: __dxlog_file,
87
+ L: 74,
88
+ S: void 0,
89
+ C: (f, a) => f(...a)
90
+ });
91
+ return [];
92
+ }
93
+ const cleanup = (0, import_async.addEventListener)(document.defaultView, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions);
94
+ return (0, import_app_framework.contributes)(import_app_framework.Capabilities.Null, null, () => cleanup());
95
+ }
96
+ })
97
+ ]);
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ PREVIEW_PLUGIN,
101
+ PreviewPlugin,
102
+ meta
103
+ });
104
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts", "../../../src/PreviewPlugin.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';\n\nexport const meta: PluginMeta = {\n id: PREVIEW_PLUGIN,\n name: 'Preview',\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport {\n createIntent,\n Capabilities,\n contributes,\n Events,\n defineModule,\n definePlugin,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { resolveRef } from '@dxos/client';\nimport { parseId, type Space } from '@dxos/client/echo';\nimport { DXN } from '@dxos/keys';\nimport { type DxRefTagActivate } from '@dxos/lit-ui';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';\n\nimport { meta } from './meta';\n\nconst customEventOptions = { capture: true, passive: false };\n\nconst handlePreviewLookup = async (\n client: Client,\n defaultSpace: Space,\n { ref, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n const dxn = DXN.parse(ref);\n if (!dxn) {\n return null;\n }\n\n const object = await resolveRef(client, dxn, defaultSpace);\n return { label, object };\n};\n\nexport const PreviewPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/preview-popoevr`,\n activatesOn: Events.Startup,\n activate: (context) => {\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleDxRefTagActivate = async ({ ref, label, trigger }: DxRefTagActivate) => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n const client = context.requestCapability(ClientCapabilities.Client);\n const [layout] = context.requestCapabilities(Capabilities.Layout);\n const { spaceId } = parseId(layout.workspace);\n const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;\n const result = await handlePreviewLookup(client, space, { ref, label });\n if (!result) {\n return;\n }\n\n await dispatch(\n createIntent(LayoutAction.UpdatePopover, {\n part: 'popover',\n subject: result.object,\n options: {\n state: true,\n variant: 'virtual',\n anchor: trigger,\n },\n }),\n );\n };\n\n if (!document.defaultView) {\n log.warn('No default view found');\n return [];\n }\n\n const cleanup = addEventListener(\n document.defaultView,\n 'dx-ref-tag-activate',\n handleDxRefTagActivate,\n customEventOptions,\n );\n return contributes(Capabilities.Null, null, () => cleanup());\n },\n }),\n ]);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;ACIA,2BAQO;AACP,mBAAiC;AAEjC,oBAA2B;AAC3B,kBAAoC;AACpC,kBAAoB;AAEpB,iBAAoB;AACpB,2BAAmC;ADd5B,IAAMA,iBAAiB;AAEvB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;;ACYA,IAAMC,qBAAqB;EAAEC,SAAS;EAAMC,SAAS;AAAM;AAE3D,IAAMC,sBAAsB,OAC1BC,QACAC,cACA,EAAEC,KAAKC,MAAK,MAAkB;AAE9B,QAAMC,MAAMC,gBAAIC,MAAMJ,GAAAA;AACtB,MAAI,CAACE,KAAK;AACR,WAAO;EACT;AAEA,QAAMG,SAAS,UAAMC,0BAAWR,QAAQI,KAAKH,YAAAA;AAC7C,SAAO;IAAEE;IAAOI;EAAO;AACzB;AAEO,IAAME,gBAAgB,UAC3BC,mCAAanB,MAAM;MACjBoB,mCAAa;IACXnB,IAAI,GAAGD,KAAKC,EAAE;IACdoB,aAAaC,4BAAOC;IACpBC,UAAU,CAACC,YAAAA;AAET,YAAMC,yBAAyB,OAAO,EAAEf,KAAKC,OAAOe,QAAO,MAAoB;AAC7E,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKJ,QAAQK,kBAAkBC,kCAAaC,gBAAgB;AAC7F,cAAMvB,SAASgB,QAAQK,kBAAkBG,wCAAmBC,MAAM;AAClE,cAAM,CAACC,MAAAA,IAAUV,QAAQW,oBAAoBL,kCAAaM,MAAM;AAChE,cAAM,EAAEC,QAAO,QAAKC,qBAAQJ,OAAOK,SAAS;AAC5C,cAAMC,SAASH,WAAW7B,OAAOiC,OAAOC,IAAIL,OAAAA,MAAa7B,OAAOiC,OAAOE;AACvE,cAAMC,SAAS,MAAMrC,oBAAoBC,QAAQgC,OAAO;UAAE9B;UAAKC;QAAM,CAAA;AACrE,YAAI,CAACiC,QAAQ;AACX;QACF;AAEA,cAAMhB,aACJiB,mCAAaC,kCAAaC,eAAe;UACvCC,MAAM;UACNC,SAASL,OAAO7B;UAChBmC,SAAS;YACPC,OAAO;YACPC,SAAS;YACTC,QAAQ3B;UACV;QACF,CAAA,CAAA;MAEJ;AAEA,UAAI,CAAC4B,SAASC,aAAa;AACzBC,uBAAIC,KAAK,yBAAA,QAAA;;;;;;AACT,eAAO,CAAA;MACT;AAEA,YAAMC,cAAUC,+BACdL,SAASC,aACT,uBACA9B,wBACArB,kBAAAA;AAEF,iBAAOwD,kCAAY9B,kCAAa+B,MAAM,MAAM,MAAMH,QAAAA,CAAAA;IACpD;EACF,CAAA;CACD;",
6
+ "names": ["PREVIEW_PLUGIN", "meta", "id", "name", "icon", "source", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "dxn", "DXN", "parse", "object", "resolveRef", "PreviewPlugin", "definePlugin", "defineModule", "activatesOn", "Events", "Startup", "activate", "context", "handleDxRefTagActivate", "trigger", "dispatchPromise", "dispatch", "requestCapability", "Capabilities", "IntentDispatcher", "ClientCapabilities", "Client", "layout", "requestCapabilities", "Layout", "spaceId", "parseId", "workspace", "space", "spaces", "get", "default", "result", "createIntent", "LayoutAction", "UpdatePopover", "part", "subject", "options", "state", "variant", "anchor", "document", "defaultView", "log", "warn", "cleanup", "addEventListener", "contributes", "Null"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/plugins/plugin-preview/src/meta.ts":{"bytes":1296,"imports":[],"format":"esm"},"packages/plugins/plugin-preview/src/PreviewPlugin.tsx":{"bytes":10087,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-preview/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-preview/src/index.ts":{"bytes":596,"imports":[{"path":"packages/plugins/plugin-preview/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-preview/src/PreviewPlugin.tsx","kind":"import-statement","original":"./PreviewPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-preview/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5715},"packages/plugins/plugin-preview/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true}],"exports":["PREVIEW_PLUGIN","PreviewPlugin","meta"],"entryPoint":"packages/plugins/plugin-preview/src/index.ts","inputs":{"packages/plugins/plugin-preview/src/meta.ts":{"bytesInOutput":216},"packages/plugins/plugin-preview/src/index.ts":{"bytesInOutput":0},"packages/plugins/plugin-preview/src/PreviewPlugin.tsx":{"bytesInOutput":2307}},"bytes":2717}}}
@@ -0,0 +1,83 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/plugins/plugin-preview/src/meta.ts
4
+ var PREVIEW_PLUGIN = "dxos.org/plugin/preview";
5
+ var meta = {
6
+ id: PREVIEW_PLUGIN,
7
+ name: "Preview",
8
+ icon: "ph--eye--regular",
9
+ source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
10
+ };
11
+
12
+ // packages/plugins/plugin-preview/src/PreviewPlugin.tsx
13
+ import { createIntent, Capabilities, contributes, Events, defineModule, definePlugin, LayoutAction } from "@dxos/app-framework";
14
+ import { addEventListener } from "@dxos/async";
15
+ import { resolveRef } from "@dxos/client";
16
+ import { parseId } from "@dxos/client/echo";
17
+ import { DXN } from "@dxos/keys";
18
+ import { log } from "@dxos/log";
19
+ import { ClientCapabilities } from "@dxos/plugin-client";
20
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-preview/src/PreviewPlugin.tsx";
21
+ var customEventOptions = {
22
+ capture: true,
23
+ passive: false
24
+ };
25
+ var handlePreviewLookup = async (client, defaultSpace, { ref, label }) => {
26
+ const dxn = DXN.parse(ref);
27
+ if (!dxn) {
28
+ return null;
29
+ }
30
+ const object = await resolveRef(client, dxn, defaultSpace);
31
+ return {
32
+ label,
33
+ object
34
+ };
35
+ };
36
+ var PreviewPlugin = () => definePlugin(meta, [
37
+ defineModule({
38
+ id: `${meta.id}/module/preview-popoevr`,
39
+ activatesOn: Events.Startup,
40
+ activate: (context) => {
41
+ const handleDxRefTagActivate = async ({ ref, label, trigger }) => {
42
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
43
+ const client = context.requestCapability(ClientCapabilities.Client);
44
+ const [layout] = context.requestCapabilities(Capabilities.Layout);
45
+ const { spaceId } = parseId(layout.workspace);
46
+ const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
47
+ const result = await handlePreviewLookup(client, space, {
48
+ ref,
49
+ label
50
+ });
51
+ if (!result) {
52
+ return;
53
+ }
54
+ await dispatch(createIntent(LayoutAction.UpdatePopover, {
55
+ part: "popover",
56
+ subject: result.object,
57
+ options: {
58
+ state: true,
59
+ variant: "virtual",
60
+ anchor: trigger
61
+ }
62
+ }));
63
+ };
64
+ if (!document.defaultView) {
65
+ log.warn("No default view found", void 0, {
66
+ F: __dxlog_file,
67
+ L: 74,
68
+ S: void 0,
69
+ C: (f, a) => f(...a)
70
+ });
71
+ return [];
72
+ }
73
+ const cleanup = addEventListener(document.defaultView, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions);
74
+ return contributes(Capabilities.Null, null, () => cleanup());
75
+ }
76
+ })
77
+ ]);
78
+ export {
79
+ PREVIEW_PLUGIN,
80
+ PreviewPlugin,
81
+ meta
82
+ };
83
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts", "../../../src/PreviewPlugin.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';\n\nexport const meta: PluginMeta = {\n id: PREVIEW_PLUGIN,\n name: 'Preview',\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport {\n createIntent,\n Capabilities,\n contributes,\n Events,\n defineModule,\n definePlugin,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { resolveRef } from '@dxos/client';\nimport { parseId, type Space } from '@dxos/client/echo';\nimport { DXN } from '@dxos/keys';\nimport { type DxRefTagActivate } from '@dxos/lit-ui';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';\n\nimport { meta } from './meta';\n\nconst customEventOptions = { capture: true, passive: false };\n\nconst handlePreviewLookup = async (\n client: Client,\n defaultSpace: Space,\n { ref, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n const dxn = DXN.parse(ref);\n if (!dxn) {\n return null;\n }\n\n const object = await resolveRef(client, dxn, defaultSpace);\n return { label, object };\n};\n\nexport const PreviewPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/preview-popoevr`,\n activatesOn: Events.Startup,\n activate: (context) => {\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleDxRefTagActivate = async ({ ref, label, trigger }: DxRefTagActivate) => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n const client = context.requestCapability(ClientCapabilities.Client);\n const [layout] = context.requestCapabilities(Capabilities.Layout);\n const { spaceId } = parseId(layout.workspace);\n const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;\n const result = await handlePreviewLookup(client, space, { ref, label });\n if (!result) {\n return;\n }\n\n await dispatch(\n createIntent(LayoutAction.UpdatePopover, {\n part: 'popover',\n subject: result.object,\n options: {\n state: true,\n variant: 'virtual',\n anchor: trigger,\n },\n }),\n );\n };\n\n if (!document.defaultView) {\n log.warn('No default view found');\n return [];\n }\n\n const cleanup = addEventListener(\n document.defaultView,\n 'dx-ref-tag-activate',\n handleDxRefTagActivate,\n customEventOptions,\n );\n return contributes(Capabilities.Null, null, () => cleanup());\n },\n }),\n ]);\n"],
5
+ "mappings": ";;;AAMO,IAAMA,iBAAiB;AAEvB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;;;ACTA,SACEC,cACAC,cACAC,aACAC,QACAC,cACAC,cACAC,oBACK;AACP,SAASC,wBAAwB;AAEjC,SAASC,kBAAkB;AAC3B,SAASC,eAA2B;AACpC,SAASC,WAAW;AAEpB,SAASC,WAAW;AACpB,SAASC,0BAA0B;;AAKnC,IAAMC,qBAAqB;EAAEC,SAAS;EAAMC,SAAS;AAAM;AAE3D,IAAMC,sBAAsB,OAC1BC,QACAC,cACA,EAAEC,KAAKC,MAAK,MAAkB;AAE9B,QAAMC,MAAMC,IAAIC,MAAMJ,GAAAA;AACtB,MAAI,CAACE,KAAK;AACR,WAAO;EACT;AAEA,QAAMG,SAAS,MAAMC,WAAWR,QAAQI,KAAKH,YAAAA;AAC7C,SAAO;IAAEE;IAAOI;EAAO;AACzB;AAEO,IAAME,gBAAgB,MAC3BC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,CAACC,YAAAA;AAET,YAAMC,yBAAyB,OAAO,EAAEjB,KAAKC,OAAOiB,QAAO,MAAoB;AAC7E,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKJ,QAAQK,kBAAkBC,aAAaC,gBAAgB;AAC7F,cAAMzB,SAASkB,QAAQK,kBAAkBG,mBAAmBC,MAAM;AAClE,cAAM,CAACC,MAAAA,IAAUV,QAAQW,oBAAoBL,aAAaM,MAAM;AAChE,cAAM,EAAEC,QAAO,IAAKC,QAAQJ,OAAOK,SAAS;AAC5C,cAAMC,SAASH,WAAW/B,OAAOmC,OAAOC,IAAIL,OAAAA,MAAa/B,OAAOmC,OAAOE;AACvE,cAAMC,SAAS,MAAMvC,oBAAoBC,QAAQkC,OAAO;UAAEhC;UAAKC;QAAM,CAAA;AACrE,YAAI,CAACmC,QAAQ;AACX;QACF;AAEA,cAAMhB,SACJiB,aAAaC,aAAaC,eAAe;UACvCC,MAAM;UACNC,SAASL,OAAO/B;UAChBqC,SAAS;YACPC,OAAO;YACPC,SAAS;YACTC,QAAQ3B;UACV;QACF,CAAA,CAAA;MAEJ;AAEA,UAAI,CAAC4B,SAASC,aAAa;AACzBC,YAAIC,KAAK,yBAAA,QAAA;;;;;;AACT,eAAO,CAAA;MACT;AAEA,YAAMC,UAAUC,iBACdL,SAASC,aACT,uBACA9B,wBACAvB,kBAAAA;AAEF,aAAO0D,YAAY9B,aAAa+B,MAAM,MAAM,MAAMH,QAAAA,CAAAA;IACpD;EACF,CAAA;CACD;",
6
+ "names": ["PREVIEW_PLUGIN", "meta", "id", "name", "icon", "source", "createIntent", "Capabilities", "contributes", "Events", "defineModule", "definePlugin", "LayoutAction", "addEventListener", "resolveRef", "parseId", "DXN", "log", "ClientCapabilities", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "dxn", "DXN", "parse", "object", "resolveRef", "PreviewPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activate", "context", "handleDxRefTagActivate", "trigger", "dispatchPromise", "dispatch", "requestCapability", "Capabilities", "IntentDispatcher", "ClientCapabilities", "Client", "layout", "requestCapabilities", "Layout", "spaceId", "parseId", "workspace", "space", "spaces", "get", "default", "result", "createIntent", "LayoutAction", "UpdatePopover", "part", "subject", "options", "state", "variant", "anchor", "document", "defaultView", "log", "warn", "cleanup", "addEventListener", "contributes", "Null"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/plugins/plugin-preview/src/meta.ts":{"bytes":1296,"imports":[],"format":"esm"},"packages/plugins/plugin-preview/src/PreviewPlugin.tsx":{"bytes":10087,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-preview/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-preview/src/index.ts":{"bytes":596,"imports":[{"path":"packages/plugins/plugin-preview/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-preview/src/PreviewPlugin.tsx","kind":"import-statement","original":"./PreviewPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-preview/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5717},"packages/plugins/plugin-preview/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true}],"exports":["PREVIEW_PLUGIN","PreviewPlugin","meta"],"entryPoint":"packages/plugins/plugin-preview/src/index.ts","inputs":{"packages/plugins/plugin-preview/src/meta.ts":{"bytesInOutput":216},"packages/plugins/plugin-preview/src/index.ts":{"bytesInOutput":0},"packages/plugins/plugin-preview/src/PreviewPlugin.tsx":{"bytesInOutput":2307}},"bytes":2810}}}
@@ -0,0 +1,2 @@
1
+ export declare const PreviewPlugin: () => import("@dxos/app-framework").Plugin;
2
+ //# sourceMappingURL=PreviewPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewPlugin.d.ts","sourceRoot":"","sources":["../../../src/PreviewPlugin.tsx"],"names":[],"mappings":"AAyCA,eAAO,MAAM,aAAa,4CA6CtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './meta';
2
+ export * from './PreviewPlugin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type PluginMeta } from '@dxos/app-framework';
2
+ export declare const PREVIEW_PLUGIN = "dxos.org/plugin/preview";
3
+ export declare const meta: PluginMeta;
4
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAExD,eAAO,MAAM,IAAI,EAAE,UAKlB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":"5.7.3"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@dxos/plugin-preview",
3
+ "version": "0.8.2-main.12df754",
4
+ "description": "Preview plugin",
5
+ "homepage": "https://dxos.org",
6
+ "bugs": "https://github.com/dxos/dxos/issues",
7
+ "license": "MIT",
8
+ "author": "DXOS.org",
9
+ "sideEffects": true,
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/src/index.d.ts",
14
+ "browser": "./dist/lib/browser/index.mjs"
15
+ }
16
+ },
17
+ "types": "dist/types/src/index.d.ts",
18
+ "typesVersions": {
19
+ "*": {}
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "dependencies": {
26
+ "@dxos/app-framework": "0.8.2-main.12df754",
27
+ "@dxos/client": "0.8.2-main.12df754",
28
+ "@dxos/async": "0.8.2-main.12df754",
29
+ "@dxos/keys": "0.8.2-main.12df754",
30
+ "@dxos/lit-ui": "0.8.2-main.12df754",
31
+ "@dxos/log": "0.8.2-main.12df754",
32
+ "@dxos/react-ui-editor": "0.8.2-main.12df754",
33
+ "@dxos/plugin-client": "0.8.2-main.12df754"
34
+ },
35
+ "devDependencies": {
36
+ "react": "~18.2.0",
37
+ "react-dom": "~18.2.0",
38
+ "vite": "5.4.7"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "~18.2.0",
42
+ "react-dom": "~18.2.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }
@@ -0,0 +1,87 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import {
6
+ createIntent,
7
+ Capabilities,
8
+ contributes,
9
+ Events,
10
+ defineModule,
11
+ definePlugin,
12
+ LayoutAction,
13
+ } from '@dxos/app-framework';
14
+ import { addEventListener } from '@dxos/async';
15
+ import { type Client } from '@dxos/client';
16
+ import { resolveRef } from '@dxos/client';
17
+ import { parseId, type Space } from '@dxos/client/echo';
18
+ import { DXN } from '@dxos/keys';
19
+ import { type DxRefTagActivate } from '@dxos/lit-ui';
20
+ import { log } from '@dxos/log';
21
+ import { ClientCapabilities } from '@dxos/plugin-client';
22
+ import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
23
+
24
+ import { meta } from './meta';
25
+
26
+ const customEventOptions = { capture: true, passive: false };
27
+
28
+ const handlePreviewLookup = async (
29
+ client: Client,
30
+ defaultSpace: Space,
31
+ { ref, label }: PreviewLinkRef,
32
+ ): Promise<PreviewLinkTarget | null> => {
33
+ const dxn = DXN.parse(ref);
34
+ if (!dxn) {
35
+ return null;
36
+ }
37
+
38
+ const object = await resolveRef(client, dxn, defaultSpace);
39
+ return { label, object };
40
+ };
41
+
42
+ export const PreviewPlugin = () =>
43
+ definePlugin(meta, [
44
+ defineModule({
45
+ id: `${meta.id}/module/preview-popoevr`,
46
+ activatesOn: Events.Startup,
47
+ activate: (context) => {
48
+ // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
49
+ const handleDxRefTagActivate = async ({ ref, label, trigger }: DxRefTagActivate) => {
50
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
51
+ const client = context.requestCapability(ClientCapabilities.Client);
52
+ const [layout] = context.requestCapabilities(Capabilities.Layout);
53
+ const { spaceId } = parseId(layout.workspace);
54
+ const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
55
+ const result = await handlePreviewLookup(client, space, { ref, label });
56
+ if (!result) {
57
+ return;
58
+ }
59
+
60
+ await dispatch(
61
+ createIntent(LayoutAction.UpdatePopover, {
62
+ part: 'popover',
63
+ subject: result.object,
64
+ options: {
65
+ state: true,
66
+ variant: 'virtual',
67
+ anchor: trigger,
68
+ },
69
+ }),
70
+ );
71
+ };
72
+
73
+ if (!document.defaultView) {
74
+ log.warn('No default view found');
75
+ return [];
76
+ }
77
+
78
+ const cleanup = addEventListener(
79
+ document.defaultView,
80
+ 'dx-ref-tag-activate',
81
+ handleDxRefTagActivate,
82
+ customEventOptions,
83
+ );
84
+ return contributes(Capabilities.Null, null, () => cleanup());
85
+ },
86
+ }),
87
+ ]);
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './meta';
6
+ export * from './PreviewPlugin';
package/src/meta.ts ADDED
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type PluginMeta } from '@dxos/app-framework';
6
+
7
+ export const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';
8
+
9
+ export const meta: PluginMeta = {
10
+ id: PREVIEW_PLUGIN,
11
+ name: 'Preview',
12
+ icon: 'ph--eye--regular',
13
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
14
+ };