@kitschpatrol/tweakpane-plugin-file-import 1.2.0-fork.3 → 1.2.0-fork.4
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.
|
@@ -6,8 +6,7 @@ function forceCast(v) {
|
|
|
6
6
|
function parseObject(value, keyToParserMap) {
|
|
7
7
|
return forceCast(Object.keys(keyToParserMap).reduce((tmp, key) => {
|
|
8
8
|
if (tmp === void 0) return;
|
|
9
|
-
const
|
|
10
|
-
const result = parser(value[key]);
|
|
9
|
+
const result = (0, keyToParserMap[key])(value[key]);
|
|
11
10
|
return result.succeeded ? Object.assign(Object.assign({}, tmp), { [key]: result.value }) : void 0;
|
|
12
11
|
}, {}));
|
|
13
12
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){return e}function t(t,n){return e(Object.keys(n).reduce((e,r)=>{if(e===void 0)return;let i=n[r]
|
|
1
|
+
function e(e){return e}function t(t,n){return e(Object.keys(n).reduce((e,r)=>{if(e===void 0)return;let i=(0,n[r])(t[r]);return i.succeeded?Object.assign(Object.assign({},e),{[r]:i.value}):void 0},{}))}function n(e,t){return e.reduce((e,n)=>{if(e===void 0)return;let r=t(n);if(r.succeeded&&r.value!==void 0)return[...e,r.value]},[])}function r(e){return typeof e==`object`&&!!e}function i(e){return t=>n=>{if(!t&&n===void 0)return{succeeded:!1,value:void 0};if(t&&n===void 0)return{succeeded:!0,value:void 0};let r=e(n);return r===void 0?{succeeded:!1,value:void 0}:{succeeded:!0,value:r}}}function a(e){return{custom:t=>i(t)(e),boolean:i(e=>typeof e==`boolean`?e:void 0)(e),number:i(e=>typeof e==`number`?e:void 0)(e),string:i(e=>typeof e==`string`?e:void 0)(e),function:i(e=>typeof e==`function`?e:void 0)(e),constant:t=>i(e=>e===t?t:void 0)(e),raw:i(e=>e)(e),object:n=>i(e=>{if(r(e))return t(e,n)})(e),array:t=>i(e=>{if(Array.isArray(e))return n(e,t)})(e)}}const o={optional:a(!0),required:a(!1)};function s(e,t){let n=t(o),r=o.required.object(n)(e);return r.succeeded?r.value:void 0}function c(e){return(t,n)=>[`tp`,`-`,e,`v`,t?`_${t}`:``,n?`-${n}`:``].join(``)}const l=new class{constructor(e){let[t,n]=e.split(`-`),r=t.split(`.`);this.major=parseInt(r[0],10),this.minor=parseInt(r[1],10),this.patch=parseInt(r[2],10),this.prerelease=n??null}toString(){let e=[this.major,this.minor,this.patch].join(`.`);return this.prerelease===null?e:[e,this.prerelease].join(`-`)}}(`2.0.5`);function u(e){return Object.assign({core:l},e)}var d=class{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((e,t)=>t.constrain(e),e)}};const f=c(`ctn`),p=c(`input`),m=c(`btn`);var h=class{clearButton;container;element;fileIcon;input;text;warning;constructor(e,t){this.element=e.createElement(`div`),this.container=e.createElement(`div`),this.container.classList.add(f()),t.viewProps.bindClassModifiers(this.container),this.input=e.createElement(`input`),this.input.classList.add(p()),this.input.setAttribute(`type`,`file`),this.input.setAttribute(`accept`,t.filetypes?t.filetypes.join(`,`):`*`),this.input.style.height=`calc(20px * ${t.lineCount})`,this.fileIcon=e.createElement(`div`),this.fileIcon.classList.add(f(`icon`)),this.text=e.createElement(`span`),this.text.classList.add(f(`text`)),this.warning=e.createElement(`span`),this.warning.classList.add(f(`warning`)),this.warning.textContent=t.invalidFiletypeMessage,this.warning.style.display=`none`,this.clearButton=e.createElement(`button`),this.clearButton.classList.add(m(`b`)),this.clearButton.textContent=`Delete`,this.clearButton.style.display=`none`,this.container.append(this.input),this.container.append(this.fileIcon),this.element.append(this.container),this.element.append(this.warning),this.element.append(this.clearButton)}changeDraggingState(e){e?this.container.classList.add(f(`input_area_dragging`)):this.container.classList.remove(f(`input_area_dragging`))}},g=class{value;view;viewProps;config;constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new h(e,{filetypes:t.filetypes,invalidFiletypeMessage:t.invalidFiletypeMessage,lineCount:t.lineCount,value:t.value,viewProps:this.viewProps}),this.config=t,this.onFile=this.onFile.bind(this),this.onDrop=this.onDrop.bind(this),this.onDragOver=this.onDragOver.bind(this),this.onDragLeave=this.onDragLeave.bind(this),this.onDeleteClick=this.onDeleteClick.bind(this),this.view.input.addEventListener(`change`,this.onFile),this.view.element.addEventListener(`drop`,this.onDrop),this.view.element.addEventListener(`dragover`,this.onDragOver),this.view.element.addEventListener(`dragleave`,this.onDragLeave),this.view.clearButton.addEventListener(`click`,this.onDeleteClick),this.value.emitter.on(`change`,()=>{this.handleValueChange()}),this.viewProps.handleDispose(()=>{this.view.input.removeEventListener(`change`,this.onFile),this.view.element.removeEventListener(`drop`,this.onDrop),this.view.element.removeEventListener(`dragover`,this.onDragOver),this.view.element.removeEventListener(`dragleave`,this.onDragLeave),this.view.clearButton.removeEventListener(`click`,this.onDeleteClick)})}handleValueChange(){let e=this.value.rawValue,t=this.view.container,n=this.view.text,r=this.view.fileIcon,{clearButton:i}=this.view;e?(n.textContent=e.name,t.append(n),t.contains(r)&&r.remove(),this.view.warning.style.display=`none`,i.style.display=`block`,t.style.border=`unset`):(n.textContent=``,t.append(r),n.remove(),this.view.warning.style.display=`none`,i.style.display=`none`,t.style.border=`1px dashed #717070`)}isFileValid(e){let{filetypes:t}=this.config,n=`.`+(e.name.split(`.`).pop()?.toLowerCase()??``);return!t||t.length===0||t.includes(n)}onDeleteClick(){this.value.rawValue&&(this.value.setRawValue(null),this.view.input.value=``,this.view.warning.style.display=`none`)}onDragLeave(){this.view.changeDraggingState(!1)}onDragOver(e){e.preventDefault(),this.view.changeDraggingState(!0)}onDrop(e){try{if(!(e instanceof DragEvent))return;e.preventDefault();let t=e.dataTransfer?.files;if(t?.length!==1)return;let n=t.item(0);if(!n)return;this.isFileValid(n)?this.value.setRawValue(n):this.showWarning()}finally{this.view.changeDraggingState(!1)}}onFile(e){let t=this.view.input.files?.item(0);t&&(this.isFileValid(t)?this.value.setRawValue(t):this.showWarning())}showWarning(){this.view.warning.style.display=`block`,setTimeout(()=>{this.view.warning.style.display=`none`},5e3)}};function _(e){return e instanceof File?e:null}function v(e,t){e.write(t)}const y=u({accept(e,t){if(typeof e!=`string`)return null;let n=s(t,e=>({filetypes:e.optional.array(e.required.string),invalidFiletypeMessage:e.optional.string,lineCount:e.optional.number,view:e.required.constant(`file-input`)}));return n?{initialValue:e,params:n}:null},binding:{constraint(e){return new d([])},reader(e){return _},writer(e){return v}},controller(e){return new g(e.document,{filetypes:e.params.filetypes,invalidFiletypeMessage:e.params.invalidFiletypeMessage??`Unaccepted file type.`,lineCount:e.params.lineCount??3,value:e.value,viewProps:e.viewProps})},id:`file-input`,type:`input`});var b=`.tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.tp-ctnv:hover{background-color:var(--in-bg-h)}.tp-ctnv:focus{background-color:var(--in-bg-f)}.tp-ctnv:active{background-color:var(--in-bg-a)}.tp-ctnv:disabled{opacity:.5}.tp-ctnv{cursor:pointer;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:"";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:"";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-ctnv~.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}
|
|
2
2
|
`;const x=`file-input`,S=b,C=[y];export{S as css,x as id,C as plugins};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tweakpane-plugin-file-import",
|
|
3
|
-
"version": "1.2.0-fork.
|
|
3
|
+
"version": "1.2.0-fork.4",
|
|
4
4
|
"description": "Fork of tweakpane-plugin-file-import with build optimizations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"npm-package",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@arethetypeswrong/core": "^0.18.5",
|
|
48
|
-
"@kitschpatrol/chagent": "^0.
|
|
49
|
-
"@kitschpatrol/shared-config": "^8.
|
|
48
|
+
"@kitschpatrol/chagent": "^0.9.0",
|
|
49
|
+
"@kitschpatrol/shared-config": "^8.15.0",
|
|
50
50
|
"@tsdown/css": "^0.23.7",
|
|
51
51
|
"@types/node": "~24.13.6",
|
|
52
52
|
"bumpp": "^12.3.0",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"publint": "^0.3.25",
|
|
55
55
|
"sass": "^1.108.2",
|
|
56
56
|
"shx": "^0.4.0",
|
|
57
|
-
"stylelint-config-standard-scss": "^
|
|
57
|
+
"stylelint-config-standard-scss": "^18.0.0",
|
|
58
58
|
"tsdown": "^0.23.7",
|
|
59
59
|
"tweakpane": "^4.0.5",
|
|
60
60
|
"typescript": "~6.0.3",
|
|
61
|
-
"vite": "^8.
|
|
62
|
-
"vitest": "^5.1.
|
|
61
|
+
"vite": "^8.4.1",
|
|
62
|
+
"vitest": "^5.1.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"tweakpane": "^4.0.0"
|
package/readme.md
CHANGED
|
@@ -104,9 +104,9 @@ In addition to the dependency externalization change, this fork also includes de
|
|
|
104
104
|
|
|
105
105
|
[Issues](https://github.com/kitschpatrol/tweakpane-plugin-file-import/issues) are welcome and appreciated.
|
|
106
106
|
|
|
107
|
-
Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs
|
|
107
|
+
Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs are unlikely to be merged.
|
|
108
108
|
|
|
109
|
-
This repository uses [
|
|
109
|
+
This repository uses [ksc](https://github.com/kitschpatrol/shared-config) to handle linting and formatting with the usual tools, plus [mdat](https://github.com/kitschpatrol/mdat) for readme placeholder expansion, and [chagent](https://github.com/kitschpatrol/chagent) to maintain the [changelog](changelog.md).
|
|
110
110
|
|
|
111
111
|
<!-- /contributing -->
|
|
112
112
|
|