Skip to content

Commit

Permalink
Add checks to prevent breaking when running in the server
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-script committed Mar 4, 2022
1 parent e49d444 commit c605bb5
Show file tree
Hide file tree
Showing 20 changed files with 215 additions and 147 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"indent": ["error", 2, { "SwitchCase": 1 }],
"semi": ["error", "always"],
"lines-between-class-members": ["error", "always"],
"tsdoc/syntax": "warn"
"tsdoc/syntax": "warn",
"no-constant-condition": "off"
},
"ignorePatterns": [
"rollup.config.js",
Expand Down
2 changes: 1 addition & 1 deletion demo/demo1.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<canvas></canvas>
<pre></pre>
</body>
<script src="../dist/bundle.js"></script>
<script src="../dist/bundle.browser.js"></script>
<script>
(async () => {
const FFT_SIZE = 1024 * 2
Expand Down
2 changes: 1 addition & 1 deletion demo/demo2.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<canvas></canvas>
<pre></pre>
</body>
<script src="../dist/bundle.js"></script>
<script src="../dist/bundle.browser.js"></script>
<script>
(async () => {
const FFT_SIZE = 1024 * 2
Expand Down
35 changes: 21 additions & 14 deletions dist/bundle.js → dist/bundle.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.min.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions dist/bundle.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.advancedAnalyserNode = {}));
})(this, (function (exports) { 'use strict';

/*
* The path below is not an external module. It's an alias (defined in tsconfig.json) to ./dist/processor.worklet.js
* The AudioWorkletProcessor is bundled first, and later imported here to be bundled as a base64 string,
* to avoid needing to be manually imported and loaded by this module's consumers
*/
const createAdvancedAnalyserNode = async (context, options = {}) => {
{
throw new Error(`
AudioWorkletNode does not exist in this environment:
This typically happens if you try to run 'createAdvancedAnalyserNode' in the server
`);
}
};

exports.createAdvancedAnalyserNode = createAdvancedAnalyserNode;

Object.defineProperty(exports, '__esModule', { value: true });

}));
5 changes: 2 additions & 3 deletions dist/src/node/create-advanced-analyser.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import { AdvancedAnalyserNodeProperties } from 'src/types';
import { AdvancedAnalyserNode } from './advanced-analyser-node';
export declare const createAdvancedAnalyserNode: (context: BaseAudioContext, options?: AdvancedAnalyserNodeProperties) => Promise<AdvancedAnalyserNode>;
import { AdvancedAnalyserNodeProperties } from '../types';
export declare const createAdvancedAnalyserNode: (context: BaseAudioContext, options?: AdvancedAnalyserNodeProperties) => Promise<import("./advanced-analyser-node").AdvancedAnalyserNode>;
2 changes: 1 addition & 1 deletion dist/src/node/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './create-advanced-analyser';
export * from './advanced-analyser-node';
export { type AdvancedAnalyserNode } from './advanced-analyser-node';
10 changes: 5 additions & 5 deletions docs/DOC.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
advanced-analyser-node
@audioui/advanced-analyser-node

# advanced-analyser-node
# @audioui/advanced-analyser-node

## Table of contents

Expand Down Expand Up @@ -41,13 +41,13 @@ advanced-analyser-node

#### Defined in

[src/types.ts:163](https://github.com/ju-faria/advanced-analyser-node/blob/bc691c4/src/types.ts#L163)
[src/types.ts:163](https://github.com/ju-faria/advanced-analyser-node/blob/e49d444/src/types.ts#L163)

## Functions

### createAdvancedAnalyserNode

**createAdvancedAnalyserNode**(`context`, `options`): `Promise`<[`AdvancedAnalyserNode`](classes/AdvancedAnalyserNode.md)\>
**createAdvancedAnalyserNode**(`context`, `options?`): `Promise`<[`AdvancedAnalyserNode`](classes/AdvancedAnalyserNode.md)\>

#### Parameters

Expand All @@ -62,4 +62,4 @@ advanced-analyser-node

#### Defined in

[src/node/create-advanced-analyser.ts:10](https://github.com/ju-faria/advanced-analyser-node/blob/bc691c4/src/node/create-advanced-analyser.ts#L10)
[src/node/create-advanced-analyser.ts:9](https://github.com/ju-faria/advanced-analyser-node/blob/e49d444/src/node/create-advanced-analyser.ts#L9)
Loading

0 comments on commit c605bb5

Please sign in to comment.