vfit 0.1.2 → 0.1.3

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.
@@ -1,64 +1,84 @@
1
1
  import { defineComponent, reactive, inject, ref, watch, createElementBlock, openBlock, normalizeStyle, normalizeClass, renderSlot } from "vue";
2
- function observeScale(target, designHeight, onScale) {
3
- const observer = new ResizeObserver((entries) => {
4
- for (const entry of entries) {
5
- const rectHeight = entry.contentRect.height;
6
- const rectWidth = entry.contentRect.width;
7
- let scaleVal;
8
- if (rectWidth / rectHeight < 1.7666666666666666) {
9
- scaleVal = rectWidth / 1920 * 0.98;
10
- } else {
11
- scaleVal = rectHeight / designHeight;
12
- }
13
- onScale(scaleVal);
2
+ function _0x5b39(_0x3715b5, _0x2e4c8d) {
3
+ const _0x5e3a5 = _0x5e3a();
4
+ return _0x5b39 = function(_0x5b394e, _0x4459f1) {
5
+ _0x5b394e = _0x5b394e - 187;
6
+ let _0x43f33a = _0x5e3a5[_0x5b394e];
7
+ return _0x43f33a;
8
+ }, _0x5b39(_0x3715b5, _0x2e4c8d);
9
+ }
10
+ (function(_0x4d0763, _0x217f6f) {
11
+ const _0x4ff46b = _0x5b39, _0x396afb = _0x4d0763();
12
+ while (!![]) {
13
+ try {
14
+ const _0x3a94a0 = parseInt(_0x4ff46b(193)) / 1 + parseInt(_0x4ff46b(189)) / 2 * (parseInt(_0x4ff46b(192)) / 3) + parseInt(_0x4ff46b(199)) / 4 * (-parseInt(_0x4ff46b(198)) / 5) + -parseInt(_0x4ff46b(195)) / 6 * (-parseInt(_0x4ff46b(200)) / 7) + -parseInt(_0x4ff46b(196)) / 8 * (parseInt(_0x4ff46b(197)) / 9) + parseInt(_0x4ff46b(188)) / 10 * (-parseInt(_0x4ff46b(191)) / 11) + parseInt(_0x4ff46b(194)) / 12;
15
+ if (_0x3a94a0 === _0x217f6f) break;
16
+ else _0x396afb["push"](_0x396afb["shift"]());
17
+ } catch (_0x557b6c) {
18
+ _0x396afb["push"](_0x396afb["shift"]());
19
+ }
20
+ }
21
+ })(_0x5e3a, 653108);
22
+ function observeScale(_0x47f0dd, _0x319e73, _0x1b6eac) {
23
+ const _0x546310 = new ResizeObserver((_0x9a2e4f) => {
24
+ const _0x35b442 = _0x5b39;
25
+ for (const _0x4bf30e of _0x9a2e4f) {
26
+ const _0x322e1f = _0x4bf30e[_0x35b442(187)][_0x35b442(190)], _0x10af9e = _0x4bf30e[_0x35b442(187)]["width"];
27
+ let _0x2780a2;
28
+ _0x10af9e / _0x322e1f < 1.7666666666666666 ? _0x2780a2 = _0x10af9e / 1920 * 0.98 : _0x2780a2 = _0x322e1f / _0x319e73, _0x1b6eac(_0x2780a2);
14
29
  }
15
30
  });
16
- observer.observe(target);
17
- return observer;
31
+ return _0x546310["observe"](_0x47f0dd), _0x546310;
18
32
  }
19
- const _sfc_main = /* @__PURE__ */ defineComponent({
20
- __name: "FitContainer",
21
- props: {
22
- scale: { type: Number, default: 0 },
23
- top: { type: Number },
24
- bottom: { type: Number },
25
- left: { type: Number },
26
- right: { type: Number },
27
- unit: { type: String, default: "px" }
28
- },
29
- setup(__props) {
30
- const position = reactive({
31
- scale: `scale(1)`,
32
- top: "auto",
33
- bottom: "auto",
34
- left: "auto",
35
- right: "auto"
36
- });
37
- const props = __props;
38
- const fitScale = inject(FitScaleKey, ref(1));
39
- watch([() => props.scale, fitScale], () => {
40
- const s = props.scale && props.scale > 0 ? props.scale : (fitScale == null ? void 0 : fitScale.value) ?? 1;
41
- position.scale = `scale(${s})`;
42
- const styleKey = ["top", "bottom", "left", "right"];
43
- styleKey.forEach((key) => {
44
- const val = props[key];
45
- if (props.unit === "%") {
46
- position[key] = val == void 0 ? "auto" : `${val}${props.unit}`;
47
- } else {
48
- position[key] = val == void 0 ? "auto" : `${val * s}${props.unit}`;
49
- }
50
- });
51
- }, { immediate: true });
52
- return (_ctx, _cache) => {
53
- return openBlock(), createElementBlock("div", {
54
- class: normalizeClass(["fit-container", { "fit-container-right": props.right !== void 0 }]),
55
- style: normalizeStyle({ transform: position.scale, top: position.top, bottom: position.bottom, left: position.left, right: position.right })
56
- }, [
57
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
58
- ], 6);
59
- };
33
+ function _0x5e3a() {
34
+ const _0x2496c4 = ["height", "6360915jgmmHX", "39oTIYPi", "2614wKzJKD", "9664764UuFarW", "78baZmcJ", "2444240fjGScu", "36FHZamq", "5TAXYRD", "439788uhDQcL", "455014cFiuQc", "contentRect", "10ImcMkP", "140062BisBzb"];
35
+ _0x5e3a = function() {
36
+ return _0x2496c4;
37
+ };
38
+ return _0x5e3a();
39
+ }
40
+ (function(_0x4e7396, _0x3feedf) {
41
+ const _0x42fcc8 = _0x3700, _0x56ae42 = _0x4e7396();
42
+ while (!![]) {
43
+ try {
44
+ const _0x1e29d4 = parseInt(_0x42fcc8(315)) / 1 + parseInt(_0x42fcc8(314)) / 2 + -parseInt(_0x42fcc8(324)) / 3 * (-parseInt(_0x42fcc8(322)) / 4) + -parseInt(_0x42fcc8(326)) / 5 + parseInt(_0x42fcc8(325)) / 6 + parseInt(_0x42fcc8(318)) / 7 + -parseInt(_0x42fcc8(320)) / 8;
45
+ if (_0x1e29d4 === _0x3feedf) break;
46
+ else _0x56ae42["push"](_0x56ae42["shift"]());
47
+ } catch (_0x29777b) {
48
+ _0x56ae42["push"](_0x56ae42["shift"]());
49
+ }
60
50
  }
61
- });
51
+ })(_0xda13, 521578);
52
+ function _0x3700(_0x4ccf37, _0x32cead) {
53
+ const _0xda13ca = _0xda13();
54
+ return _0x3700 = function(_0x3700e0, _0xc30946) {
55
+ _0x3700e0 = _0x3700e0 - 308;
56
+ let _0x516097 = _0xda13ca[_0x3700e0];
57
+ return _0x516097;
58
+ }, _0x3700(_0x4ccf37, _0x32cead);
59
+ }
60
+ function _0xda13() {
61
+ const _0xfc6c74 = ["auto", "scale(1)", "div", "scale", "left", "unit", "scale(", "663644JGVBnw", "756593rToWWV", "default", "top", "6062693DerMNQ", "forEach", "15258080dmMyDO", "right", "3592iuPECl", "bottom", "1749PUsjdg", "3400062kbRaDz", "3079435NAAHxG"];
62
+ _0xda13 = function() {
63
+ return _0xfc6c74;
64
+ };
65
+ return _0xda13();
66
+ }
67
+ const _sfc_main = defineComponent({ "__name": "FitContainer", "props": { "scale": { "type": Number, "default": 0 }, "top": { "type": Number }, "bottom": { "type": Number }, "left": { "type": Number }, "right": { "type": Number }, "unit": { "type": String, "default": "px" } }, "setup"(_0x13ac5f) {
68
+ const _0x156e9b = _0x3700, _0x46dff0 = reactive({ "scale": _0x156e9b(308), "top": _0x156e9b(327), "bottom": _0x156e9b(327), "left": _0x156e9b(327), "right": _0x156e9b(327) }), _0x32030a = _0x13ac5f, _0x35cc12 = inject(FitScaleKey, ref(1));
69
+ return watch([() => _0x32030a[_0x156e9b(310)], _0x35cc12], () => {
70
+ const _0x42ae48 = _0x156e9b, _0xa4ef78 = _0x32030a[_0x42ae48(310)] && _0x32030a["scale"] > 0 ? _0x32030a[_0x42ae48(310)] : (_0x35cc12 == null ? void 0 : _0x35cc12["value"]) ?? 1;
71
+ _0x46dff0[_0x42ae48(310)] = _0x42ae48(313) + _0xa4ef78 + ")";
72
+ const _0x22d343 = [_0x42ae48(317), _0x42ae48(323), _0x42ae48(311), "right"];
73
+ _0x22d343[_0x42ae48(319)]((_0x17de75) => {
74
+ const _0x5cceb8 = _0x42ae48, _0x35e2e0 = _0x32030a[_0x17de75];
75
+ _0x32030a[_0x5cceb8(312)] === "%" ? _0x46dff0[_0x17de75] = _0x35e2e0 == void 0 ? _0x5cceb8(327) : "" + _0x35e2e0 + _0x32030a["unit"] : _0x46dff0[_0x17de75] = _0x35e2e0 == void 0 ? "auto" : "" + _0x35e2e0 * _0xa4ef78 + _0x32030a["unit"];
76
+ });
77
+ }, { "immediate": !![] }), (_0x3c1779, _0x5f23ac) => {
78
+ const _0xfdc63e = _0x156e9b;
79
+ return openBlock(), createElementBlock(_0xfdc63e(309), { "class": normalizeClass(["fit-container", { "fit-container-right": _0x32030a[_0xfdc63e(321)] !== void 0 }]), "style": normalizeStyle({ "transform": _0x46dff0[_0xfdc63e(310)], "top": _0x46dff0["top"], "bottom": _0x46dff0[_0xfdc63e(323)], "left": _0x46dff0[_0xfdc63e(311)], "right": _0x46dff0[_0xfdc63e(321)] }) }, [renderSlot(_0x3c1779["$slots"], _0xfdc63e(316), {}, void 0, !![])], 6);
80
+ };
81
+ } });
62
82
  const _export_sfc = (sfc, props) => {
63
83
  const target = sfc.__vccOpts || sfc;
64
84
  for (const [key, val] of props) {
@@ -66,29 +86,52 @@ const _export_sfc = (sfc, props) => {
66
86
  }
67
87
  return target;
68
88
  };
69
- const FitContainer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1ab0024a"]]);
70
- const FitScaleKey = Symbol("FitScale");
71
- function createFitScale(options = {}) {
72
- const fitScale = ref(1);
73
- return {
74
- install(app) {
75
- const rootEl = typeof options.target === "string" ? document.querySelector(options.target) : options.target;
76
- const target = rootEl || document.querySelector("#app");
77
- observeScale(target, options.designHeight ?? 1080, (v) => {
78
- fitScale.value = v;
79
- });
80
- app.provide(FitScaleKey, fitScale);
81
- app.config.globalProperties.$fitScale = fitScale;
82
- app.component("FitContainer", FitContainer);
89
+ const _0x12e950 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1ab0024a"]]);
90
+ const _0x4fe986 = _0x1654;
91
+ (function(_0x517ebe, _0x1bfeff) {
92
+ const _0x424e87 = _0x1654, _0x418173 = _0x517ebe();
93
+ while (!![]) {
94
+ try {
95
+ const _0x5cf584 = -parseInt(_0x424e87(184)) / 1 * (parseInt(_0x424e87(180)) / 2) + -parseInt(_0x424e87(175)) / 3 * (parseInt(_0x424e87(172)) / 4) + parseInt(_0x424e87(167)) / 5 + parseInt(_0x424e87(166)) / 6 * (-parseInt(_0x424e87(183)) / 7) + parseInt(_0x424e87(170)) / 8 + parseInt(_0x424e87(186)) / 9 * (-parseInt(_0x424e87(182)) / 10) + parseInt(_0x424e87(169)) / 11;
96
+ if (_0x5cf584 === _0x1bfeff) break;
97
+ else _0x418173["push"](_0x418173["shift"]());
98
+ } catch (_0x321aa4) {
99
+ _0x418173["push"](_0x418173["shift"]());
83
100
  }
84
- };
101
+ }
102
+ })(_0x513e, 674638);
103
+ const FitScaleKey = Symbol(_0x4fe986(189));
104
+ function _0x1654(_0x103f76, _0x500394) {
105
+ const _0x513e78 = _0x513e();
106
+ return _0x1654 = function(_0x165485, _0x595dcc) {
107
+ _0x165485 = _0x165485 - 166;
108
+ let _0x4c826e = _0x513e78[_0x165485];
109
+ return _0x4c826e;
110
+ }, _0x1654(_0x103f76, _0x500394);
111
+ }
112
+ function createFitScale(_0x500c9d = {}) {
113
+ const _0x5d8b1f = ref(1);
114
+ return { "install"(_0x31a6a0) {
115
+ const _0x5c10fa = _0x1654, _0xcd811f = typeof _0x500c9d["target"] === _0x5c10fa(177) ? document[_0x5c10fa(176)](_0x500c9d["target"]) : _0x500c9d[_0x5c10fa(178)], _0x4dd71f = _0xcd811f || document["querySelector"](_0x5c10fa(171));
116
+ observeScale(_0x4dd71f, _0x500c9d[_0x5c10fa(179)] ?? 1080, (_0x49c801) => {
117
+ const _0x48cc90 = _0x5c10fa;
118
+ _0x5d8b1f[_0x48cc90(168)] = _0x49c801;
119
+ }), _0x31a6a0[_0x5c10fa(174)](FitScaleKey, _0x5d8b1f), _0x31a6a0[_0x5c10fa(187)][_0x5c10fa(181)][_0x5c10fa(185)] = _0x5d8b1f, _0x31a6a0[_0x5c10fa(173)](_0x5c10fa(188), _0x12e950);
120
+ } };
85
121
  }
86
122
  function useFitScale() {
87
- const injectedFitScale = inject(FitScaleKey, ref(1));
88
- return injectedFitScale;
123
+ const _0x5c73c1 = inject(FitScaleKey, ref(1));
124
+ return _0x5c73c1;
125
+ }
126
+ function _0x513e() {
127
+ const _0xfca304 = ["822680xuEkaQ", "value", "32379204QoromE", "7181016gmKVpU", "#app", "4THCEmZ", "component", "provide", "3909849nBeJTi", "querySelector", "string", "target", "designHeight", "2042230sCwFca", "globalProperties", "620cwxmbL", "63nHsAlL", "1YQrvew", "$fitScale", "114651vCQbaR", "config", "FitContainer", "FitScale", "144582CxRYQn"];
128
+ _0x513e = function() {
129
+ return _0xfca304;
130
+ };
131
+ return _0x513e();
89
132
  }
90
133
  export {
91
- FitContainer,
134
+ _0x12e950 as FitContainer,
92
135
  FitScaleKey,
93
136
  createFitScale,
94
137
  useFitScale
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FitScale={},e.Vue)}(this,function(e,t){"use strict";const o=(e=>{const t=e.__vccOpts||e;for(const[o,n]of[["__scopeId","data-v-1ab0024a"]])t[o]=n;return t})(t.defineComponent({__name:"FitContainer",props:{scale:{type:Number,default:0},top:{type:Number},bottom:{type:Number},left:{type:Number},right:{type:Number},unit:{type:String,default:"px"}},setup(e){const o=t.reactive({scale:"scale(1)",top:"auto",bottom:"auto",left:"auto",right:"auto"}),i=e,r=t.inject(n,t.ref(1));return t.watch([()=>i.scale,r],()=>{const e=i.scale&&i.scale>0?i.scale:(null==r?void 0:r.value)??1;o.scale=`scale(${e})`,["top","bottom","left","right"].forEach(t=>{const n=i[t];"%"===i.unit?o[t]=null==n?"auto":`${n}${i.unit}`:o[t]=null==n?"auto":`${n*e}${i.unit}`})},{immediate:!0}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["fit-container",{"fit-container-right":void 0!==i.right}]),style:t.normalizeStyle({transform:o.scale,top:o.top,bottom:o.bottom,left:o.left,right:o.right})},[t.renderSlot(e.$slots,"default",{},void 0,!0)],6))}})),n=Symbol("FitScale");e.FitContainer=o,e.FitScaleKey=n,e.createFitScale=function(e={}){const i=t.ref(1);return{install(t){var r,a,l;r=("string"==typeof e.target?document.querySelector(e.target):e.target)||document.querySelector("#app"),a=e.designHeight??1080,l=e=>{i.value=e},new ResizeObserver(e=>{for(const t of e){const e=t.contentRect.height,o=t.contentRect.width;let n;n=o/e<1.7666666666666666?o/1920*.98:e/a,l(n)}}).observe(r),t.provide(n,i),t.config.globalProperties.$fitScale=i,t.component("FitContainer",o)}}},e.useFitScale=function(){return t.inject(n,t.ref(1))},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FitScale={},t.Vue)}(this,function(t,e){"use strict";function n(t,e){const o=r();return(n=function(t,e){return o[t-=187]})(t,e)}function r(){const t=["height","6360915jgmmHX","39oTIYPi","2614wKzJKD","9664764UuFarW","78baZmcJ","2444240fjGScu","36FHZamq","5TAXYRD","439788uhDQcL","455014cFiuQc","contentRect","10ImcMkP","140062BisBzb"];return(r=function(){return t})()}function o(t,e){const n=s();return(o=function(t,e){return n[t-=308]})(t,e)}function s(){const t=["auto","scale(1)","div","scale","left","unit","scale(","663644JGVBnw","756593rToWWV","default","top","6062693DerMNQ","forEach","15258080dmMyDO","right","3592iuPECl","bottom","1749PUsjdg","3400062kbRaDz","3079435NAAHxG"];return(s=function(){return t})()}!function(t){const e=n,r=t();for(;;)try{if(653108==parseInt(e(193))/1+parseInt(e(189))/2*(parseInt(e(192))/3)+parseInt(e(199))/4*(-parseInt(e(198))/5)+-parseInt(e(195))/6*(-parseInt(e(200))/7)+-parseInt(e(196))/8*(parseInt(e(197))/9)+parseInt(e(188))/10*(-parseInt(e(191))/11)+parseInt(e(194))/12)break;r.push(r.shift())}catch(o){r.push(r.shift())}}(r),function(t){const e=o,n=t();for(;;)try{if(521578==parseInt(e(315))/1+parseInt(e(314))/2+-parseInt(e(324))/3*(-parseInt(e(322))/4)+-parseInt(e(326))/5+parseInt(e(325))/6+parseInt(e(318))/7+-parseInt(e(320))/8)break;n.push(n.shift())}catch(r){n.push(n.shift())}}(s);const a=(t=>{const e=t.__vccOpts||t;for(const[n,r]of[["__scopeId","data-v-1ab0024a"]])e[n]=r;return e})(e.defineComponent({__name:"FitContainer",props:{scale:{type:Number,default:0},top:{type:Number},bottom:{type:Number},left:{type:Number},right:{type:Number},unit:{type:String,default:"px"}},setup(t){const n=o,r=e.reactive({scale:n(308),top:n(327),bottom:n(327),left:n(327),right:n(327)}),s=t,a=e.inject(c,e.ref(1));return e.watch([()=>s[n(310)],a],()=>{const t=n,e=s[t(310)]&&s.scale>0?s[t(310)]:(null==a?void 0:a.value)??1;r[t(310)]=t(313)+e+")",[t(317),t(323),t(311),"right"][t(319)](n=>{const o=t,a=s[n];"%"===s[o(312)]?r[n]=null==a?o(327):""+a+s.unit:r[n]=null==a?"auto":""+a*e+s.unit})},{immediate:!0}),(t,o)=>{const a=n;return e.openBlock(),e.createElementBlock(a(309),{class:e.normalizeClass(["fit-container",{"fit-container-right":void 0!==s[a(321)]}]),style:e.normalizeStyle({transform:r[a(310)],top:r.top,bottom:r[a(323)],left:r[a(311)],right:r[a(321)]})},[e.renderSlot(t.$slots,a(316),{},void 0,!0)],6)}}})),i=u;!function(t){const e=u,n=t();for(;;)try{if(674638==-parseInt(e(184))/1*(parseInt(e(180))/2)+-parseInt(e(175))/3*(parseInt(e(172))/4)+parseInt(e(167))/5+parseInt(e(166))/6*(-parseInt(e(183))/7)+parseInt(e(170))/8+parseInt(e(186))/9*(-parseInt(e(182))/10)+parseInt(e(169))/11)break;n.push(n.shift())}catch(r){n.push(n.shift())}}(p);const c=Symbol(i(189));function u(t,e){const n=p();return(u=function(t,e){return n[t-=166]})(t,e)}function p(){const t=["822680xuEkaQ","value","32379204QoromE","7181016gmKVpU","#app","4THCEmZ","component","provide","3909849nBeJTi","querySelector","string","target","designHeight","2042230sCwFca","globalProperties","620cwxmbL","63nHsAlL","1YQrvew","$fitScale","114651vCQbaR","config","FitContainer","FitScale","144582CxRYQn"];return(p=function(){return t})()}t.FitContainer=a,t.FitScaleKey=c,t.createFitScale=function(t={}){const r=e.ref(1);return{install(e){const o=u;var s,i,p;s=(typeof t.target===o(177)?document[o(176)](t.target):t[o(178)])||document.querySelector(o(171)),i=t[o(179)]??1080,p=t=>{r[o(168)]=t},new ResizeObserver(t=>{const e=n;for(const n of t){const t=n[e(187)][e(190)],r=n[e(187)].width;let o;o=r/t<1.7666666666666666?r/1920*.98:t/i,p(o)}}).observe(s),e[o(174)](c,r),e[o(187)][o(181)][o(185)]=r,e[o(173)](o(188),a)}}},t.useFitScale=function(){return e.inject(c,e.ref(1))},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vfit",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A tiny Vue 3 plugin to auto-fit UI scale based on container size, plus a FitContainer component for easy positioning.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,6 +26,8 @@
26
26
  "@vitejs/plugin-vue": "^5.0.4",
27
27
  "typescript": "^5.6.3",
28
28
  "vite": "^5.4.0",
29
- "terser": "^5.31.0"
29
+ "terser": "^5.31.0",
30
+ "javascript-obfuscator": "^4.1.0",
31
+ "vite-plugin-javascript-obfuscator": "^3.1.0"
30
32
  }
31
33
  }