@publisle/adapter-vue 0.0.0-stage → 0.1.1

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VoidReg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @publisle/adapter-vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Publisle Core package.
4
+
5
+ Requires Node.js 24 or later. Framework adapters also require their declared peer dependencies.
6
+ This package is part of Publisle, independently versioned at `0.1.1` and published under the npm `beta` tag.
7
+ Frozen contract version integers are independent of npm package versions.
8
+
9
+ - [Core standard](https://github.com/VoidReg/publisle/blob/main/docs/standards/README.md)
10
+ - [Quickstart and package usage](https://github.com/VoidReg/publisle#readme)
11
+ - [Distribution and release checklist](https://github.com/VoidReg/publisle/blob/main/docs/guides/releases.md)
12
+
13
+ Core packages do not install Research templates, citeproc, PDF compilers, or TeX.
@@ -0,0 +1,3 @@
1
+ import { type AdapterTarget } from "@publisle/adapter-core";
2
+ export declare const vueTarget: AdapterTarget;
3
+ //# sourceMappingURL=emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,eAAO,MAAM,SAAS,EAAE,aAqBvB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { javascriptValue as js, placementProgram, } from "@publisle/adapter-core";
2
+ export const vueTarget = {
3
+ name: "vue",
4
+ extension: "js",
5
+ emitModule(plan) {
6
+ const components = [];
7
+ const emit = (node) => {
8
+ if (node.kind === "text")
9
+ return js(node.value);
10
+ if (node.kind === "raw")
11
+ return `h("span",{innerHTML:${js(node.value)}})`;
12
+ if (node.kind === "component" || node.kind === "island") {
13
+ const index = components.push(node) - 1;
14
+ if (node.kind === "component")
15
+ return `h(Static${index},${js(node.props)})`;
16
+ return `h(PublisleIsland,{activation:${js(node.activation)},label:${js(node.label)},input:${js(node.props)},load:()=>import(${js(node.module)}),exportName:${js(node.exportName)}},{default:()=>[${node.fallback.map(emit).join(",")}]})`;
17
+ }
18
+ return `h(${js(node.tag)},publislePlace(${js(node.attributes)},placement),[${node.children.map(emit).join(",")}])`;
19
+ };
20
+ const body = plan.nodes.map(emit).join(",");
21
+ const placement = placementProgram(plan.nodes);
22
+ return `import {h,defineComponent,useId} from "vue";\n${components.some((node) => node.kind === "island") ? 'import {PublisleIsland} from "@publisle/adapter-vue/runtime";' : ""}\n${components.map((node, index) => (node.kind === "component" ? `import {${js(node.exportName)} as Static${index}} from ${js(node.module)};` : "")).join("\n")}\n${placement || "const publislePlace=(attributes)=>attributes;"}\nexport const metadata=${js(plan.metadata ?? null)};export const diagnostics=${js(plan.diagnostics)};export const document=${js(plan.document)};\nexport default defineComponent({props:{instanceId:String},setup(props){const id=useId();const placement=props.instanceId ?? ("publisle"+id.replace(/[^A-Za-z0-9_-]/g,"_"));return ()=>h("div",null,[${body}]);}});`;
23
+ },
24
+ };
25
+ //# sourceMappingURL=emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.js","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,IAAI,EAAE,EACrB,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAkB;IACtC,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,IAAI;IACf,UAAU,CAAC,IAAI;QACb,MAAM,UAAU,GACd,EAAE,CAAC;QACL,MAAM,IAAI,GAAG,CAAC,IAAgB,EAAU,EAAE;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;gBAAE,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK;gBAAE,OAAO,uBAAuB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAC1E,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACxC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;oBAC3B,OAAO,WAAW,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC/C,OAAO,gCAAgC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE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S,CAAC;IAC3vB,CAAC;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { PublisleViteOptions } from "@publisle/adapter-core";
2
+ export { vueTarget } from "./emitter.js";
3
+ export { PublisleArticle, PublisleIsland } from "./runtime.js";
4
+ export { createRenderPlan, compilePublication } from "@publisle/adapter-core";
5
+ export declare function publisleVue(options: Omit<PublisleViteOptions, "target">): Promise<import("vite").Plugin<any>>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,qBAAqB;AACzC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB;AAC/D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,wBAAgB,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,uCAKvE"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import { vueTarget } from "./emitter.js";
2
+ export { vueTarget } from "./emitter.js";
3
+ export { PublisleArticle, PublisleIsland } from "./runtime.js";
4
+ export { createRenderPlan, compilePublication } from "@publisle/adapter-core";
5
+ export function publisleVue(options) {
6
+ return import("@publisle/adapter-core/vite").then(({ createPublisleVitePlugin }) => createPublisleVitePlugin({ ...options, target: vueTarget }));
7
+ }
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,MAAM,UAAU,WAAW,CAAC,OAA4C;IACtE,OAAO,MAAM,CAAC,6BAA6B,CAAC,CAAC,IAAI,CAC/C,CAAC,EAAE,wBAAwB,EAAE,EAAE,EAAE,CAC/B,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { type PropType } from "vue";
2
+ import { type PublicationArtifact, type PublicationEnvironment } from "@publisle/adapter-core/publication-runtime";
3
+ export declare const PublisleArticle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ publication: {
5
+ type: PropType<PublicationArtifact>;
6
+ required: true;
7
+ };
8
+ instanceId: {
9
+ type: StringConstructor;
10
+ required: true;
11
+ };
12
+ implementations: {
13
+ type: PropType<PublicationEnvironment["implementations"]>;
14
+ default: undefined;
15
+ };
16
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
+ [key: string]: any;
18
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ publication: {
20
+ type: PropType<PublicationArtifact>;
21
+ required: true;
22
+ };
23
+ instanceId: {
24
+ type: StringConstructor;
25
+ required: true;
26
+ };
27
+ implementations: {
28
+ type: PropType<PublicationEnvironment["implementations"]>;
29
+ default: undefined;
30
+ };
31
+ }>> & Readonly<{}>, {
32
+ implementations: Readonly<Record<string, () => Promise<unknown>>> | undefined;
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
34
+ import type { Activation, JsonValue } from "@publisle/schema";
35
+ export declare const PublisleIsland: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
36
+ activation: {
37
+ type: PropType<Activation>;
38
+ required: true;
39
+ };
40
+ label: {
41
+ type: StringConstructor;
42
+ required: true;
43
+ };
44
+ input: {
45
+ type: PropType<JsonValue>;
46
+ required: true;
47
+ };
48
+ load: {
49
+ type: PropType<() => Promise<unknown>>;
50
+ required: true;
51
+ };
52
+ exportName: {
53
+ type: StringConstructor;
54
+ required: true;
55
+ };
56
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
57
+ [key: string]: any;
58
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
59
+ activation: {
60
+ type: PropType<Activation>;
61
+ required: true;
62
+ };
63
+ label: {
64
+ type: StringConstructor;
65
+ required: true;
66
+ };
67
+ input: {
68
+ type: PropType<JsonValue>;
69
+ required: true;
70
+ };
71
+ load: {
72
+ type: PropType<() => Promise<unknown>>;
73
+ required: true;
74
+ };
75
+ exportName: {
76
+ type: StringConstructor;
77
+ required: true;
78
+ };
79
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
80
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,QAAQ,EACd,MAAM,KAAK,CAAC;AACb,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAE5B,MAAM,4CAA4C,CAAC;AACpD,eAAO,MAAM,eAAe;;cAIN,QAAQ,CAAC,mBAAmB,CAAC;;;;;;;;cAK7B,QAAQ,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;;;;;;;cALnD,QAAQ,CAAC,mBAAmB,CAAC;;;;;;;;cAK7B,QAAQ,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;;;;;4EAuCvE,CAAC;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,eAAO,MAAM,cAAc;;cAGO,QAAQ,CAAC,UAAU,CAAC;;;;;;;;cAEzB,QAAQ,CAAC,SAAS,CAAC;;;;cAExB,QAAQ,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;;;;;;;;;cAJtB,QAAQ,CAAC,UAAU,CAAC;;;;;;;;cAEzB,QAAQ,CAAC,SAAS,CAAC;;;;cAExB,QAAQ,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;;;;;iGAwDtD,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { defineComponent, h, shallowRef, onMounted, onBeforeUnmount, watch, createApp, } from "vue";
2
+ import { attachPublication, instantiatePublication, } from "@publisle/adapter-core/publication-runtime";
3
+ export const PublisleArticle = defineComponent({
4
+ name: "PublisleArticle",
5
+ props: {
6
+ publication: {
7
+ type: Object,
8
+ required: true,
9
+ },
10
+ instanceId: { type: String, required: true },
11
+ implementations: {
12
+ type: Object,
13
+ default: undefined,
14
+ },
15
+ },
16
+ setup(props) {
17
+ const root = shallowRef();
18
+ let handle;
19
+ const attach = () => {
20
+ handle?.dispose();
21
+ if (!root.value)
22
+ return;
23
+ handle = attachPublication(root.value, props.publication, {
24
+ ...(props.implementations
25
+ ? { implementations: props.implementations }
26
+ : {}),
27
+ mount(module, target, input) {
28
+ const component = module.default;
29
+ const app = createApp(component, input);
30
+ app.mount(target);
31
+ return app;
32
+ },
33
+ unmount(instance) {
34
+ instance.unmount();
35
+ },
36
+ });
37
+ };
38
+ onMounted(attach);
39
+ watch(() => [props.publication, props.instanceId, props.implementations], attach, { flush: "post" });
40
+ onBeforeUnmount(() => handle?.dispose());
41
+ return () => h("div", {
42
+ ref: root,
43
+ innerHTML: instantiatePublication(props.publication, props.instanceId)
44
+ .html,
45
+ });
46
+ },
47
+ });
48
+ import { createIslandController } from "@publisle/adapter-core/island-runtime";
49
+ export const PublisleIsland = defineComponent({
50
+ name: "PublisleIsland",
51
+ props: {
52
+ activation: { type: String, required: true },
53
+ label: { type: String, required: true },
54
+ input: { type: Object, required: true },
55
+ load: {
56
+ type: Function,
57
+ required: true,
58
+ },
59
+ exportName: { type: String, required: true },
60
+ },
61
+ setup(props, { slots }) {
62
+ const scope = shallowRef();
63
+ const root = shallowRef();
64
+ const fallback = shallowRef();
65
+ let controller;
66
+ const attach = () => {
67
+ controller?.destroy();
68
+ if (!scope.value || !root.value || !fallback.value)
69
+ return;
70
+ controller = createIslandController({
71
+ scope: scope.value,
72
+ root: root.value,
73
+ fallback: fallback.value,
74
+ activation: props.activation,
75
+ props: props.input,
76
+ load: props.load,
77
+ mount(module, target, input) {
78
+ const component = module[props.exportName];
79
+ if (!component)
80
+ throw new Error(`Missing Vue island export ${props.exportName}`);
81
+ const app = createApp(component, input);
82
+ app.mount(target);
83
+ return app;
84
+ },
85
+ unmount(instance) {
86
+ instance.unmount();
87
+ },
88
+ });
89
+ };
90
+ onMounted(attach);
91
+ watch(() => [props.activation, props.input, props.load, props.exportName], attach, { flush: "post" });
92
+ onBeforeUnmount(() => controller?.destroy());
93
+ return () => h("div", { ref: scope, class: "publisle-island", "aria-label": props.label }, [
94
+ h("div", { ref: fallback, "data-publisle-fallback": true }, slots["default"]?.()),
95
+ h("div", { ref: root, hidden: true, "data-publisle-mount": true }),
96
+ ]);
97
+ },
98
+ });
99
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,UAAU,EACV,SAAS,EACT,eAAe,EACf,KAAK,EACL,SAAS,GAGV,MAAM,KAAK,CAAC;AACb,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAIvB,MAAM,4CAA4C,CAAC;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;IAC7C,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE;QACL,WAAW,EAAE;YACX,IAAI,EAAE,MAAuC;YAC7C,QAAQ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AAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC;SACnE,CACF,CAAC;IACN,CAAC;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@publisle/adapter-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./runtime": {
14
+ "types": "./dist/runtime.d.ts",
15
+ "import": "./dist/runtime.js",
16
+ "default": "./dist/runtime.js"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "@publisle/adapter-core": "^0.1.1",
21
+ "@publisle/core": "^0.1.1",
22
+ "@publisle/schema": "^0.1.0"
23
+ },
24
+ "peerDependencies": {
25
+ "vue": "^3.5.0",
26
+ "vite": "^8.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "vue": "^3.5.0",
30
+ "vite": "^8.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "src",
38
+ "README.md",
39
+ "NOTICE.md",
40
+ "LICENSE"
41
+ ],
42
+ "engines": {
43
+ "node": ">=24"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/VoidReg/publisle.git",
48
+ "directory": "packages/adapter-vue"
49
+ },
50
+ "homepage": "https://github.com/VoidReg/publisle#readme",
51
+ "types": "./dist/index.d.ts"
6
52
  }
package/src/emitter.ts ADDED
@@ -0,0 +1,28 @@
1
+ import {
2
+ javascriptValue as js,
3
+ placementProgram,
4
+ type AdapterTarget,
5
+ type RenderNode,
6
+ } from "@publisle/adapter-core";
7
+ export const vueTarget: AdapterTarget = {
8
+ name: "vue",
9
+ extension: "js",
10
+ emitModule(plan) {
11
+ const components: Extract<RenderNode, { kind: "component" | "island" }>[] =
12
+ [];
13
+ const emit = (node: RenderNode): string => {
14
+ if (node.kind === "text") return js(node.value);
15
+ if (node.kind === "raw") return `h("span",{innerHTML:${js(node.value)}})`;
16
+ if (node.kind === "component" || node.kind === "island") {
17
+ const index = components.push(node) - 1;
18
+ if (node.kind === "component")
19
+ return `h(Static${index},${js(node.props)})`;
20
+ return `h(PublisleIsland,{activation:${js(node.activation)},label:${js(node.label)},input:${js(node.props)},load:()=>import(${js(node.module)}),exportName:${js(node.exportName)}},{default:()=>[${node.fallback.map(emit).join(",")}]})`;
21
+ }
22
+ return `h(${js(node.tag)},publislePlace(${js(node.attributes)},placement),[${node.children.map(emit).join(",")}])`;
23
+ };
24
+ const body = plan.nodes.map(emit).join(",");
25
+ const placement = placementProgram(plan.nodes);
26
+ return `import {h,defineComponent,useId} from "vue";\n${components.some((node) => node.kind === "island") ? 'import {PublisleIsland} from "@publisle/adapter-vue/runtime";' : ""}\n${components.map((node, index) => (node.kind === "component" ? `import {${js(node.exportName)} as Static${index}} from ${js(node.module)};` : "")).join("\n")}\n${placement || "const publislePlace=(attributes)=>attributes;"}\nexport const metadata=${js(plan.metadata ?? null)};export const diagnostics=${js(plan.diagnostics)};export const document=${js(plan.document)};\nexport default defineComponent({props:{instanceId:String},setup(props){const id=useId();const placement=props.instanceId ?? ("publisle"+id.replace(/[^A-Za-z0-9_-]/g,"_"));return ()=>h("div",null,[${body}]);}});`;
27
+ },
28
+ };
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { PublisleViteOptions } from "@publisle/adapter-core";
2
+ import { vueTarget } from "./emitter.ts";
3
+ export { vueTarget } from "./emitter.ts";
4
+ export { PublisleArticle, PublisleIsland } from "./runtime.ts";
5
+ export { createRenderPlan, compilePublication } from "@publisle/adapter-core";
6
+ export function publisleVue(options: Omit<PublisleViteOptions, "target">) {
7
+ return import("@publisle/adapter-core/vite").then(
8
+ ({ createPublisleVitePlugin }) =>
9
+ createPublisleVitePlugin({ ...options, target: vueTarget }),
10
+ );
11
+ }
package/src/runtime.ts ADDED
@@ -0,0 +1,134 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ shallowRef,
5
+ onMounted,
6
+ onBeforeUnmount,
7
+ watch,
8
+ createApp,
9
+ type Component,
10
+ type PropType,
11
+ } from "vue";
12
+ import {
13
+ attachPublication,
14
+ instantiatePublication,
15
+ type PublicationArtifact,
16
+ type PublicationEnvironment,
17
+ type PublicationHandle,
18
+ } from "@publisle/adapter-core/publication-runtime";
19
+ export const PublisleArticle = defineComponent({
20
+ name: "PublisleArticle",
21
+ props: {
22
+ publication: {
23
+ type: Object as PropType<PublicationArtifact>,
24
+ required: true,
25
+ },
26
+ instanceId: { type: String, required: true },
27
+ implementations: {
28
+ type: Object as PropType<PublicationEnvironment["implementations"]>,
29
+ default: undefined,
30
+ },
31
+ },
32
+ setup(props) {
33
+ const root = shallowRef<HTMLElement>();
34
+ let handle: PublicationHandle | undefined;
35
+ const attach = () => {
36
+ handle?.dispose();
37
+ if (!root.value) return;
38
+ handle = attachPublication(root.value, props.publication, {
39
+ ...(props.implementations
40
+ ? { implementations: props.implementations }
41
+ : {}),
42
+ mount(module, target, input) {
43
+ const component = (module as { default: Component }).default;
44
+ const app = createApp(component, input as Record<string, unknown>);
45
+ app.mount(target);
46
+ return app;
47
+ },
48
+ unmount(instance) {
49
+ (instance as ReturnType<typeof createApp>).unmount();
50
+ },
51
+ });
52
+ };
53
+ onMounted(attach);
54
+ watch(
55
+ () => [props.publication, props.instanceId, props.implementations],
56
+ attach,
57
+ { flush: "post" },
58
+ );
59
+ onBeforeUnmount(() => handle?.dispose());
60
+ return () =>
61
+ h("div", {
62
+ ref: root,
63
+ innerHTML: instantiatePublication(props.publication, props.instanceId)
64
+ .html,
65
+ });
66
+ },
67
+ });
68
+
69
+ import { createIslandController } from "@publisle/adapter-core/island-runtime";
70
+ import type { Activation, JsonValue } from "@publisle/schema";
71
+ export const PublisleIsland = defineComponent({
72
+ name: "PublisleIsland",
73
+ props: {
74
+ activation: { type: String as PropType<Activation>, required: true },
75
+ label: { type: String, required: true },
76
+ input: { type: Object as PropType<JsonValue>, required: true },
77
+ load: {
78
+ type: Function as PropType<() => Promise<unknown>>,
79
+ required: true,
80
+ },
81
+ exportName: { type: String, required: true },
82
+ },
83
+ setup(props, { slots }) {
84
+ const scope = shallowRef<HTMLElement>();
85
+ const root = shallowRef<HTMLElement>();
86
+ const fallback = shallowRef<HTMLElement>();
87
+ let controller: ReturnType<typeof createIslandController> | undefined;
88
+ const attach = () => {
89
+ controller?.destroy();
90
+ if (!scope.value || !root.value || !fallback.value) return;
91
+ controller = createIslandController({
92
+ scope: scope.value,
93
+ root: root.value,
94
+ fallback: fallback.value,
95
+ activation: props.activation,
96
+ props: props.input,
97
+ load: props.load,
98
+ mount(module, target, input) {
99
+ const component = (module as Record<string, Component>)[
100
+ props.exportName
101
+ ];
102
+ if (!component)
103
+ throw new Error(`Missing Vue island export ${props.exportName}`);
104
+ const app = createApp(component, input as Record<string, unknown>);
105
+ app.mount(target);
106
+ return app;
107
+ },
108
+ unmount(instance) {
109
+ (instance as ReturnType<typeof createApp>).unmount();
110
+ },
111
+ });
112
+ };
113
+ onMounted(attach);
114
+ watch(
115
+ () => [props.activation, props.input, props.load, props.exportName],
116
+ attach,
117
+ { flush: "post" },
118
+ );
119
+ onBeforeUnmount(() => controller?.destroy());
120
+ return () =>
121
+ h(
122
+ "div",
123
+ { ref: scope, class: "publisle-island", "aria-label": props.label },
124
+ [
125
+ h(
126
+ "div",
127
+ { ref: fallback, "data-publisle-fallback": true },
128
+ slots["default"]?.(),
129
+ ),
130
+ h("div", { ref: root, hidden: true, "data-publisle-mount": true }),
131
+ ],
132
+ );
133
+ },
134
+ });