@zeus-js/output-vue-wrapper 0.1.0-beta.3 → 0.1.0-beta.5

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.
@@ -0,0 +1,114 @@
1
+ /**
2
+ * output-vue-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ let vue = require("vue");
11
+ //#region packages/web-c/output-vue-wrapper/src/runtime/defineContainer.ts
12
+ const EMPTY_PROP = Symbol();
13
+ const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
14
+ const UPDATE_MODEL_VALUE_EVENT = "update:modelValue";
15
+ const MODEL_VALUE = "modelValue";
16
+ function defineContainer(options) {
17
+ const { tagName, displayName, defineCustomElement, props: componentProps = [], events: emitProps = [], slots: slotNames = [], model, transformTag } = options;
18
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
19
+ const emits = [...emitProps];
20
+ const componentPropsMap = {};
21
+ for (const prop of componentProps) componentPropsMap[prop] = DEFAULT_EMPTY_PROP;
22
+ if (model) {
23
+ const updateEvent = getModelUpdateEvent(model.prop);
24
+ emits.push(updateEvent);
25
+ if (updateEvent !== UPDATE_MODEL_VALUE_EVENT) emits.push(UPDATE_MODEL_VALUE_EVENT);
26
+ componentPropsMap[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
27
+ }
28
+ return (0, vue.defineComponent)((propsValue, { attrs, slots: allSlots, emit }) => {
29
+ const containerRef = (0, vue.ref)();
30
+ const listeners = [];
31
+ (0, vue.onMounted)(() => {
32
+ const el = containerRef.value;
33
+ if (!el) return;
34
+ for (const eventName of emitProps) {
35
+ const listener = (event) => {
36
+ emit(eventName, event);
37
+ };
38
+ el.addEventListener(eventName, listener);
39
+ listeners.push({
40
+ eventName,
41
+ listener
42
+ });
43
+ }
44
+ });
45
+ (0, vue.onBeforeUnmount)(() => {
46
+ const el = containerRef.value;
47
+ if (!el) return;
48
+ for (const item of listeners) el.removeEventListener(item.eventName, item.listener);
49
+ listeners.length = 0;
50
+ });
51
+ const vModelDirective = { created: (el) => {
52
+ if (!model) return;
53
+ for (const eventName of toArray(model.event)) el.addEventListener(eventName, (event) => {
54
+ var _model$eventPath;
55
+ if (event.target.tagName !== el.tagName) return;
56
+ const value = readEventPath(event, (_model$eventPath = model.eventPath) !== null && _model$eventPath !== void 0 ? _model$eventPath : `target.${model.prop}`);
57
+ emit(getModelUpdateEvent(model.prop), value);
58
+ if (propsValue[MODEL_VALUE] !== EMPTY_PROP) emit(UPDATE_MODEL_VALUE_EVENT, value);
59
+ });
60
+ } };
61
+ return () => {
62
+ const propsToAdd = { ref: containerRef };
63
+ for (const key in propsValue) {
64
+ const value = propsValue[key];
65
+ if (value !== EMPTY_PROP) propsToAdd[key] = value;
66
+ }
67
+ for (const key in attrs) propsToAdd[key] = attrs[key];
68
+ if (model) {
69
+ const modelValue = propsValue[MODEL_VALUE];
70
+ const modelPropValue = propsValue[model.prop];
71
+ if (modelValue !== EMPTY_PROP) propsToAdd[model.prop] = modelValue;
72
+ else if (modelPropValue !== EMPTY_PROP) propsToAdd[model.prop] = modelPropValue;
73
+ }
74
+ const children = createChildren(allSlots, slotNames);
75
+ const node = (0, vue.h)(transformTag ? transformTag(tagName) : tagName, propsToAdd, children);
76
+ return model ? (0, vue.withDirectives)(node, [[vModelDirective]]) : node;
77
+ };
78
+ }, {
79
+ name: displayName !== null && displayName !== void 0 ? displayName : tagName,
80
+ props: componentPropsMap,
81
+ emits
82
+ });
83
+ }
84
+ function createChildren(slots, slotNames) {
85
+ const children = slots.default ? slots.default() : [];
86
+ for (const name of slotNames) {
87
+ const slot = slots[name];
88
+ if (!slot) continue;
89
+ for (const vnode of slot()) children.push(withSlot(name, vnode));
90
+ }
91
+ return children;
92
+ }
93
+ function withSlot(name, vnode) {
94
+ if (!vnode) return vnode;
95
+ if (typeof vnode === "string") return (0, vue.h)("span", {
96
+ slot: name,
97
+ style: "display: contents"
98
+ }, vnode);
99
+ return (0, vue.cloneVNode)(vnode, { slot: name });
100
+ }
101
+ function getModelUpdateEvent(prop) {
102
+ return `update:${prop}`;
103
+ }
104
+ function toArray(value) {
105
+ return Array.isArray(value) ? value : [value];
106
+ }
107
+ function readEventPath(event, path) {
108
+ return path.split(".").reduce((value, key) => {
109
+ if (value == null) return void 0;
110
+ return value[key];
111
+ }, event);
112
+ }
113
+ //#endregion
114
+ exports.defineContainer = defineContainer;
@@ -0,0 +1,26 @@
1
+ import * as vue from 'vue';
2
+
3
+ export interface ZeusVueModelOptions {
4
+ prop: string;
5
+ event: string | string[];
6
+ eventPath?: string;
7
+ }
8
+ export interface ZeusVueContainerOptions {
9
+ tagName: string;
10
+ displayName?: string;
11
+ defineCustomElement?: () => void;
12
+ props?: string[];
13
+ events?: string[];
14
+ slots?: string[];
15
+ model?: ZeusVueModelOptions;
16
+ transformTag?: (tagName: string) => string;
17
+ }
18
+ export declare function defineContainer(options: ZeusVueContainerOptions): vue.DefineSetupFnComponent<{
19
+ [x: string]: /*elided*/ any;
20
+ }, string[], {}, {
21
+ [x: string]: /*elided*/ any;
22
+ } & {
23
+ [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
24
+ }, vue.PublicProps>;
25
+
26
+
@@ -0,0 +1,110 @@
1
+ /**
2
+ * output-vue-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { cloneVNode, defineComponent, h, onBeforeUnmount, onMounted, ref, withDirectives } from "vue";
7
+ //#region packages/web-c/output-vue-wrapper/src/runtime/defineContainer.ts
8
+ const EMPTY_PROP = Symbol();
9
+ const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
10
+ const UPDATE_MODEL_VALUE_EVENT = "update:modelValue";
11
+ const MODEL_VALUE = "modelValue";
12
+ function defineContainer(options) {
13
+ const { tagName, displayName, defineCustomElement, props: componentProps = [], events: emitProps = [], slots: slotNames = [], model, transformTag } = options;
14
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
15
+ const emits = [...emitProps];
16
+ const componentPropsMap = {};
17
+ for (const prop of componentProps) componentPropsMap[prop] = DEFAULT_EMPTY_PROP;
18
+ if (model) {
19
+ const updateEvent = getModelUpdateEvent(model.prop);
20
+ emits.push(updateEvent);
21
+ if (updateEvent !== UPDATE_MODEL_VALUE_EVENT) emits.push(UPDATE_MODEL_VALUE_EVENT);
22
+ componentPropsMap[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
23
+ }
24
+ return defineComponent((propsValue, { attrs, slots: allSlots, emit }) => {
25
+ const containerRef = ref();
26
+ const listeners = [];
27
+ onMounted(() => {
28
+ const el = containerRef.value;
29
+ if (!el) return;
30
+ for (const eventName of emitProps) {
31
+ const listener = (event) => {
32
+ emit(eventName, event);
33
+ };
34
+ el.addEventListener(eventName, listener);
35
+ listeners.push({
36
+ eventName,
37
+ listener
38
+ });
39
+ }
40
+ });
41
+ onBeforeUnmount(() => {
42
+ const el = containerRef.value;
43
+ if (!el) return;
44
+ for (const item of listeners) el.removeEventListener(item.eventName, item.listener);
45
+ listeners.length = 0;
46
+ });
47
+ const vModelDirective = { created: (el) => {
48
+ if (!model) return;
49
+ for (const eventName of toArray(model.event)) el.addEventListener(eventName, (event) => {
50
+ var _model$eventPath;
51
+ if (event.target.tagName !== el.tagName) return;
52
+ const value = readEventPath(event, (_model$eventPath = model.eventPath) !== null && _model$eventPath !== void 0 ? _model$eventPath : `target.${model.prop}`);
53
+ emit(getModelUpdateEvent(model.prop), value);
54
+ if (propsValue[MODEL_VALUE] !== EMPTY_PROP) emit(UPDATE_MODEL_VALUE_EVENT, value);
55
+ });
56
+ } };
57
+ return () => {
58
+ const propsToAdd = { ref: containerRef };
59
+ for (const key in propsValue) {
60
+ const value = propsValue[key];
61
+ if (value !== EMPTY_PROP) propsToAdd[key] = value;
62
+ }
63
+ for (const key in attrs) propsToAdd[key] = attrs[key];
64
+ if (model) {
65
+ const modelValue = propsValue[MODEL_VALUE];
66
+ const modelPropValue = propsValue[model.prop];
67
+ if (modelValue !== EMPTY_PROP) propsToAdd[model.prop] = modelValue;
68
+ else if (modelPropValue !== EMPTY_PROP) propsToAdd[model.prop] = modelPropValue;
69
+ }
70
+ const children = createChildren(allSlots, slotNames);
71
+ const node = h(transformTag ? transformTag(tagName) : tagName, propsToAdd, children);
72
+ return model ? withDirectives(node, [[vModelDirective]]) : node;
73
+ };
74
+ }, {
75
+ name: displayName !== null && displayName !== void 0 ? displayName : tagName,
76
+ props: componentPropsMap,
77
+ emits
78
+ });
79
+ }
80
+ function createChildren(slots, slotNames) {
81
+ const children = slots.default ? slots.default() : [];
82
+ for (const name of slotNames) {
83
+ const slot = slots[name];
84
+ if (!slot) continue;
85
+ for (const vnode of slot()) children.push(withSlot(name, vnode));
86
+ }
87
+ return children;
88
+ }
89
+ function withSlot(name, vnode) {
90
+ if (!vnode) return vnode;
91
+ if (typeof vnode === "string") return h("span", {
92
+ slot: name,
93
+ style: "display: contents"
94
+ }, vnode);
95
+ return cloneVNode(vnode, { slot: name });
96
+ }
97
+ function getModelUpdateEvent(prop) {
98
+ return `update:${prop}`;
99
+ }
100
+ function toArray(value) {
101
+ return Array.isArray(value) ? value : [value];
102
+ }
103
+ function readEventPath(event, path) {
104
+ return path.split(".").reduce((value, key) => {
105
+ if (value == null) return void 0;
106
+ return value[key];
107
+ }, event);
108
+ }
109
+ //#endregion
110
+ export { defineContainer };
@@ -0,0 +1,110 @@
1
+ /**
2
+ * output-vue-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { cloneVNode, defineComponent, h, onBeforeUnmount, onMounted, ref, withDirectives } from "vue";
7
+ //#region packages/web-c/output-vue-wrapper/src/runtime/defineContainer.ts
8
+ const EMPTY_PROP = Symbol();
9
+ const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
10
+ const UPDATE_MODEL_VALUE_EVENT = "update:modelValue";
11
+ const MODEL_VALUE = "modelValue";
12
+ function defineContainer(options) {
13
+ const { tagName, displayName, defineCustomElement, props: componentProps = [], events: emitProps = [], slots: slotNames = [], model, transformTag } = options;
14
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
15
+ const emits = [...emitProps];
16
+ const componentPropsMap = {};
17
+ for (const prop of componentProps) componentPropsMap[prop] = DEFAULT_EMPTY_PROP;
18
+ if (model) {
19
+ const updateEvent = getModelUpdateEvent(model.prop);
20
+ emits.push(updateEvent);
21
+ if (updateEvent !== UPDATE_MODEL_VALUE_EVENT) emits.push(UPDATE_MODEL_VALUE_EVENT);
22
+ componentPropsMap[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
23
+ }
24
+ return defineComponent((propsValue, { attrs, slots: allSlots, emit }) => {
25
+ const containerRef = ref();
26
+ const listeners = [];
27
+ onMounted(() => {
28
+ const el = containerRef.value;
29
+ if (!el) return;
30
+ for (const eventName of emitProps) {
31
+ const listener = (event) => {
32
+ emit(eventName, event);
33
+ };
34
+ el.addEventListener(eventName, listener);
35
+ listeners.push({
36
+ eventName,
37
+ listener
38
+ });
39
+ }
40
+ });
41
+ onBeforeUnmount(() => {
42
+ const el = containerRef.value;
43
+ if (!el) return;
44
+ for (const item of listeners) el.removeEventListener(item.eventName, item.listener);
45
+ listeners.length = 0;
46
+ });
47
+ const vModelDirective = { created: (el) => {
48
+ if (!model) return;
49
+ for (const eventName of toArray(model.event)) el.addEventListener(eventName, (event) => {
50
+ var _model$eventPath;
51
+ if (event.target.tagName !== el.tagName) return;
52
+ const value = readEventPath(event, (_model$eventPath = model.eventPath) !== null && _model$eventPath !== void 0 ? _model$eventPath : `target.${model.prop}`);
53
+ emit(getModelUpdateEvent(model.prop), value);
54
+ if (propsValue[MODEL_VALUE] !== EMPTY_PROP) emit(UPDATE_MODEL_VALUE_EVENT, value);
55
+ });
56
+ } };
57
+ return () => {
58
+ const propsToAdd = { ref: containerRef };
59
+ for (const key in propsValue) {
60
+ const value = propsValue[key];
61
+ if (value !== EMPTY_PROP) propsToAdd[key] = value;
62
+ }
63
+ for (const key in attrs) propsToAdd[key] = attrs[key];
64
+ if (model) {
65
+ const modelValue = propsValue[MODEL_VALUE];
66
+ const modelPropValue = propsValue[model.prop];
67
+ if (modelValue !== EMPTY_PROP) propsToAdd[model.prop] = modelValue;
68
+ else if (modelPropValue !== EMPTY_PROP) propsToAdd[model.prop] = modelPropValue;
69
+ }
70
+ const children = createChildren(allSlots, slotNames);
71
+ const node = h(transformTag ? transformTag(tagName) : tagName, propsToAdd, children);
72
+ return model ? withDirectives(node, [[vModelDirective]]) : node;
73
+ };
74
+ }, {
75
+ name: displayName !== null && displayName !== void 0 ? displayName : tagName,
76
+ props: componentPropsMap,
77
+ emits
78
+ });
79
+ }
80
+ function createChildren(slots, slotNames) {
81
+ const children = slots.default ? slots.default() : [];
82
+ for (const name of slotNames) {
83
+ const slot = slots[name];
84
+ if (!slot) continue;
85
+ for (const vnode of slot()) children.push(withSlot(name, vnode));
86
+ }
87
+ return children;
88
+ }
89
+ function withSlot(name, vnode) {
90
+ if (!vnode) return vnode;
91
+ if (typeof vnode === "string") return h("span", {
92
+ slot: name,
93
+ style: "display: contents"
94
+ }, vnode);
95
+ return cloneVNode(vnode, { slot: name });
96
+ }
97
+ function getModelUpdateEvent(prop) {
98
+ return `update:${prop}`;
99
+ }
100
+ function toArray(value) {
101
+ return Array.isArray(value) ? value : [value];
102
+ }
103
+ function readEventPath(event, path) {
104
+ return path.split(".").reduce((value, key) => {
105
+ if (value == null) return void 0;
106
+ return value[key];
107
+ }, event);
108
+ }
109
+ //#endregion
110
+ export { defineContainer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeus-js/output-vue-wrapper",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "Zeus Vue wrapper output plugin",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -21,6 +21,11 @@
21
21
  "development": "./dist/output-vue-wrapper.cjs.js",
22
22
  "default": "./index.js"
23
23
  }
24
+ },
25
+ "./runtime": {
26
+ "types": "./dist/runtime/index.d.ts",
27
+ "import": "./dist/runtime/index.js",
28
+ "require": "./dist/runtime/index.cjs.js"
24
29
  }
25
30
  },
26
31
  "sideEffects": false,
@@ -33,12 +38,18 @@
33
38
  "formats": [
34
39
  "esm-bundler",
35
40
  "cjs"
41
+ ],
42
+ "additionalEntries": [
43
+ {
44
+ "entry": "runtime/index.ts",
45
+ "output": "dist/runtime/index.js"
46
+ }
36
47
  ]
37
48
  },
38
49
  "dependencies": {
39
- "@zeus-js/bundler-plugin": "0.1.0-beta.3",
40
- "@zeus-js/component-dts": "0.1.0-beta.3",
41
- "@zeus-js/component-analyzer": "0.1.0-beta.3"
50
+ "@zeus-js/bundler-plugin": "0.1.0-beta.5",
51
+ "@zeus-js/component-dts": "0.1.0-beta.5",
52
+ "@zeus-js/component-analyzer": "0.1.0-beta.5"
42
53
  },
43
54
  "peerDependencies": {
44
55
  "vue": ">=3"