@mulsense/xnew 0.1.7 → 0.1.8

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.
@@ -9,7 +9,7 @@
9
9
  xnew.extend(Root, { engine });
10
10
  },
11
11
  nest(object) {
12
- xnew.extend(Nest, object);
12
+ xnew.extend(Nest, { object });
13
13
  return object;
14
14
  },
15
15
  get engine() {
@@ -22,22 +22,20 @@
22
22
  xnew.context('xmatter.root', root);
23
23
  root.isActive = true;
24
24
  root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
25
- xnew.extend(Nest, root.engine.world);
25
+ xnew.context('xmatter.object', root.engine.world);
26
26
  self.on('update', () => {
27
27
  if (root.isActive) {
28
28
  Matter.Engine.update(root.engine);
29
29
  }
30
30
  });
31
31
  }
32
- function Nest(self, object) {
32
+ function Nest(self, { object }) {
33
33
  const parent = xnew.context('xmatter.object');
34
34
  xnew.context('xmatter.object', object);
35
- if (parent) {
36
- Matter.Composite.add(parent, object);
37
- self.on('finalize', () => {
38
- Matter.Composite.remove(parent, object);
39
- });
40
- }
35
+ Matter.Composite.add(parent, object);
36
+ self.on('finalize', () => {
37
+ Matter.Composite.remove(parent, object);
38
+ });
41
39
  }
42
40
 
43
41
  return xmatter;
@@ -6,7 +6,7 @@ var xmatter = {
6
6
  xnew.extend(Root, { engine });
7
7
  },
8
8
  nest(object) {
9
- xnew.extend(Nest, object);
9
+ xnew.extend(Nest, { object });
10
10
  return object;
11
11
  },
12
12
  get engine() {
@@ -19,22 +19,20 @@ function Root(self, { engine }) {
19
19
  xnew.context('xmatter.root', root);
20
20
  root.isActive = true;
21
21
  root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
22
- xnew.extend(Nest, root.engine.world);
22
+ xnew.context('xmatter.object', root.engine.world);
23
23
  self.on('update', () => {
24
24
  if (root.isActive) {
25
25
  Matter.Engine.update(root.engine);
26
26
  }
27
27
  });
28
28
  }
29
- function Nest(self, object) {
29
+ function Nest(self, { object }) {
30
30
  const parent = xnew.context('xmatter.object');
31
31
  xnew.context('xmatter.object', object);
32
- if (parent) {
33
- Matter.Composite.add(parent, object);
34
- self.on('finalize', () => {
35
- Matter.Composite.remove(parent, object);
36
- });
37
- }
32
+ Matter.Composite.add(parent, object);
33
+ self.on('finalize', () => {
34
+ Matter.Composite.remove(parent, object);
35
+ });
38
36
  }
39
37
 
40
38
  export { xmatter as default };
@@ -28,7 +28,7 @@
28
28
  xnew.extend(Root, { renderer, canvas });
29
29
  },
30
30
  nest(object) {
31
- xnew.extend(Nest, object);
31
+ xnew.extend(Nest, { object });
32
32
  return object;
33
33
  },
34
34
  sync(canvas) {
@@ -78,15 +78,13 @@
78
78
  }
79
79
  });
80
80
  }
81
- function Nest(self, object) {
81
+ function Nest(self, { object }) {
82
82
  const parent = xnew.context('xpixi.object');
83
83
  xnew.context('xpixi.object', object);
84
- if (parent) {
85
- parent.addChild(object);
86
- self.on('finalize', () => {
87
- parent.removeChild(object);
88
- });
89
- }
84
+ parent.addChild(object);
85
+ self.on('finalize', () => {
86
+ parent.removeChild(object);
87
+ });
90
88
  }
91
89
  function PreUpdate(self, callback) {
92
90
  const root = xnew.context('xpixi.root');
@@ -6,7 +6,7 @@ var xpixi = {
6
6
  xnew.extend(Root, { renderer, canvas });
7
7
  },
8
8
  nest(object) {
9
- xnew.extend(Nest, object);
9
+ xnew.extend(Nest, { object });
10
10
  return object;
11
11
  },
12
12
  sync(canvas) {
@@ -56,15 +56,13 @@ function Root(self, { canvas }) {
56
56
  }
57
57
  });
58
58
  }
