@novely/moment-presser 0.5.0-next → 0.6.0
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/README.md +66 -66
- package/dist/{index.d.ts → index.d.mts} +8 -8
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +105 -0
- package/license +15 -15
- package/package.json +33 -32
- package/dist/index.css +0 -2
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
# @novely/moment-presser
|
|
2
|
-
|
|
3
|
-
Moment Presser is a custom action that requires an action from player. Specifically, pressing on button in time. When the moving indicator falls into the narrowest zone, a function is called, to which the state 'PERFECT' is passed, if the zone is thicker — 'PASS', and if it does not hit — 'MISS'. When the income reaches the end, the indicator returns back, and then moves forward again.
|
|
4
|
-
|
|
5
|
-
<div style="width: 100%; display: flex; justify-content: flex-start;">
|
|
6
|
-
<img alt="" src="https://raw.githubusercontent.com/yhdgms1/novely/main/packages/moment-presser/preview.jpg" style="max-height: 20vh; max-width: 100vw;" />
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import type { CreateMomentPresserOptions } from '@novely/moment-presser';
|
|
13
|
-
import { createMomentPresser } from '@novely/moment-presser';
|
|
14
|
-
import '@novely/moment-presser/style.css';
|
|
15
|
-
|
|
16
|
-
import { extendAction } from '@novely/core';
|
|
17
|
-
|
|
18
|
-
const action = extendAction(engine.action, {
|
|
19
|
-
momentPresser: (onPressed: CreateMomentPresserOptions<typeof engine.typeEssentials>['onPressed']) => {
|
|
20
|
-
const momentPresser = createMomentPresser<typeof engine.typeEssentials>({
|
|
21
|
-
onPressed: onPressed,
|
|
22
|
-
translation: {
|
|
23
|
-
en: {
|
|
24
|
-
stop: 'Stop'
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
return ['custom', momentPresser];
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
engine.script({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## CSS Properties
|
|
47
|
-
|
|
48
|
-
```css
|
|
49
|
-
:root {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
```
|
|
1
|
+
# @novely/moment-presser
|
|
2
|
+
|
|
3
|
+
Moment Presser is a custom action that requires an action from player. Specifically, pressing on button in time. When the moving indicator falls into the narrowest zone, a function is called, to which the state 'PERFECT' is passed, if the zone is thicker — 'PASS', and if it does not hit — 'MISS'. When the income reaches the end, the indicator returns back, and then moves forward again.
|
|
4
|
+
|
|
5
|
+
<div style="width: 100%; display: flex; justify-content: flex-start;">
|
|
6
|
+
<img alt="" src="https://raw.githubusercontent.com/yhdgms1/novely/main/packages/moment-presser/preview.jpg" style="max-height: 20vh; max-width: 100vw;" />
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import type { CreateMomentPresserOptions } from '@novely/moment-presser';
|
|
13
|
+
import { createMomentPresser } from '@novely/moment-presser';
|
|
14
|
+
import '@novely/moment-presser/style.css';
|
|
15
|
+
|
|
16
|
+
import { extendAction } from '@novely/core';
|
|
17
|
+
|
|
18
|
+
const action = extendAction(engine.action, {
|
|
19
|
+
momentPresser: (onPressed: CreateMomentPresserOptions<typeof engine.typeEssentials>['onPressed']) => {
|
|
20
|
+
const momentPresser = createMomentPresser<typeof engine.typeEssentials>({
|
|
21
|
+
onPressed: onPressed,
|
|
22
|
+
translation: {
|
|
23
|
+
en: {
|
|
24
|
+
stop: 'Stop',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return ['custom', momentPresser];
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
engine.script({
|
|
34
|
+
start: [
|
|
35
|
+
// you'r story goes here
|
|
36
|
+
action.momentPresser((state, presserState) => {
|
|
37
|
+
console.log(presserState); // 'PERFECT' | 'PASS' | 'MISS'
|
|
38
|
+
|
|
39
|
+
// Function to receive or set state, see: https://novely.deno.dev/guide/state.html
|
|
40
|
+
state();
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## CSS Properties
|
|
47
|
+
|
|
48
|
+
```css
|
|
49
|
+
:root {
|
|
50
|
+
--moment-presser-main-arc-background: color;
|
|
51
|
+
--moment-presser-inner-arc-background: color;
|
|
52
|
+
--moment-presser-outer-arc-background: color;
|
|
53
|
+
--moment-presser-pillar-background: color;
|
|
54
|
+
--moment-presser-wide-match-zone-background: color;
|
|
55
|
+
--moment-presser-narrow-match-zone-background: color;
|
|
56
|
+
--moment-presser-aim-background: color;
|
|
57
|
+
|
|
58
|
+
--moment-presser-button-background: color;
|
|
59
|
+
--moment-presser-button-border: color;
|
|
60
|
+
--moment-presser-circle-background: color;
|
|
61
|
+
--moment-presser-circle-border: color;
|
|
62
|
+
--moment-presser-circle-color: color;
|
|
63
|
+
|
|
64
|
+
--moment-presser-caption-color: color;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { EngineTypes, Lang, State, StateFunction
|
|
1
|
+
import { CustomHandler, EngineTypes, Lang, State, StateFunction } from "@novely/core";
|
|
2
2
|
|
|
3
|
+
//#region src/moment-presser.d.ts
|
|
3
4
|
type MomentPresserOptions<$Lang extends Lang, $State extends State> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
onPressed?: (state: StateFunction<$State>, pressState: 'PERFECT' | 'PASS' | 'MISS') => void;
|
|
5
|
+
translation?: { [L in $Lang & string]: {
|
|
6
|
+
stop: string;
|
|
7
|
+
} };
|
|
8
|
+
onPressed?: (state: StateFunction<$State>, pressState: 'PERFECT' | 'PASS' | 'MISS') => void;
|
|
10
9
|
};
|
|
11
10
|
type CreateMomentPresserOptions<T> = T extends EngineTypes<infer $Lang, infer $State, any, any> ? MomentPresserOptions<$Lang, $State> : never;
|
|
12
11
|
declare const createMomentPresser: <T>(options: CreateMomentPresserOptions<T>) => CustomHandler;
|
|
13
|
-
|
|
12
|
+
//#endregion
|
|
14
13
|
export { type CreateMomentPresserOptions, createMomentPresser };
|
|
14
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content.firstChild},t=({label:t})=>e(`<div class="moment-presser-button-container"><button type="button" class="moment-presser-button" style="aspect-ratio: 1;" aria-label="${t}"><div class="moment-presser-circle" style="aspect-ratio: 1;"><svg fill="currentColor" viewBox="0 0 256 256"><path d="M200.73,40H55.27A15.29,15.29,0,0,0,40,55.27V200.73A15.29,15.29,0,0,0,55.27,216H200.73A15.29,15.29,0,0,0,216,200.73V55.27A15.29,15.29,0,0,0,200.73,40ZM200,200H56V56H200Z"></path></svg></div></button><span class="moment-presser-caption">${t}</span></div>`),n=e=>{let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{mainArcBackground:n(`--moment-presser-main-arc-background`,`#6c868950`),innerArcBackground:n(`--moment-presser-inner-arc-background`,`#c4c3b5`),outerArcBackground:n(`--moment-presser-outer-arc-background`,`#c4c3b5`),pillarBackground:n(`--moment-presser-pillar-background`,`#c4c3b5aa`),wideMatchZoneBackground:n(`--moment-presser-wide-match-zone-background`,`#eaecb7`),narrowMatchZoneBackground:n(`--moment-presser-narrow-match-zone-background`,`#ffc040`),aimBackground:n(`--moment-presser-aim-background`,`#ffffff`)}},r=e=>{let t=!1;return(...n)=>{t||(t=!0,e(...n))}},{max:i,sin:a,cos:o,PI:s}=Math,c=(e,t)=>Math.random()*(t-e)+e,l=(e,t,n)=>Math.max(e,Math.min(t,n)),u=s*2,d=s/2,f=s+s/6,p=u-s/6,m=e=>{let t=s/4,n=e||c(f,p-t),r=n+t,i=s/12,a=n+t/2-i/2;return{outerStart:n,outerWidth:t,outerEnd:r,innerStart:a,innerWidth:i,innerEnd:a+i}},h=e=>t=>Math.floor(e*t),g=e=>f+(p-f)*e,_=(e,t,n,r,i,a)=>{let o=e.canvas.width/2,s=e.canvas.height;e.beginPath(),e.arc(o,s,t,n,r),e.lineWidth=i,e.strokeStyle=a,e.stroke()},v=({ctx:e,fontSize:t,variables:n,get:r})=>{let{width:a,height:o}=e.canvas,{innerStart:c,innerEnd:l,outerStart:f,outerEnd:p}=m(r()),v=h(t),y=v(6.125),b=i(a,o)/2-y,x=a/2,S=o;_(e,b,s,u,y,n.mainArcBackground),_(e,b-y/2-v(.313),s,u,v(.313),n.innerArcBackground),_(e,b+y/2+v(.313),s,u,v(.313),n.outerArcBackground);let C=v(.25),w=y-v(.625);e.fillStyle=n.pillarBackground;for(let t=0;t<7;t++){e.save();let n=g(t/6);e.translate(x+b*Math.cos(n),S+b*Math.sin(n)),e.rotate(n-d),e.beginPath(),e.roundRect(-C/2,-w/2,C,w,v(.313)),e.fill(),e.restore()}_(e,b,f,p,y,n.wideMatchZoneBackground),_(e,b,c,l,y,n.narrowMatchZoneBackground)},y=({ticker:e,preview:t,ctx:n,staticCtx:r,fontSize:s,variables:c,set:u,get:f})=>{let p=0,_=`right`,y=h(s),{innerStart:b,innerEnd:x,outerStart:S,outerEnd:C}=m(f());if(u(S),v({variables:c,fontSize:s,ctx:r,get:f}),t)return{cleanup:()=>{},getState:()=>`MISS`};let w=y(6.125),T=e.add(e=>{let t=e.deltaTime/(1e3/60),{width:r,height:s}=n.canvas;n.clearRect(0,0,r,s);let u=i(r,s)/2-w,f=r/2,m=s,h=y(.25),v=w-y(.625);n.fillStyle=c.aimBackground,n.save(),_=p>=1?`left`:p<=0?`right`:_;let b=g(p);n.translate(f+u*o(b),m+u*a(b)),n.rotate(b-d),n.beginPath(),n.roundRect(-h/2,-v/2,h*3,v,y(.313)),n.fill(),n.restore();let x=t*(_===`right`?.01:-.01);p=l(0,p+x,1)});return e.start(),{cleanup:T,getState:()=>{let e=g(p);return e>=b&&e<=x?`PERFECT`:e>=S&&e<=C?`PASS`:`MISS`}}},b=Symbol(),x=(e={})=>{let i=({getDomNodes:i,clear:a,remove:o,state:s,ticker:c,lang:l,flags:{preview:u}})=>{let{promise:d,resolve:f}=Promise.withResolvers(),{element:p}=i(!0),m=document.createElement(`canvas`),h=document.createElement(`canvas`),g=m.getContext(`2d`),_=h.getContext(`2d`);if(!g||!_)return;let v=document.createElement(`div`);v.className=`moment-presser-root`,p.appendChild(v),m.width=h.width=v.getBoundingClientRect().width*devicePixelRatio,m.height=h.height=m.width/2,h.style.zIndex=`-1`;let b=t({label:e.translation?e.translation[l].stop:`Stop`});v.appendChild(m),v.appendChild(h),v.appendChild(b);let x=Number.parseFloat(getComputedStyle(p).fontSize),S=y({ticker:c,variables:n(p),fontSize:x,preview:u,ctx:g,staticCtx:_,set:e=>{s({$$momentPresserStart:e})},get:()=>s().$$momentPresserStart}),C=r(()=>{c.stop(),S.cleanup(),b.removeEventListener(`click`,w),v.remove(),m.remove(),h.remove(),b.remove()}),w=r(()=>{u||(e.onPressed?.(s,S.getState()),s({$$momentPresserStart:void 0}),C(),f(),o())});return b.addEventListener(`click`,w),a(C),u&&f(),d};return i.id=b,i.key=`moment-presser`,i.requireUserAction=!0,i.callOnlyLatest=!0,i},S=e=>x(e);export{S as createMomentPresser};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/button.ts","../src/css-variables.ts","../src/once.ts","../src/math.ts","../src/render.ts","../src/moment-presser.ts"],"sourcesContent":["const template = (html: string) => {\r\n\tconst t = document.createElement('template');\r\n\r\n\tt.innerHTML = html;\r\n\r\n\treturn t.content.firstChild;\r\n};\r\n\r\ntype CreateButtonOptions = {\r\n\tlabel: string;\r\n};\r\n\r\nconst createButton = ({ label }: CreateButtonOptions) => {\r\n\t/**\r\n\t * Optimized via {@link https://grim.pages.dev/repl Grim JSX}\r\n\t */\r\n\tconst html = `<div class=\"moment-presser-button-container\"><button type=\"button\" class=\"moment-presser-button\" style=\"aspect-ratio: 1;\" aria-label=\"${label}\"><div class=\"moment-presser-circle\" style=\"aspect-ratio: 1;\"><svg fill=\"currentColor\" viewBox=\"0 0 256 256\"><path d=\"M200.73,40H55.27A15.29,15.29,0,0,0,40,55.27V200.73A15.29,15.29,0,0,0,55.27,216H200.73A15.29,15.29,0,0,0,216,200.73V55.27A15.29,15.29,0,0,0,200.73,40ZM200,200H56V56H200Z\"></path></svg></div></button><span class=\"moment-presser-caption\">${label}</span></div>`;\r\n\r\n\treturn template(html) as HTMLButtonElement;\r\n};\r\n\r\nexport { createButton };\r\n","type Variables = {\r\n\tmainArcBackground: string;\r\n\tinnerArcBackground: string;\r\n\touterArcBackground: string;\r\n\tpillarBackground: string;\r\n\twideMatchZoneBackground: string;\r\n\tnarrowMatchZoneBackground: string;\r\n\taimBackground: string;\r\n};\r\n\r\nconst parseVariables = (element: HTMLElement) => {\r\n\tconst style = getComputedStyle(element);\r\n\r\n\tconst get = (property: string, fallback: string) => {\r\n\t\treturn style.getPropertyValue(property).trim() || fallback;\r\n\t};\r\n\r\n\treturn {\r\n\t\tmainArcBackground: get('--moment-presser-main-arc-background', '#6c868950'),\r\n\t\tinnerArcBackground: get('--moment-presser-inner-arc-background', '#c4c3b5'),\r\n\t\touterArcBackground: get('--moment-presser-outer-arc-background', '#c4c3b5'),\r\n\t\tpillarBackground: get('--moment-presser-pillar-background', '#c4c3b5aa'),\r\n\t\twideMatchZoneBackground: get('--moment-presser-wide-match-zone-background', '#eaecb7'),\r\n\t\tnarrowMatchZoneBackground: get('--moment-presser-narrow-match-zone-background', '#ffc040'),\r\n\t\taimBackground: get('--moment-presser-aim-background', '#ffffff'),\r\n\t};\r\n};\r\n\r\nexport { parseVariables };\r\nexport type { Variables };\r\n","const once = <T extends (...args: any[]) => any>(fn: T) => {\r\n\tlet called = false;\r\n\treturn (...params: Parameters<T>) => {\r\n\t\tif (!called) {\r\n\t\t\tcalled = true;\r\n\t\t\tfn(...params);\r\n\t\t}\r\n\t};\r\n};\r\n\r\nexport { once };\r\n","const { max, sin, cos, PI } = Math;\r\n\r\nconst random = (min: number, max: number) => {\r\n\treturn Math.random() * (max - min) + min;\r\n};\r\n\r\nconst clamp = (min: number, num: number, max: number) => {\r\n\treturn Math.max(min, Math.min(num, max));\r\n};\r\n\r\nconst TWO_PI = PI * 2;\r\nconst PI_OVER_TWO = PI / 2;\r\n\r\nexport { random, clamp };\r\nexport { max, sin, cos, PI, TWO_PI, PI_OVER_TWO };\r\n","import type { Variables } from './css-variables';\r\nimport type { Ticker } from '@novely/core';\r\nimport { PI, PI_OVER_TWO, TWO_PI, clamp, cos, max, random, sin } from './math';\r\n\r\nconst st = PI + PI / 6;\r\nconst ed = TWO_PI - PI / 6;\r\n\r\nconst createTarget = (start?: number) => {\r\n\tconst outerWidth = PI / 4;\r\n\tconst outerStart = start || random(st, ed - outerWidth);\r\n\tconst outerEnd = outerStart + outerWidth;\r\n\r\n\tconst innerWidth = PI / 12;\r\n\tconst innerStart = outerStart + outerWidth / 2 - innerWidth / 2;\r\n\tconst innerEnd = innerStart + innerWidth;\r\n\r\n\treturn {\r\n\t\touterStart,\r\n\t\touterWidth,\r\n\t\touterEnd,\r\n\r\n\t\tinnerStart,\r\n\t\tinnerWidth,\r\n\t\tinnerEnd,\r\n\t};\r\n};\r\n\r\nconst createRem = (fontSize: number) => {\r\n\tconst rem = (value: number) => {\r\n\t\t// Floor for performance reasons\r\n\t\treturn Math.floor(fontSize * value);\r\n\t};\r\n\r\n\treturn rem;\r\n};\r\n\r\nconst getAngle = (at: number) => {\r\n\treturn st + (ed - st) * at;\r\n};\r\n\r\nconst arc = (\r\n\tctx: CanvasRenderingContext2D,\r\n\tradius: number,\r\n\tstart: number,\r\n\tend: number,\r\n\twidth: number,\r\n\tcolor: string,\r\n) => {\r\n\tconst cx = ctx.canvas.width / 2;\r\n\tconst cy = ctx.canvas.height;\r\n\r\n\tctx.beginPath();\r\n\tctx.arc(cx, cy, radius, start, end);\r\n\tctx.lineWidth = width;\r\n\tctx.strokeStyle = color;\r\n\tctx.stroke();\r\n};\r\n\r\ntype RenderStaticCicleObjects = {\r\n\tvariables: Variables;\r\n\tfontSize: number;\r\n\r\n\tctx: CanvasRenderingContext2D;\r\n\r\n\tget: () => number | undefined;\r\n};\r\n\r\nconst renderStaticObjects = ({ ctx, fontSize, variables, get }: RenderStaticCicleObjects) => {\r\n\tconst { width: canvasWidth, height: canvasHeight } = ctx.canvas;\r\n\tconst { innerStart, innerEnd, outerStart, outerEnd } = createTarget(get());\r\n\tconst rem = createRem(fontSize);\r\n\r\n\tconst strokeWidth = rem(6.125);\r\n\r\n\tconst d = max(canvasWidth, canvasHeight);\r\n\tconst r = d / 2 - strokeWidth;\r\n\r\n\tconst cx = canvasWidth / 2;\r\n\tconst cy = canvasHeight;\r\n\r\n\t// Main Arc\r\n\tarc(ctx, r, PI, TWO_PI, strokeWidth, variables.mainArcBackground);\r\n\t// Inner Arc\r\n\tarc(ctx, r - strokeWidth / 2 - rem(0.313), PI, TWO_PI, rem(0.313), variables.innerArcBackground);\r\n\t// Outer Arc\r\n\tarc(ctx, r + strokeWidth / 2 + rem(0.313), PI, TWO_PI, rem(0.313), variables.outerArcBackground);\r\n\r\n\tconst pillarWidth = rem(0.25);\r\n\tconst pillarHeight = strokeWidth - rem(0.625);\r\n\r\n\tctx.fillStyle = variables.pillarBackground;\r\n\r\n\tfor (let i = 0; i < 7; i++) {\r\n\t\tctx.save();\r\n\r\n\t\tconst angle = getAngle(i / 6);\r\n\r\n\t\tctx.translate(cx + r * Math.cos(angle), cy + r * Math.sin(angle));\r\n\r\n\t\tctx.rotate(angle - PI_OVER_TWO);\r\n\r\n\t\tctx.beginPath();\r\n\t\tctx.roundRect(-pillarWidth / 2, -pillarHeight / 2, pillarWidth, pillarHeight, rem(0.313));\r\n\t\tctx.fill();\r\n\r\n\t\tctx.restore();\r\n\t}\r\n\r\n\t// Outer Golden\r\n\tarc(ctx, r, outerStart, outerEnd, strokeWidth, variables.wideMatchZoneBackground);\r\n\t// Inner Golden\r\n\tarc(ctx, r, innerStart, innerEnd, strokeWidth, variables.narrowMatchZoneBackground);\r\n};\r\n\r\ntype StartRenderOptions = {\r\n\tticker: Ticker;\r\n\r\n\tvariables: Variables;\r\n\tfontSize: number;\r\n\r\n\tpreview: boolean;\r\n\r\n\tctx: CanvasRenderingContext2D;\r\n\tstaticCtx: CanvasRenderingContext2D;\r\n\r\n\tset: (start: number) => void;\r\n\tget: () => number | undefined;\r\n};\r\n\r\nconst startRender = ({ ticker, preview, ctx, staticCtx, fontSize, variables, set, get }: StartRenderOptions) => {\r\n\tlet position = 0;\r\n\tlet direction: 'right' | 'left' = 'right';\r\n\r\n\tconst rem = createRem(fontSize);\r\n\r\n\tconst { innerStart, innerEnd, outerStart, outerEnd } = createTarget(get());\r\n\r\n\tset(outerStart);\r\n\r\n\trenderStaticObjects({\r\n\t\tvariables,\r\n\t\tfontSize,\r\n\r\n\t\tctx: staticCtx,\r\n\r\n\t\tget,\r\n\t});\r\n\r\n\t/**\r\n\t * 1. Pillar is not rendered\r\n\t * 2. Get state is always miss\r\n\t * 2.1 Should never be called\r\n\t * 2.2 Start position is zero, target zone is never zero\r\n\t */\r\n\tif (preview) {\r\n\t\treturn {\r\n\t\t\tcleanup: () => {},\r\n\t\t\tgetState: () => 'MISS' as const,\r\n\t\t};\r\n\t}\r\n\r\n\tconst strokeWidth = rem(6.125);\r\n\r\n\tconst cleanup = ticker.add((ticker) => {\r\n\t\tconst dtm = ticker.deltaTime / (1000 / 60);\r\n\r\n\t\tconst { width: canvasWidth, height: canvasHeight } = ctx.canvas;\r\n\r\n\t\tctx.clearRect(0, 0, canvasWidth, canvasHeight);\r\n\r\n\t\tconst d = max(canvasWidth, canvasHeight);\r\n\t\tconst r = d / 2 - strokeWidth;\r\n\r\n\t\tconst cx = canvasWidth / 2;\r\n\t\tconst cy = canvasHeight;\r\n\r\n\t\tconst pillarWidth = rem(0.25);\r\n\t\tconst pillarHeight = strokeWidth - rem(0.625);\r\n\r\n\t\t/**\r\n\t\t * Aim\r\n\t\t */\r\n\t\tctx.fillStyle = variables.aimBackground;\r\n\r\n\t\tctx.save();\r\n\r\n\t\tdirection = position >= 1 ? 'left' : position <= 0 ? 'right' : direction;\r\n\r\n\t\tconst angle = getAngle(position);\r\n\r\n\t\tctx.translate(cx + r * cos(angle), cy + r * sin(angle));\r\n\r\n\t\tctx.rotate(angle - PI_OVER_TWO);\r\n\r\n\t\tctx.beginPath();\r\n\t\tctx.roundRect(-pillarWidth / 2, -pillarHeight / 2, pillarWidth * 3, pillarHeight, rem(0.313));\r\n\t\tctx.fill();\r\n\r\n\t\tctx.restore();\r\n\r\n\t\tconst change = dtm * (direction === 'right' ? 0.01 : -0.01);\r\n\r\n\t\tposition = clamp(0, position + change, 1);\r\n\t});\r\n\r\n\tticker.start();\r\n\r\n\tconst getState = () => {\r\n\t\tconst angle = getAngle(position);\r\n\r\n\t\tif (angle >= innerStart && angle <= innerEnd) {\r\n\t\t\treturn 'PERFECT';\r\n\t\t}\r\n\r\n\t\tif (angle >= outerStart && angle <= outerEnd) {\r\n\t\t\treturn 'PASS';\r\n\t\t}\r\n\r\n\t\treturn 'MISS';\r\n\t};\r\n\r\n\treturn {\r\n\t\tcleanup,\r\n\t\tgetState,\r\n\t};\r\n};\r\n\r\nexport { startRender, renderStaticObjects };\r\n","import type { CustomHandler, Lang, State, StateFunction, EngineTypes } from '@novely/core';\r\nimport { createButton } from './button';\r\nimport { parseVariables } from './css-variables';\r\nimport { once } from './once';\r\nimport { startRender } from './render';\r\n\r\nconst MOMENT_PRESSER_ID = Symbol();\r\n\r\ntype MomentPresserOptions<$Lang extends Lang, $State extends State> = {\r\n\ttranslation?: {\r\n\t\t[L in $Lang & string]: {\r\n\t\t\tstop: string;\r\n\t\t};\r\n\t};\r\n\r\n\tonPressed?: (state: StateFunction<$State>, pressState: 'PERFECT' | 'PASS' | 'MISS') => void;\r\n};\r\n\r\nconst momentPresser = (options: MomentPresserOptions<Lang, State> = {}) => {\r\n\tconst fn: CustomHandler = ({ getDomNodes, clear, remove, state, ticker, lang, flags: { preview } }) => {\r\n\t\tconst { promise, resolve } = Promise.withResolvers<void>();\r\n\r\n\t\tconst { element } = getDomNodes(true);\r\n\r\n\t\tconst canvas = document.createElement('canvas');\r\n\t\tconst staticCanvas = document.createElement('canvas');\r\n\r\n\t\tconst ctx = canvas.getContext('2d');\r\n\t\tconst staticCtx = staticCanvas.getContext('2d');\r\n\r\n\t\tif (!ctx || !staticCtx) return;\r\n\r\n\t\tconst root = document.createElement('div');\r\n\t\troot.className = 'moment-presser-root';\r\n\r\n\t\telement.appendChild(root);\r\n\r\n\t\tcanvas.width = staticCanvas.width = root.getBoundingClientRect().width * devicePixelRatio;\r\n\t\tcanvas.height = staticCanvas.height = canvas.width / 2;\r\n\r\n\t\t/**\r\n\t\t * Позиционируем так, чтобы не перекрывался бегунок\r\n\t\t */\r\n\t\tstaticCanvas.style.zIndex = '-1';\r\n\r\n\t\tconst button = createButton({\r\n\t\t\tlabel: options.translation ? options.translation[lang].stop : 'Stop',\r\n\t\t});\r\n\r\n\t\troot.appendChild(canvas);\r\n\t\troot.appendChild(staticCanvas);\r\n\t\troot.appendChild(button);\r\n\r\n\t\tconst fontSize = Number.parseFloat(getComputedStyle(element).fontSize);\r\n\t\tconst variables = parseVariables(element);\r\n\r\n\t\tconst renderer = startRender({\r\n\t\t\tticker,\r\n\r\n\t\t\tvariables,\r\n\t\t\tfontSize,\r\n\r\n\t\t\tpreview,\r\n\r\n\t\t\tctx,\r\n\t\t\tstaticCtx,\r\n\r\n\t\t\tset: (start) => {\r\n\t\t\t\tstate({ $$momentPresserStart: start });\r\n\t\t\t},\r\n\t\t\tget: () => {\r\n\t\t\t\treturn state().$$momentPresserStart;\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\tconst cleanup = once(() => {\r\n\t\t\tticker.stop();\r\n\t\t\trenderer.cleanup();\r\n\r\n\t\t\tbutton.removeEventListener('click', onButtonClick);\r\n\r\n\t\t\troot.remove();\r\n\t\t\tcanvas.remove();\r\n\t\t\tstaticCanvas.remove();\r\n\t\t\tbutton.remove();\r\n\t\t});\r\n\r\n\t\tconst onButtonClick = once(() => {\r\n\t\t\tif (preview) return;\r\n\r\n\t\t\toptions.onPressed?.(state, renderer.getState());\r\n\r\n\t\t\tstate({ $$momentPresserStart: undefined });\r\n\r\n\t\t\tcleanup();\r\n\t\t\tresolve();\r\n\r\n\t\t\tremove();\r\n\t\t});\r\n\r\n\t\tbutton.addEventListener('click', onButtonClick);\r\n\r\n\t\tclear(cleanup);\r\n\r\n\t\tif (preview) {\r\n\t\t\tresolve();\r\n\t\t}\r\n\r\n\t\treturn promise;\r\n\t};\r\n\r\n\tfn.id = MOMENT_PRESSER_ID;\r\n\tfn.key = 'moment-presser';\r\n\tfn.requireUserAction = true;\r\n\tfn.callOnlyLatest = true;\r\n\r\n\treturn fn;\r\n};\r\n\r\ntype CreateMomentPresserOptions<T> =\r\n\tT extends EngineTypes<infer $Lang, infer $State, any, any> ? MomentPresserOptions<$Lang, $State> : never;\r\n\r\nconst createMomentPresser = <T>(options: CreateMomentPresserOptions<T>) => {\r\n\treturn momentPresser(options);\r\n};\r\n\r\nexport { createMomentPresser };\r\nexport type { MomentPresserOptions, CreateMomentPresserOptions };\r\n"],"mappings":"AAAA,MAAM,EAAY,GAAiB,CAClC,IAAM,EAAI,SAAS,cAAc,WAAW,CAI5C,MAFA,GAAE,UAAY,EAEP,EAAE,QAAQ,YAOZ,GAAgB,CAAE,WAMhB,EAFM,yIAAyI,EAAM,mWAAmW,EAAM,eAEhf,CCRhB,EAAkB,GAAyB,CAChD,IAAM,EAAQ,iBAAiB,EAAQ,CAEjC,GAAO,EAAkB,IACvB,EAAM,iBAAiB,EAAS,CAAC,MAAM,EAAI,EAGnD,MAAO,CACN,kBAAmB,EAAI,uCAAwC,YAAY,CAC3E,mBAAoB,EAAI,wCAAyC,UAAU,CAC3E,mBAAoB,EAAI,wCAAyC,UAAU,CAC3E,iBAAkB,EAAI,qCAAsC,YAAY,CACxE,wBAAyB,EAAI,8CAA+C,UAAU,CACtF,0BAA2B,EAAI,gDAAiD,UAAU,CAC1F,cAAe,EAAI,kCAAmC,UAAU,CAChE,ECzBI,EAA2C,GAAU,CAC1D,IAAI,EAAS,GACb,OAAQ,GAAG,IAA0B,CAC/B,IACJ,EAAS,GACT,EAAG,GAAG,EAAO,ICLV,CAAE,MAAK,MAAK,MAAK,MAAO,KAExB,GAAU,EAAa,IACrB,KAAK,QAAQ,EAAI,EAAM,GAAO,EAGhC,GAAS,EAAa,EAAa,IACjC,KAAK,IAAI,EAAK,KAAK,IAAI,EAAK,EAAI,CAAC,CAGnC,EAAS,EAAK,EACd,EAAc,EAAK,ECPnB,EAAK,EAAK,EAAK,EACf,EAAK,EAAS,EAAK,EAEnB,EAAgB,GAAmB,CACxC,IAAM,EAAa,EAAK,EAClB,EAAa,GAAS,EAAO,EAAI,EAAK,EAAW,CACjD,EAAW,EAAa,EAExB,EAAa,EAAK,GAClB,EAAa,EAAa,EAAa,EAAI,EAAa,EAG9D,MAAO,CACN,aACA,aACA,WAEA,aACA,aACA,SATgB,EAA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,EAAO,MAAM,CACb,EAAS,SAAS,CAElB,EAAO,oBAAoB,QAAS,EAAc,CAElD,EAAK,QAAQ,CACb,EAAO,QAAQ,CACf,EAAa,QAAQ,CACrB,EAAO,QAAQ,EACd,CAEI,EAAgB,MAAW,CAC5B,IAEJ,EAAQ,YAAY,EAAO,EAAS,UAAU,CAAC,CAE/C,EAAM,CAAE,qBAAsB,IAAA,GAAW,CAAC,CAE1C,GAAS,CACT,GAAS,CAET,GAAQ,GACP,CAUF,OARA,EAAO,iBAAiB,QAAS,EAAc,CAE/C,EAAM,EAAQ,CAEV,GACH,GAAS,CAGH,GAQR,MALA,GAAG,GAAK,EACR,EAAG,IAAM,iBACT,EAAG,kBAAoB,GACvB,EAAG,eAAiB,GAEb,GAMF,EAA0B,GACxB,EAAc,EAAQ"}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
.moment-presser-root {
|
|
2
|
+
z-index: 29;
|
|
3
|
+
backdrop-filter: blur(10px);
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
justify-content: flex-end;
|
|
6
|
+
align-items: center;
|
|
7
|
+
width: 100vw;
|
|
8
|
+
height: 100vh;
|
|
9
|
+
display: flex;
|
|
10
|
+
position: absolute;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.preview .moment-presser-root {
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.moment-presser-root canvas {
|
|
19
|
+
width: 50%;
|
|
20
|
+
margin-bottom: 4rem;
|
|
21
|
+
position: absolute;
|
|
22
|
+
mask-image: linear-gradient(#000 0% 50%, #0000 100%);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (aspect-ratio <= .8) {
|
|
26
|
+
.moment-presser-root canvas {
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.moment-presser-button-container {
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: .7rem;
|
|
36
|
+
display: flex;
|
|
37
|
+
position: absolute;
|
|
38
|
+
bottom: 0;
|
|
39
|
+
left: 50%;
|
|
40
|
+
transform: translate(-50%, -50%);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.moment-presser-button {
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
background: var(--moment-presser-button-background, #6c8689);
|
|
46
|
+
width: 4rem;
|
|
47
|
+
height: 4rem;
|
|
48
|
+
box-shadow: 0 0 0 .2rem var(--moment-presser-button-border, #b5ced1);
|
|
49
|
+
user-select: none;
|
|
50
|
+
border: none;
|
|
51
|
+
border-radius: 999rem;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
align-items: center;
|
|
54
|
+
display: flex;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.moment-presser-circle {
|
|
58
|
+
background: var(--moment-presser-circle-background, #3b4553);
|
|
59
|
+
width: 3rem;
|
|
60
|
+
height: 3rem;
|
|
61
|
+
box-shadow: 0 0 0 .2rem var(--moment-presser-circle-border, #3e4c53);
|
|
62
|
+
color: var(--moment-presser-circle-color, #ffffc0);
|
|
63
|
+
border-radius: 999rem;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
align-items: center;
|
|
66
|
+
display: flex;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.moment-presser-circle svg {
|
|
70
|
+
width: 2rem;
|
|
71
|
+
height: 2rem;
|
|
72
|
+
filter: drop-shadow(0 0 .75rem var(--moment-presser-caption-color, #ffffc0));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.moment-presser-caption {
|
|
76
|
+
color: var(--moment-presser-caption-color, #ffffc0);
|
|
77
|
+
font-size: 1.3rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (aspect-ratio <= .8) or ((aspect-ratio >= .8) and (pointer: coarse)) {
|
|
81
|
+
.moment-presser-button-container {
|
|
82
|
+
transform: translate(-50%, -130%);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.moment-presser-button {
|
|
86
|
+
width: 3rem;
|
|
87
|
+
height: 3rem;
|
|
88
|
+
box-shadow: 0 0 0 .1rem var(--moment-presser-button-border, #b5ced1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.moment-presser-circle {
|
|
92
|
+
width: 2.2rem;
|
|
93
|
+
height: 2.2rem;
|
|
94
|
+
box-shadow: 0 0 0 .1rem var(--moment-presser-circle-border, #3e4c53);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.moment-presser-circle svg {
|
|
98
|
+
width: 1.4rem;
|
|
99
|
+
height: 1.4rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.moment-presser-caption {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
}
|
package/license
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024, Artem Schukin
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Artem Schukin
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novely/moment-presser",
|
|
3
|
+
"version": "0.6.0",
|
|
3
4
|
"description": "Moment Presser Action",
|
|
4
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"novely"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/yhdgms1/novely/tree/main/packages/moment-presser",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/yhdgms1/novely/issues"
|
|
11
|
+
},
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Artemiy Schukin",
|
|
15
|
+
"url": "https://github.com/yhdgms1"
|
|
16
|
+
},
|
|
17
|
+
"contributors": [],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/yhdgms1/novely.git"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/*"
|
|
24
|
+
],
|
|
5
25
|
"type": "module",
|
|
6
26
|
"sideEffects": false,
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
27
|
+
"main": "./dist/index.mjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
10
30
|
"exports": {
|
|
11
31
|
".": {
|
|
12
|
-
"types": "./dist/index.d.
|
|
13
|
-
"import": "./dist/index.
|
|
32
|
+
"types": "./dist/index.d.mts",
|
|
33
|
+
"import": "./dist/index.mjs"
|
|
14
34
|
},
|
|
15
|
-
"./style.css": "./dist/
|
|
35
|
+
"./style.css": "./dist/style.css",
|
|
16
36
|
"./*": "./dist/*",
|
|
17
37
|
"./package.json": "./package.json"
|
|
18
38
|
},
|
|
@@ -20,37 +40,18 @@
|
|
|
20
40
|
"access": "public"
|
|
21
41
|
},
|
|
22
42
|
"dependencies": {
|
|
23
|
-
"@novely/core": "^0.
|
|
43
|
+
"@novely/core": "^0.56.0"
|
|
24
44
|
},
|
|
25
45
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
46
|
+
"@tsdown/css": "^0.21.4",
|
|
47
|
+
"tsdown": "^0.21.4",
|
|
48
|
+
"typescript": "^5.9.3"
|
|
28
49
|
},
|
|
29
50
|
"peerDependencies": {
|
|
30
51
|
"@novely/core": "*"
|
|
31
52
|
},
|
|
32
|
-
"license": "ISC",
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/yhdgms1/novely/issues"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://github.com/yhdgms1/novely/tree/main/packages/moment-presser",
|
|
37
|
-
"keywords": [
|
|
38
|
-
"novely"
|
|
39
|
-
],
|
|
40
|
-
"author": {
|
|
41
|
-
"name": "Artemiy Schukin",
|
|
42
|
-
"url": "https://github.com/yhdgms1"
|
|
43
|
-
},
|
|
44
|
-
"contributors": [],
|
|
45
|
-
"repository": {
|
|
46
|
-
"type": "git",
|
|
47
|
-
"url": "git+https://github.com/yhdgms1/novely.git"
|
|
48
|
-
},
|
|
49
|
-
"files": [
|
|
50
|
-
"dist/*"
|
|
51
|
-
],
|
|
52
53
|
"scripts": {
|
|
53
|
-
"dev": "
|
|
54
|
-
"build": "
|
|
54
|
+
"dev": "tsdown --watch --dts",
|
|
55
|
+
"build": "tsdown --dts"
|
|
55
56
|
}
|
|
56
57
|
}
|
package/dist/index.css
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
.moment-presser-root{width:100vw;height:100vh;position:absolute;z-index:29;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;backdrop-filter:blur(10px)}.preview .moment-presser-root{width:100%;height:100%}.moment-presser-root canvas{position:absolute;margin-bottom:4rem;width:50%;mask-image:linear-gradient(180deg,#000 0%,#000 50%,transparent 100%)}@media (max-aspect-ratio: .8){.moment-presser-root canvas{width:100%}}.moment-presser-button-container{position:absolute;bottom:0;left:50%;transform:translate(-50%,-50%);display:flex;gap:.7rem;flex-direction:column;align-items:center;justify-content:center}.moment-presser-button{cursor:pointer;background:var(--moment-presser-button-background, #6c8689);width:4rem;height:4rem;border:none;box-shadow:0 0 0 .2rem var(--moment-presser-button-border, #b5ced1);border-radius:999rem;display:flex;align-items:center;justify-content:center;user-select:none}.moment-presser-circle{background:var(--moment-presser-circle-background, #3b4553);width:3rem;height:3rem;box-shadow:0 0 0 .2rem var(--moment-presser-circle-border, #3e4c53);border-radius:999rem;display:flex;align-items:center;justify-content:center;color:var(--moment-presser-circle-color, #ffffc0)}.moment-presser-circle svg{width:2rem;height:2rem;filter:drop-shadow(0 0 .75rem var(--moment-presser-caption-color, #ffffc0))}.moment-presser-caption{font-size:1.3rem;color:var(--moment-presser-caption-color, #ffffc0)}@media (max-aspect-ratio: .8) or ((min-aspect-ratio: .8) and (pointer: coarse)){.moment-presser-button-container{transform:translate(-50%,-130%)}.moment-presser-button{width:3rem;height:3rem;box-shadow:0 0 0 .1rem var(--moment-presser-button-border, #b5ced1)}.moment-presser-circle{width:2.2rem;height:2.2rem;box-shadow:0 0 0 .1rem var(--moment-presser-circle-border, #3e4c53)}.moment-presser-circle svg{width:1.4rem;height:1.4rem}.moment-presser-caption{display:none}}
|
|
2
|
-
/*# sourceMappingURL=index.css.map */
|
package/dist/index.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/style.css"],"sourcesContent":[".moment-presser-root {\n\twidth: 100vw;\n\theight: 100vh;\n\n\tposition: absolute;\n\tz-index: 29;\n\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: flex-end;\n\n\tbackdrop-filter: blur(10px);\n}\n\n.preview .moment-presser-root {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.moment-presser-root canvas {\n\tposition: absolute;\n\n\tmargin-bottom: 4rem;\n\n\twidth: 50%;\n\n\tmask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 100%);\n}\n\n@media (max-aspect-ratio: 0.8) {\n\t.moment-presser-root canvas {\n\t\twidth: 100%;\n\t}\n}\n\n.moment-presser-button-container {\n\tposition: absolute;\n\n\tbottom: 0;\n\tleft: 50%;\n\n\ttransform: translate(-50%, -50%);\n\n\tdisplay: flex;\n\tgap: 0.7rem;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.moment-presser-button {\n\tcursor: pointer;\n\n\tbackground: var(--moment-presser-button-background, #6c8689);\n\n\twidth: 4rem;\n\theight: 4rem;\n\n\tborder: none;\n\n\tbox-shadow: 0 0 0 0.2rem var(--moment-presser-button-border, #b5ced1);\n\n\tborder-radius: 999rem;\n\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\n\tuser-select: none;\n}\n\n.moment-presser-circle {\n\tbackground: var(--moment-presser-circle-background, #3b4553);\n\n\twidth: 3rem;\n\theight: 3rem;\n\n\tbox-shadow: 0 0 0 0.2rem var(--moment-presser-circle-border, #3e4c53);\n\n\tborder-radius: 999rem;\n\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\n\tcolor: var(--moment-presser-circle-color, #ffffc0);\n}\n\n.moment-presser-circle svg {\n\twidth: 2rem;\n\theight: 2rem;\n\n\tfilter: drop-shadow(0 0 0.75rem var(--moment-presser-caption-color, #ffffc0));\n}\n\n.moment-presser-caption {\n\tfont-size: 1.3rem;\n\n\tcolor: var(--moment-presser-caption-color, #ffffc0);\n}\n\n@media (max-aspect-ratio: 0.8) or ((min-aspect-ratio: 0.8) and (pointer: coarse)) {\n\t.moment-presser-button-container {\n\t\ttransform: translate(-50%, -130%);\n\t}\n\n\t.moment-presser-button {\n\t\twidth: 3rem;\n\t\theight: 3rem;\n\n\t\tbox-shadow: 0 0 0 0.1rem var(--moment-presser-button-border, #b5ced1);\n\t}\n\n\t.moment-presser-circle {\n\t\twidth: 2.2rem;\n\t\theight: 2.2rem;\n\n\t\tbox-shadow: 0 0 0 0.1rem var(--moment-presser-circle-border, #3e4c53);\n\t}\n\n\t.moment-presser-circle svg {\n\t\twidth: 1.4rem;\n\t\theight: 1.4rem;\n\t}\n\n\t.moment-presser-caption {\n\t\tdisplay: none;\n\t}\n}\n"],"mappings":"AAAA,CAAC,oBACA,MAAO,MACP,OAAQ,MAER,SAAU,SACV,QAAS,GAET,QAAS,KACT,eAAgB,OAChB,YAAa,OACb,gBAAiB,SAEjB,gBAAiB,KAAK,KACvB,CAEA,CAAC,QAAQ,CAfR,oBAgBA,MAAO,KACP,OAAQ,IACT,CAEA,CApBC,oBAoBoB,OACpB,SAAU,SAEV,cAAe,KAEf,MAAO,IAEP,WAAY,gBAAgB,MAAM,CAAE,KAAK,EAAE,CAAE,KAAK,GAAG,CAAE,YAAY,KACpE,CAEA,OAAO,CAAC,gBAAgB,EAAE,IACzB,CA/BA,oBA+BqB,OACpB,MAAO,IAC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js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var G=e=>{let r=document.createElement("template");return r.innerHTML=e,r.content.firstChild},H=({label:e})=>{let r=`<div class="moment-presser-button-container"><button type="button" class="moment-presser-button" style="aspect-ratio: 1;" aria-label="${e}"><div class="moment-presser-circle" style="aspect-ratio: 1;"><svg fill="currentColor" viewBox="0 0 256 256"><path d="M200.73,40H55.27A15.29,15.29,0,0,0,40,55.27V200.73A15.29,15.29,0,0,0,55.27,216H200.73A15.29,15.29,0,0,0,216,200.73V55.27A15.29,15.29,0,0,0,200.73,40ZM200,200H56V56H200Z"></path></svg></div></button><span class="moment-presser-caption">${e}</span></div>`;return G(r)};var V=e=>{let r=getComputedStyle(e),t=(l,s)=>r.getPropertyValue(l).trim()||s;return{mainArcBackground:t("--moment-presser-main-arc-background","#6c868950"),innerArcBackground:t("--moment-presser-inner-arc-background","#c4c3b5"),outerArcBackground:t("--moment-presser-outer-arc-background","#c4c3b5"),pillarBackground:t("--moment-presser-pillar-background","#c4c3b5aa"),wideMatchZoneBackground:t("--moment-presser-wide-match-zone-background","#eaecb7"),narrowMatchZoneBackground:t("--moment-presser-narrow-match-zone-background","#ffc040"),aimBackground:t("--moment-presser-aim-background","#ffffff")}};var x=e=>{let r=!1;return(...t)=>{r||(r=!0,e(...t))}};var{max:O,sin:W,cos:I,PI:p}=Math,z=(e,r)=>Math.random()*(r-e)+e,Z=(e,r,t)=>Math.max(e,Math.min(r,t)),P=p*2,R=p/2;var T=p+p/6,_=P-p/6,j=e=>{let r=p/4,t=e||z(T,_-r),l=t+r,s=p/12,a=t+r/2-s/2,u=a+s;return{outerStart:t,outerWidth:r,outerEnd:l,innerStart:a,innerWidth:s,innerEnd:u}},D=e=>t=>Math.floor(e*t),A=e=>T+(_-T)*e,w=(e,r,t,l,s,a)=>{let u=e.canvas.width/2,h=e.canvas.height;e.beginPath(),e.arc(u,h,r,t,l),e.lineWidth=s,e.strokeStyle=a,e.stroke()},J=({ctx:e,fontSize:r,variables:t,get:l})=>{let{width:s,height:a}=e.canvas,{innerStart:u,innerEnd:h,outerStart:c,outerEnd:f}=j(l()),o=D(r),i=o(6.125),n=O(s,a)/2-i,y=s/2,v=a;w(e,n,p,P,i,t.mainArcBackground),w(e,n-i/2-o(.313),p,P,o(.313),t.innerArcBackground),w(e,n+i/2+o(.313),p,P,o(.313),t.outerArcBackground);let m=o(.25),b=i-o(.625);e.fillStyle=t.pillarBackground;for(let d=0;d<7;d++){e.save();let S=A(d/6);e.translate(y+n*Math.cos(S),v+n*Math.sin(S)),e.rotate(S-R),e.beginPath(),e.roundRect(-m/2,-b/2,m,b,o(.313)),e.fill(),e.restore()}w(e,n,c,f,i,t.wideMatchZoneBackground),w(e,n,u,h,i,t.narrowMatchZoneBackground)},F=({ticker:e,preview:r,ctx:t,staticCtx:l,fontSize:s,variables:a,set:u,get:h})=>{let c=0,f="right",o=D(s),{innerStart:i,innerEnd:g,outerStart:n,outerEnd:y}=j(h());if(u(n),J({variables:a,fontSize:s,ctx:l,get:h}),r)return{cleanup:()=>{},getState:()=>"MISS"};let v=o(6.125),m=e.add(d=>{let S=d.deltaTime/16.666666666666668,{width:k,height:C}=t.canvas;t.clearRect(0,0,k,C);let M=O(k,C)/2-v,N=k/2,q=C,$=o(.25),L=v-o(.625);t.fillStyle=a.aimBackground,t.save(),f=c>=1?"left":c<=0?"right":f;let E=A(c);t.translate(N+M*I(E),q+M*W(E)),t.rotate(E-R),t.beginPath(),t.roundRect(-$/2,-L/2,$*3,L,o(.313)),t.fill(),t.restore();let U=S*(f==="right"?.01:-.01);c=Z(0,c+U,1)});return e.start(),{cleanup:m,getState:()=>{let d=A(c);return d>=i&&d<=g?"PERFECT":d>=n&&d<=y?"PASS":"MISS"}}};var K=Symbol(),Q=(e={})=>{let r=({getDomNodes:t,clear:l,remove:s,state:a,ticker:u,lang:h,flags:{preview:c}})=>{let{promise:f,resolve:o}=Promise.withResolvers(),{element:i}=t(!0),g=document.createElement("canvas"),n=document.createElement("canvas"),y=g.getContext("2d"),v=n.getContext("2d");if(!y||!v)return;let m=document.createElement("div");m.className="moment-presser-root",i.appendChild(m),g.width=n.width=m.getBoundingClientRect().width*devicePixelRatio,g.height=n.height=g.width/2,n.style.zIndex="-1";let b=H({label:e.translation?e.translation[h].stop:"Stop"});m.appendChild(g),m.appendChild(n),m.appendChild(b);let d=Number.parseFloat(getComputedStyle(i).fontSize),S=V(i),k=F({ticker:u,variables:S,fontSize:d,preview:c,ctx:y,staticCtx:v,set:M=>{a({$$momentPresserStart:M})},get:()=>a().$$momentPresserStart}),C=x(()=>{u.stop(),k.cleanup(),b.removeEventListener("click",B),m.remove(),g.remove(),n.remove(),b.remove()}),B=x(()=>{c||(e.onPressed?.(a,k.getState()),a({$$momentPresserStart:void 0}),C(),o(),s())});return b.addEventListener("click",B),l(C),c&&o(),f};return r.id=K,r.key="moment-presser",r.requireUserAction=!0,r.callOnlyLatest=!0,r},X=e=>Q(e);export{X as createMomentPresser};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/button.ts","../src/css-variables.ts","../src/once.ts","../src/math.ts","../src/render.ts","../src/moment-presser.ts"],"sourcesContent":["const template = (html: string) => {\n\tconst t = document.createElement('template');\n\n\tt.innerHTML = html;\n\n\treturn t.content.firstChild;\n};\n\ntype CreateButtonOptions = {\n\tlabel: string;\n};\n\nconst createButton = ({ label }: CreateButtonOptions) => {\n\t/**\n\t * Optimized via {@link https://grim.pages.dev/repl Grim JSX}\n\t */\n\tconst html = `<div class=\"moment-presser-button-container\"><button type=\"button\" class=\"moment-presser-button\" style=\"aspect-ratio: 1;\" aria-label=\"${label}\"><div class=\"moment-presser-circle\" style=\"aspect-ratio: 1;\"><svg fill=\"currentColor\" viewBox=\"0 0 256 256\"><path d=\"M200.73,40H55.27A15.29,15.29,0,0,0,40,55.27V200.73A15.29,15.29,0,0,0,55.27,216H200.73A15.29,15.29,0,0,0,216,200.73V55.27A15.29,15.29,0,0,0,200.73,40ZM200,200H56V56H200Z\"></path></svg></div></button><span class=\"moment-presser-caption\">${label}</span></div>`;\n\n\treturn template(html) as HTMLButtonElement;\n};\n\nexport { createButton };\n","type Variables = {\n\tmainArcBackground: string;\n\tinnerArcBackground: string;\n\touterArcBackground: string;\n\tpillarBackground: string;\n\twideMatchZoneBackground: string;\n\tnarrowMatchZoneBackground: string;\n\taimBackground: string;\n};\n\nconst parseVariables = (element: HTMLElement) => {\n\tconst style = getComputedStyle(element);\n\n\tconst get = (property: string, fallback: string) => {\n\t\treturn style.getPropertyValue(property).trim() || fallback;\n\t};\n\n\treturn {\n\t\tmainArcBackground: get('--moment-presser-main-arc-background', '#6c868950'),\n\t\tinnerArcBackground: get('--moment-presser-inner-arc-background', '#c4c3b5'),\n\t\touterArcBackground: get('--moment-presser-outer-arc-background', '#c4c3b5'),\n\t\tpillarBackground: get('--moment-presser-pillar-background', '#c4c3b5aa'),\n\t\twideMatchZoneBackground: get('--moment-presser-wide-match-zone-background', '#eaecb7'),\n\t\tnarrowMatchZoneBackground: get('--moment-presser-narrow-match-zone-background', '#ffc040'),\n\t\taimBackground: get('--moment-presser-aim-background', '#ffffff'),\n\t};\n};\n\nexport { parseVariables };\nexport type { Variables };\n","const once = <T extends (...args: any[]) => any>(fn: T) => {\n\tlet called = false;\n\treturn (...params: Parameters<T>) => {\n\t\tif (!called) {\n\t\t\tcalled = true;\n\t\t\tfn(...params);\n\t\t}\n\t};\n};\n\nexport { once };\n","const { max, sin, cos, PI } = Math;\n\nconst random = (min: number, max: number) => {\n\treturn Math.random() * (max - min) + min;\n};\n\nconst clamp = (min: number, num: number, max: number) => {\n\treturn Math.max(min, Math.min(num, max));\n};\n\nconst TWO_PI = PI * 2;\nconst PI_OVER_TWO = PI / 2;\n\nexport { random, clamp };\nexport { max, sin, cos, PI, TWO_PI, PI_OVER_TWO };\n","import type { Variables } from './css-variables';\nimport type { Ticker } from '@novely/core';\nimport { PI, PI_OVER_TWO, TWO_PI, clamp, cos, max, random, sin } from './math';\n\nconst st = PI + PI / 6;\nconst ed = TWO_PI - PI / 6;\n\nconst createTarget = (start?: number) => {\n\tconst outerWidth = PI / 4;\n\tconst outerStart = start || random(st, ed - outerWidth);\n\tconst outerEnd = outerStart + outerWidth;\n\n\tconst innerWidth = PI / 12;\n\tconst innerStart = outerStart + outerWidth / 2 - innerWidth / 2;\n\tconst innerEnd = innerStart + innerWidth;\n\n\treturn {\n\t\touterStart,\n\t\touterWidth,\n\t\touterEnd,\n\n\t\tinnerStart,\n\t\tinnerWidth,\n\t\tinnerEnd,\n\t};\n};\n\nconst createRem = (fontSize: number) => {\n\tconst rem = (value: number) => {\n\t\t// Floor for performance reasons\n\t\treturn Math.floor(fontSize * value);\n\t};\n\n\treturn rem;\n};\n\nconst getAngle = (at: number) => {\n\treturn st + (ed - st) * at;\n};\n\nconst arc = (\n\tctx: CanvasRenderingContext2D,\n\tradius: number,\n\tstart: number,\n\tend: number,\n\twidth: number,\n\tcolor: string,\n) => {\n\tconst cx = ctx.canvas.width / 2;\n\tconst cy = ctx.canvas.height;\n\n\tctx.beginPath();\n\tctx.arc(cx, cy, radius, start, end);\n\tctx.lineWidth = width;\n\tctx.strokeStyle = color;\n\tctx.stroke();\n};\n\ntype RenderStaticCicleObjects = {\n\tvariables: Variables;\n\tfontSize: number;\n\n\tctx: CanvasRenderingContext2D;\n\n\tget: () => number | undefined;\n};\n\nconst renderStaticObjects = ({ ctx, fontSize, variables, get }: RenderStaticCicleObjects) => {\n\tconst { width: canvasWidth, height: canvasHeight } = ctx.canvas;\n\tconst { innerStart, innerEnd, outerStart, outerEnd } = createTarget(get());\n\tconst rem = createRem(fontSize);\n\n\tconst strokeWidth = rem(6.125);\n\n\tconst d = max(canvasWidth, canvasHeight);\n\tconst r = d / 2 - strokeWidth;\n\n\tconst cx = canvasWidth / 2;\n\tconst cy = canvasHeight;\n\n\t// Main Arc\n\tarc(ctx, r, PI, TWO_PI, strokeWidth, variables.mainArcBackground);\n\t// Inner Arc\n\tarc(ctx, r - strokeWidth / 2 - rem(0.313), PI, TWO_PI, rem(0.313), variables.innerArcBackground);\n\t// Outer Arc\n\tarc(ctx, r + strokeWidth / 2 + rem(0.313), PI, TWO_PI, rem(0.313), variables.outerArcBackground);\n\n\tconst pillarWidth = rem(0.25);\n\tconst pillarHeight = strokeWidth - rem(0.625);\n\n\tctx.fillStyle = variables.pillarBackground;\n\n\tfor (let i = 0; i < 7; i++) {\n\t\tctx.save();\n\n\t\tconst angle = getAngle(i / 6);\n\n\t\tctx.translate(cx + r * Math.cos(angle), cy + r * Math.sin(angle));\n\n\t\tctx.rotate(angle - PI_OVER_TWO);\n\n\t\tctx.beginPath();\n\t\tctx.roundRect(-pillarWidth / 2, -pillarHeight / 2, pillarWidth, pillarHeight, rem(0.313));\n\t\tctx.fill();\n\n\t\tctx.restore();\n\t}\n\n\t// Outer Golden\n\tarc(ctx, r, outerStart, outerEnd, strokeWidth, variables.wideMatchZoneBackground);\n\t// Inner Golden\n\tarc(ctx, r, innerStart, innerEnd, strokeWidth, variables.narrowMatchZoneBackground);\n};\n\ntype StartRenderOptions = {\n\tticker: Ticker;\n\n\tvariables: Variables;\n\tfontSize: number;\n\n\tpreview: boolean;\n\n\tctx: CanvasRenderingContext2D;\n\tstaticCtx: CanvasRenderingContext2D;\n\n\tset: (start: number) => void;\n\tget: () => number | undefined;\n};\n\nconst startRender = ({ ticker, preview, ctx, staticCtx, fontSize, variables, set, get }: StartRenderOptions) => {\n\tlet position = 0;\n\tlet direction: 'right' | 'left' = 'right';\n\n\tconst rem = createRem(fontSize);\n\n\tconst { innerStart, innerEnd, outerStart, outerEnd } = createTarget(get());\n\n\tset(outerStart);\n\n\trenderStaticObjects({\n\t\tvariables,\n\t\tfontSize,\n\n\t\tctx: staticCtx,\n\n\t\tget,\n\t});\n\n\t/**\n\t * 1. Pillar is not rendered\n\t * 2. Get state is always miss\n\t * 2.1 Should never be called\n\t * 2.2 Start position is zero, target zone is never zero\n\t */\n\tif (preview) {\n\t\treturn {\n\t\t\tcleanup: () => {},\n\t\t\tgetState: () => 'MISS' as const,\n\t\t};\n\t}\n\n\tconst strokeWidth = rem(6.125);\n\n\tconst cleanup = ticker.add((ticker) => {\n\t\tconst dtm = ticker.deltaTime / (1000 / 60);\n\n\t\tconst { width: canvasWidth, height: canvasHeight } = ctx.canvas;\n\n\t\tctx.clearRect(0, 0, canvasWidth, canvasHeight);\n\n\t\tconst d = max(canvasWidth, canvasHeight);\n\t\tconst r = d / 2 - strokeWidth;\n\n\t\tconst cx = canvasWidth / 2;\n\t\tconst cy = canvasHeight;\n\n\t\tconst pillarWidth = rem(0.25);\n\t\tconst pillarHeight = strokeWidth - rem(0.625);\n\n\t\t/**\n\t\t * Aim\n\t\t */\n\t\tctx.fillStyle = variables.aimBackground;\n\n\t\tctx.save();\n\n\t\tdirection = position >= 1 ? 'left' : position <= 0 ? 'right' : direction;\n\n\t\tconst angle = getAngle(position);\n\n\t\tctx.translate(cx + r * cos(angle), cy + r * sin(angle));\n\n\t\tctx.rotate(angle - PI_OVER_TWO);\n\n\t\tctx.beginPath();\n\t\tctx.roundRect(-pillarWidth / 2, -pillarHeight / 2, pillarWidth * 3, pillarHeight, rem(0.313));\n\t\tctx.fill();\n\n\t\tctx.restore();\n\n\t\tconst change = dtm * (direction === 'right' ? 0.01 : -0.01);\n\n\t\tposition = clamp(0, position + change, 1);\n\t});\n\n\tticker.start();\n\n\tconst getState = () => {\n\t\tconst angle = getAngle(position);\n\n\t\tif (angle >= innerStart && angle <= innerEnd) {\n\t\t\treturn 'PERFECT';\n\t\t}\n\n\t\tif (angle >= outerStart && angle <= outerEnd) {\n\t\t\treturn 'PASS';\n\t\t}\n\n\t\treturn 'MISS';\n\t};\n\n\treturn {\n\t\tcleanup,\n\t\tgetState,\n\t};\n};\n\nexport { startRender, renderStaticObjects };\n","import type { CustomHandler, Lang, State, StateFunction, EngineTypes } from '@novely/core';\nimport { createButton } from './button';\nimport { parseVariables } from './css-variables';\nimport { once } from './once';\nimport { startRender } from './render';\n\nconst MOMENT_PRESSER_ID = Symbol();\n\ntype MomentPresserOptions<$Lang extends Lang, $State extends State> = {\n\ttranslation?: {\n\t\t[L in $Lang & string]: {\n\t\t\tstop: string;\n\t\t};\n\t};\n\n\tonPressed?: (state: StateFunction<$State>, pressState: 'PERFECT' | 'PASS' | 'MISS') => void;\n};\n\nconst momentPresser = (options: MomentPresserOptions<Lang, State> = {}) => {\n\tconst fn: CustomHandler = ({ getDomNodes, clear, remove, state, ticker, lang, flags: { preview } }) => {\n\t\tconst { promise, resolve } = Promise.withResolvers<void>();\n\n\t\tconst { element } = getDomNodes(true);\n\n\t\tconst canvas = document.createElement('canvas');\n\t\tconst staticCanvas = document.createElement('canvas');\n\n\t\tconst ctx = canvas.getContext('2d');\n\t\tconst staticCtx = staticCanvas.getContext('2d');\n\n\t\tif (!ctx || !staticCtx) return;\n\n\t\tconst root = document.createElement('div');\n\t\troot.className = 'moment-presser-root';\n\n\t\telement.appendChild(root);\n\n\t\tcanvas.width = staticCanvas.width = root.getBoundingClientRect().width * devicePixelRatio;\n\t\tcanvas.height = staticCanvas.height = canvas.width / 2;\n\n\t\t/**\n\t\t * Позиционируем так, чтобы не перекрывался бегунок\n\t\t */\n\t\tstaticCanvas.style.zIndex = '-1';\n\n\t\tconst button = createButton({\n\t\t\tlabel: options.translation ? options.translation[lang].stop : 'Stop',\n\t\t});\n\n\t\troot.appendChild(canvas);\n\t\troot.appendChild(staticCanvas);\n\t\troot.appendChild(button);\n\n\t\tconst fontSize = Number.parseFloat(getComputedStyle(element).fontSize);\n\t\tconst variables = parseVariables(element);\n\n\t\tconst renderer = startRender({\n\t\t\tticker,\n\n\t\t\tvariables,\n\t\t\tfontSize,\n\n\t\t\tpreview,\n\n\t\t\tctx,\n\t\t\tstaticCtx,\n\n\t\t\tset: (start) => {\n\t\t\t\tstate({ $$momentPresserStart: start });\n\t\t\t},\n\t\t\tget: () => {\n\t\t\t\treturn state().$$momentPresserStart;\n\t\t\t},\n\t\t});\n\n\t\tconst cleanup = once(() => {\n\t\t\tticker.stop();\n\t\t\trenderer.cleanup();\n\n\t\t\tbutton.removeEventListener('click', onButtonClick);\n\n\t\t\troot.remove();\n\t\t\tcanvas.remove();\n\t\t\tstaticCanvas.remove();\n\t\t\tbutton.remove();\n\t\t});\n\n\t\tconst onButtonClick = once(() => {\n\t\t\tif (preview) return;\n\n\t\t\toptions.onPressed?.(state, renderer.getState());\n\n\t\t\tstate({ $$momentPresserStart: undefined });\n\n\t\t\tcleanup();\n\t\t\tresolve();\n\n\t\t\tremove();\n\t\t});\n\n\t\tbutton.addEventListener('click', onButtonClick);\n\n\t\tclear(cleanup);\n\n\t\tif (preview) {\n\t\t\tresolve();\n\t\t}\n\n\t\treturn promise;\n\t};\n\n\tfn.id = MOMENT_PRESSER_ID;\n\tfn.key = 'moment-presser';\n\tfn.requireUserAction = true;\n\tfn.callOnlyLatest = true;\n\n\treturn fn;\n};\n\ntype CreateMomentPresserOptions<T> = T extends EngineTypes<infer $Lang, infer $State, any, any>\n\t? MomentPresserOptions<$Lang, $State>\n\t: never;\n\nconst createMomentPresser = <T>(options: CreateMomentPresserOptions<T>) => {\n\treturn momentPresser(options);\n};\n\nexport { createMomentPresser };\nexport type { MomentPresserOptions, CreateMomentPresserOptions };\n"],"mappings":"AAAA,IAAMA,EAAYC,GAAiB,CAClC,IAAMC,EAAI,SAAS,cAAc,UAAU,EAE3C,OAAAA,EAAE,UAAYD,EAEPC,EAAE,QAAQ,UAClB,EAMMC,EAAe,CAAC,CAAE,MAAAC,CAAM,IAA2B,CAIxD,IAAMH,EAAO,yIAAyIG,CAAK,oWAAoWA,CAAK,gBAEpgB,OAAOJ,EAASC,CAAI,CACrB,ECTA,IAAMI,EAAkBC,GAAyB,CAChD,IAAMC,EAAQ,iBAAiBD,CAAO,EAEhCE,EAAM,CAACC,EAAkBC,IACvBH,EAAM,iBAAiBE,CAAQ,E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","html","t","createButton","label","parseVariables","element","style","get","property","fallback","once","fn","called","params","max","sin","cos","PI","random","min","clamp","num","TWO_PI","PI_OVER_TWO","st","PI","ed","TWO_PI","createTarget","start","outerWidth","outerStart","random","outerEnd","innerWidth","innerStart","innerEnd","createRem","fontSize","value","getAngle","at","arc","ctx","radius","end","width","color","cx","cy","renderStaticObjects","variables","get","canvasWidth","canvasHeight","rem","strokeWidth","r","max","pillarWidth","pillarHeight","i","angle","PI_OVER_TWO","startRender","ticker","preview","staticCtx","set","position","direction","cleanup","dtm","cos","sin","change","clamp","MOMENT_PRESSER_ID","momentPresser","options","fn","getDomNodes","clear","remove","state","ticker","lang","preview","promise","resolve","element","canvas","staticCanvas","ctx","staticCtx","root","button","createButton","fontSize","variables","parseVariables","renderer","startRender","start","cleanup","once","onButtonClick","createMomentPresser"]}
|