59
- function Nest(self, object) {
59
+ function Nest(self, { object }) {
60
60
  const parent = xnew.context('xpixi.object');
61
61
  xnew.context('xpixi.object', object);
62
- if (parent) {
63
- parent.addChild(object);
64
- self.on('finalize', () => {
65
- parent.removeChild(object);
66
- });
67
- }
62
+ parent.addChild(object);
63
+ self.on('finalize', () => {
64
+ parent.removeChild(object);
65
+ });
68
66
  }
69
67
  function PreUpdate(self, callback) {
70
68
  const root = xnew.context('xpixi.root');
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  initialize({ gravity, timestep }?: any): void;
3
- nest(object: any): any;
3
+ connect(type: any, object: any): any;
4
4
  readonly world: any;
5
5
  };
6
6
  export default _default;
@@ -8,8 +8,8 @@
8
8
  initialize({ gravity = { x: 0.0, y: 9.81 }, timestep = null } = {}) {
9
9
  xnew.extend(Root, { gravity, timestep });
10
10
  },
11
- nest(object) {
12
- xnew.extend(Nest, object);
11
+ connect(type, object) {
12
+ xnew.extend(Connect, { type, object });
13
13
  return object;
14
14
  },
15
15
  get world() {
@@ -25,7 +25,7 @@
25
25
  if (timestep !== null) {
26
26
  root.world.timestep = timestep;
27
27
  }
28
- xnew.extend(Nest, root.world);
28
+ // xnew.extend(Nest, root.world);
29
29
  });
30
30
  self.on('update', () => {
31
31
  if (root.world) {
@@ -33,32 +33,35 @@
33
33
  }
34
34
  });
35
35
  }
36
- function Nest(self, object) {
37
- const parent = xnew.context('xrapier2d.object');
38
- xnew.context('xrapier2d.object', object);
39
- if (parent) {
40
- // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
41
- // when created, so we only need to handle removal on finalize
42
- self.on('finalize', () => {
43
- try {
44
- // Check if object is a RigidBody
45
- if (object.translation && typeof object.translation === 'function') {
46
- parent.removeRigidBody(object);
47
- }
48
- // Check if object is a Collider
49
- else if (object.shape && typeof object.shape === 'function') {
50
- parent.removeCollider(object);
51
- }
52
- // Check if object is an ImpulseJoint
53
- else if (object.impulse !== undefined) {
54
- parent.removeImpulseJoint(object);
55
- }
36
+ let count = 0;
37
+ function Connect(self, { type, object }) {
38
+ const root = xnew.context('xrapier2d.root');
39
+ let temp = count++;
40
+ console.log(temp, type, object);
41
+ // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
42
+ // when created, so we only need to handle removal on finalize
43
+ self.on('finalize', () => {
44
+ try {
45
+ // Check if object is a RigidBody
46
+ if (type === 'rigidBody') {
47
+ console.log('Removing RigidBody');
48
+ root.world.removeRigidBody(object);
56
49
  }
57
- catch (e) {
58
- // Object may have already been removed
50
+ // Check if object is a Collider
51
+ else if (type === 'collider') {
52
+ console.log('Removing Collider');
53
+ root.world.removeCollider(object);
59
54
  }
60
- });
61
- }
55
+ // Check if object is an ImpulseJoint
56
+ else if (type === 'impulseJoint') {
57
+ console.log('Removing ImpulseJoint');
58
+ root.world.removeImpulseJoint(object);
59
+ }
60
+ }
61
+ catch (e) {
62
+ // Object may have already been removed
63
+ }
64
+ });
62
65
  }
63
66
 
64
67
  return xrapier2d;
@@ -5,8 +5,8 @@ var xrapier2d = {
5
5
  initialize({ gravity = { x: 0.0, y: 9.81 }, timestep = null } = {}) {
6
6
  xnew.extend(Root, { gravity, timestep });
7
7
  },
8
- nest(object) {
9
- xnew.extend(Nest, object);
8
+ connect(type, object) {
9
+ xnew.extend(Connect, { type, object });
10
10
  return object;
11
11
  },
12
12
  get world() {
@@ -22,7 +22,7 @@ function Root(self, { gravity, timestep }) {
22
22
  if (timestep !== null) {
23
23
  root.world.timestep = timestep;
24
24
  }
25
- xnew.extend(Nest, root.world);
25
+ // xnew.extend(Nest, root.world);
26
26
  });
27
27
  self.on('update', () => {
28
28
  if (root.world) {
@@ -30,32 +30,35 @@ function Root(self, { gravity, timestep }) {
30
30
  }
31
31
  });
32
32
  }
33
- function Nest(self, object) {
34
- const parent = xnew.context('xrapier2d.object');
35
- xnew.context('xrapier2d.object', object);
36
- if (parent) {
37
- // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
38
- // when created, so we only need to handle removal on finalize
39
- self.on('finalize', () => {
40
- try {
41
- // Check if object is a RigidBody
42
- if (object.translation && typeof object.translation === 'function') {
43
- parent.removeRigidBody(object);
44
- }
45
- // Check if object is a Collider
46
- else if (object.shape && typeof object.shape === 'function') {
47
- parent.removeCollider(object);
48
- }
49
- // Check if object is an ImpulseJoint
50
- else if (object.impulse !== undefined) {
51
- parent.removeImpulseJoint(object);
52
- }
33
+ let count = 0;
34
+ function Connect(self, { type, object }) {
35
+ const root = xnew.context('xrapier2d.root');
36
+ let temp = count++;
37
+ console.log(temp, type, object);
38
+ // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
39
+ // when created, so we only need to handle removal on finalize
40
+ self.on('finalize', () => {
41
+ try {
42
+ // Check if object is a RigidBody
43
+ if (type === 'rigidBody') {
44
+ console.log('Removing RigidBody');
45
+ root.world.removeRigidBody(object);
53
46
  }
54
- catch (e) {
55
- // Object may have already been removed
47
+ // Check if object is a Collider
48
+ else if (type === 'collider') {
49
+ console.log('Removing Collider');
50
+ root.world.removeCollider(object);
56
51
  }
57
- });
58
- }
52
+ // Check if object is an ImpulseJoint
53
+ else if (type === 'impulseJoint') {
54
+ console.log('Removing ImpulseJoint');
55
+ root.world.removeImpulseJoint(object);
56
+ }
57
+ }
58
+ catch (e) {
59
+ // Object may have already been removed
60
+ }
61
+ });
59
62
  }
60
63
 
61
64
  export { xrapier2d as default };
@@ -28,7 +28,7 @@
28
28
  xnew.extend(Root, { renderer, canvas, camera });
29
29
  },
30
30
  nest(object) {
31
- xnew.extend(Nest, object);
31
+ xnew.extend(Nest, { object });
32
32
  return object;
33
33
  },
34
34
  get renderer() {
@@ -61,7 +61,7 @@
61
61
  root.renderer.render(root.scene, root.camera);
62
62
  });
63
63
  }
64
- function Nest(self, object) {
64
+ function Nest(self, { object }) {
65
65
  const parent = xnew.context('xthree.object');
66
66
  xnew.context('xthree.object', object);
67
67
  if (parent) {
@@ -6,7 +6,7 @@ var xthree = {
6
6
  xnew.extend(Root, { renderer, canvas, camera });
7
7
  },
8
8
  nest(object) {
9
- xnew.extend(Nest, object);
9
+ xnew.extend(Nest, { object });
10
10
  return object;
11
11
  },
12
12
  get renderer() {
@@ -39,7 +39,7 @@ function Root(self, { canvas, camera }) {
39
39
  root.renderer.render(root.scene, root.camera);
40
40
  });
41
41
  }
42
- function Nest(self, object) {
42
+ function Nest(self, { object }) {
43
43
  const parent = xnew.context('xthree.object');
44
44
  xnew.context('xthree.object', object);
45
45
  if (parent) {
@@ -1,19 +1,2 @@
1
1
  export declare const context: AudioContext;
2
2
  export declare const master: GainNode;
3
- export declare class AudioNodeClass {
4
- nodes: {
5
- [key: string]: AudioNode & {
6
- [key: string]: any;
7
- };
8
- };
9
- constructor(params: {
10
- [key: string]: any[];
11
- });
12
- cleanup(): void;
13
- }
14
- export type AudioNodeMap = {
15
- [key: string]: AudioNode;
16
- };
17
- export declare function connect(params: {
18
- [key: string]: any[];
19
- }): AudioNodeMap;
@@ -0,0 +1,12 @@
1
+ export declare function load(path: string): AudioFile;
2
+ declare class AudioFile {
3
+ buffer?: AudioBuffer;
4
+ promise: Promise<void>;
5
+ source?: AudioBufferSourceNode;
6
+ amp?: GainNode;
7
+ start: number | null;
8
+ constructor(path: string);
9
+ play(offset?: number, loop?: boolean): void;
10
+ pause(): number | undefined;
11
+ }
12
+ export {};
@@ -1,16 +1,12 @@
1
- import { AudioNodeMap } from './audio';
2
1
  export declare function load(path: string): AudioFile;
3
2
  declare class AudioFile {
4
3
  data: any;
5
4
  startTime: number | null;
6
- nodes: AudioNodeMap;
5
+ source: AudioBufferSourceNode;
6
+ amp: GainNode;
7
7
  constructor(path: string);
8
8
  isReady(): boolean;
9
9
  get promise(): Promise<void>;
10
- set volume(value: number);
11
- get volume(): number;
12
- set loop(value: boolean);
13
- get loop(): boolean;
14
10
  play(offset?: number): void;
15
11
  pause(): number | undefined;
16
12
  }
@@ -1,11 +1,26 @@
1
+ export declare function synthesizer(props: SynthProps): Synthesizer;
1
2
  type SynthProps = {
2
- oscillator?: OscillatorOptions | null;
3
- filter?: FilterOptions | null;
4
- amp?: AmpOptions | null;
3
+ oscillator: OscillatorOptions;
4
+ amp: AmpOptions;
5
+ filter?: FilterOptions;
6
+ reverb?: ReverbOptions;
7
+ bpm?: number;
8
+ };
9
+ type OscillatorOptions = {
10
+ type: OscillatorType;
11
+ envelope?: Envelope;
12
+ LFO?: LFO;
5
13
  };
6
- type SynthEffects = {
7
- bmp?: number | null;
8
- reverb?: ReverbOptions | null;
14
+ type FilterOptions = {
15
+ type: BiquadFilterType;
16
+ cutoff: number;
17
+ };
18
+ type AmpOptions = {
19
+ envelope: Envelope;
20
+ };
21
+ type ReverbOptions = {
22
+ time: number;
23
+ mix: number;
9
24
  };
10
25
  type Envelope = {
11
26
  amount: number;
@@ -16,39 +31,11 @@ type LFO = {
16
31
  type: OscillatorType;
17
32
  rate: number;
18
33
  };
19
- type OscillatorOptions = {
20
- type?: OscillatorType;
21
- envelope?: Envelope | null;
22
- LFO?: LFO | null;
23
- };
24
- type FilterOptions = {
25
- type?: BiquadFilterType;
26
- cutoff?: number;
27
- };
28
- type AmpOptions = {
29
- envelope?: Envelope | null;
30
- };
31
- type ReverbOptions = {
32
- time?: number;
33
- mix?: number;
34
- };
35
- export declare function synthesizer(props?: SynthProps, effects?: SynthEffects): Synthesizer;
36
34
  declare class Synthesizer {
37
- oscillator: OscillatorOptions;
38
- filter: FilterOptions;
39
- amp: AmpOptions;
40
- bmp: number;
41
- reverb: ReverbOptions;
42
- static initialize(): void;
43
- constructor({ oscillator, filter, amp }?: SynthProps, { bmp, reverb }?: SynthEffects);
44
- static keymap: {
45
- [key: string]: number;
46
- };
47
- static notemap: {
48
- [key: string]: number;
49
- };
50
- press(frequency: number | string, duration?: number | string | null, wait?: number): {
35
+ props: SynthProps;
36
+ constructor(props: SynthProps);
37
+ press(frequency: number | string, duration?: number | string, wait?: number): {
51
38
  release: () => void;
52
- };
39
+ } | undefined;
53
40
  }
54
41
  export {};
@@ -1,5 +1,5 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function AccordionFrame(frame: xnew.Unit, { open, duration, easing }?: {
1
+ import { Unit } from '../core/unit';
2
+ export declare function AccordionFrame(frame: Unit, { open, duration, easing }?: {
3
3
  open?: boolean;
4
4
  duration?: number;
5
5
  easing?: string;
@@ -8,11 +8,11 @@ export declare function AccordionFrame(frame: xnew.Unit, { open, duration, easin
8
8
  open(): void;
9
9
  close(): void;
10
10
  };
11
- export declare function AccordionHeader(header: xnew.Unit, {}?: {}): void;
12
- export declare function AccordionBullet(bullet: xnew.Unit, { type }?: {
11
+ export declare function AccordionHeader(header: Unit, {}?: {}): void;
12
+ export declare function AccordionBullet(bullet: Unit, { type }?: {
13
13
  type?: string;
14
14
  }): void;
15
- export declare function AccordionContent(content: xnew.Unit, {}?: {}): {
15
+ export declare function AccordionContent(content: Unit, {}?: {}): {
16
16
  transition({ element, rate }: {
17
17
  element: HTMLElement;
18
18
  rate: number;
@@ -1,5 +1,5 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function AnalogStick(self: xnew.Unit, { size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
1
+ import { Unit } from '../core/unit';
2
+ export declare function AnalogStick(self: Unit, { size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
3
3
  size?: number;
4
4
  diagonal?: boolean;
5
5
  fill?: string;
@@ -9,7 +9,7 @@ export declare function AnalogStick(self: xnew.Unit, { size, fill, fillOpacity,
9
9
  strokeWidth?: number;
10
10
  strokeLinejoin?: string;
11
11
  }): void;
12
- export declare function DirectionalPad(self: xnew.Unit, { size, diagonal, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
12
+ export declare function DirectionalPad(self: Unit, { size, diagonal, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
13
13
  size?: number;
14
14
  diagonal?: boolean;
15
15
  fill?: string;
@@ -19,7 +19,7 @@ export declare function DirectionalPad(self: xnew.Unit, { size, diagonal, fill,
19
19
  strokeWidth?: number;
20
20
  strokeLinejoin?: string;
21
21
  }): void;
22
- export declare function TouchButton(self: xnew.Unit, { size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
22
+ export declare function TouchButton(self: Unit, { size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
23
23
  size?: number | undefined;
24
24
  fill?: string | undefined;
25
25
  fillOpacity?: number | undefined;
@@ -1,6 +1,6 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function DragFrame(frame: xnew.Unit, { x, y }?: {
1
+ import { Unit } from '../core/unit';
2
+ export declare function DragFrame(frame: Unit, { x, y }?: {
3
3
  x?: number;
4
4
  y?: number;
5
5
  }): void;
6
- export declare function DragTarget(target: xnew.Unit, {}?: {}): void;
6
+ export declare function DragTarget(target: Unit, {}?: {}): void;
@@ -1,2 +1,2 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function InputFrame(frame: xnew.Unit, {}?: {}): void;
1
+ import { Unit } from '../core/unit';
2
+ export declare function InputFrame(frame: Unit, {}?: {}): void;
@@ -1,2 +1,2 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function KeyboardEvent(unit: xnew.Unit): void;
1
+ import { Unit } from '../core/unit';
2
+ export declare function KeyboardEvent(unit: Unit): void;
@@ -1,11 +1,11 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function ModalFrame(frame: xnew.Unit, { duration, easing }?: {
1
+ import { Unit } from '../core/unit';
2
+ export declare function ModalFrame(frame: Unit, { duration, easing }?: {
3
3
  duration?: number;
4
4
  easing?: string;
5
5
  }): {
6
6
  close(): void;
7
7
  };
8
- export declare function ModalContent(content: xnew.Unit, { background }?: {
8
+ export declare function ModalContent(content: Unit, { background }?: {
9
9
  background?: string;
10
10
  }): {
11
11
  transition({ element, rate }: {
@@ -1,2 +1,2 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function PointerEvent(unit: xnew.Unit): void;
1
+ import { Unit } from '../core/unit';
2
+ export declare function PointerEvent(unit: Unit): void;
@@ -1 +1,2 @@
1
- export declare function ResizeEvent(resize: any): void;
1
+ import { Unit } from '../core/unit';
2
+ export declare function ResizeEvent(resize: Unit): void;
@@ -1,9 +1,9 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function Screen(screen: xnew.Unit, { width, height, fit }?: {
1
+ import { Unit } from '../core/unit';
2
+ export declare function Screen(screen: Unit, { width, height, fit }?: {
3
3
  width?: number | undefined;
4
4
  height?: number | undefined;
5
5
  fit?: string | undefined;
6
6
  }): {
7
- readonly canvas: any;
7
+ readonly canvas: import("../core/unit").UnitElement;
8
8
  resize(width: number, height: number): void;
9
9
  };
@@ -1,8 +1,8 @@
1
- import { xnew } from '../core/xnew';
2
- export declare function TabFrame(frame: xnew.Unit, { select }?: {
1
+ import { Unit } from '../core/unit';
2
+ export declare function TabFrame(frame: Unit, { select }?: {
3
3
  select?: string;
4
4
  }): void;
5
- export declare function TabButton(button: xnew.Unit, { key }?: {
5
+ export declare function TabButton(button: Unit, { key }?: {
6
6
  key?: string;
7
7
  }): {
8
8
  select({ element }: {
@@ -12,7 +12,7 @@ export declare function TabButton(button: xnew.Unit, { key }?: {
12
12
  element: HTMLElement;
13
13
  }): void;
14
14
  };
15
- export declare function TabContent(content: xnew.Unit, { key }?: {
15
+ export declare function TabContent(content: Unit, { key }?: {
16
16
  key?: string;
17
17
  }): {
18
18
  select({ element }: {
@@ -1,10 +1,7 @@
1
1
  export declare class Ticker {
2
- static animation: number | null;
3
- static callbacks: Set<Function>;
4
- static previous: number;
5
- static ticker(): void;
6
- static set(callback: (time: number) => void): void;
7
- static clear(callback: (time: number) => void): void;
2
+ private id;
3
+ constructor(callback: Function);
4
+ clear(): void;
8
5
  }
9
6
  export declare class Timer {
10
7
  private timeout;
@@ -15,7 +12,7 @@ export declare class Timer {
15
12
  private time;
16
13
  private offset;
17
14
  private status;
18
- private visibilitychange?;
15
+ private visibilitychange;
19
16
  private ticker;
20
17
  constructor(timeout: Function, transition: Function | null, delay: number, loop?: boolean);
21
18
  clear(): void;