@grame/faustwasm 0.13.0 → 0.13.1
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 +2 -2
- package/assets/standalone/faustwasm/index.js +33 -14
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.js +33 -14
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.js +33 -14
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.js +33 -14
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.js +33 -14
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +53 -25
- package/test/faustlive-wasm/faustwasm/index.js +33 -14
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/web/create-faust-node.js +4 -9
package/package.json
CHANGED
package/src/FaustDspGenerator.ts
CHANGED
|
@@ -1123,32 +1123,60 @@ export class FaustDspGenerator implements IFaustDspGenerator {
|
|
|
1123
1123
|
): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null> {
|
|
1124
1124
|
const getCompiler = async () => {
|
|
1125
1125
|
if (!FaustDspGenerator.compilerPromise) {
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1126
|
+
const isNode =
|
|
1127
|
+
typeof document === 'undefined' && typeof window === 'undefined';
|
|
1128
|
+
if (isNode) {
|
|
1129
|
+
// Resolve assets relative to this file when running in Node.
|
|
1130
|
+
const baseURL =
|
|
1131
|
+
(typeof __dirname !== 'undefined'
|
|
1132
|
+
? `file://${__dirname}/`
|
|
1133
|
+
: undefined) ||
|
|
1134
|
+
(typeof import.meta !== 'undefined' &&
|
|
1135
|
+
typeof import.meta.url === 'string'
|
|
1136
|
+
? import.meta.url
|
|
1137
|
+
: undefined);
|
|
1138
|
+
if (!baseURL)
|
|
1139
|
+
throw new Error('Cannot resolve libfaust-wasm location.');
|
|
1140
|
+
const jsURL = new URL(
|
|
1141
|
+
'../libfaust-wasm/libfaust-wasm.js',
|
|
1142
|
+
baseURL
|
|
1143
1143
|
).href;
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1144
|
+
const dataURL = jsURL.replace(/c?js$/, 'data');
|
|
1145
|
+
const wasmURL = jsURL.replace(/c?js$/, 'wasm');
|
|
1146
|
+
FaustDspGenerator.compilerPromise =
|
|
1147
|
+
instantiateFaustModuleFromFile(
|
|
1148
|
+
jsURL,
|
|
1149
|
+
dataURL,
|
|
1150
|
+
wasmURL
|
|
1151
|
+
).then((module) => new FaustCompiler(new LibFaust(module)));
|
|
1152
|
+
} else {
|
|
1153
|
+
// Resolve libfaust-wasm assets relative to current script/page location (works in browser and bundlers).
|
|
1154
|
+
// Falling back to document/baseURI keeps things working when import.meta.url is unavailable (es2019 target).
|
|
1155
|
+
const baseURL =
|
|
1156
|
+
(typeof document !== 'undefined'
|
|
1157
|
+
? ('src' in (document.currentScript || {})
|
|
1158
|
+
? (document.currentScript as HTMLScriptElement)
|
|
1159
|
+
.src
|
|
1160
|
+
: document.baseURI)
|
|
1161
|
+
: undefined) ||
|
|
1162
|
+
(typeof window !== 'undefined'
|
|
1163
|
+
? window.location.href
|
|
1164
|
+
: undefined);
|
|
1165
|
+
if (!baseURL)
|
|
1166
|
+
throw new Error('Cannot resolve libfaust-wasm location.');
|
|
1167
|
+
const jsURL = new URL(
|
|
1168
|
+
'../libfaust-wasm/libfaust-wasm.js',
|
|
1169
|
+
baseURL
|
|
1170
|
+
).href;
|
|
1171
|
+
const dataURL = jsURL.replace(/c?js$/, 'data');
|
|
1172
|
+
const wasmURL = jsURL.replace(/c?js$/, 'wasm');
|
|
1173
|
+
FaustDspGenerator.compilerPromise =
|
|
1174
|
+
instantiateFaustModuleFromFile(
|
|
1175
|
+
jsURL,
|
|
1176
|
+
dataURL,
|
|
1177
|
+
wasmURL
|
|
1178
|
+
).then((module) => new FaustCompiler(new LibFaust(module)));
|
|
1179
|
+
}
|
|
1152
1180
|
}
|
|
1153
1181
|
return FaustDspGenerator.compilerPromise;
|
|
1154
1182
|
};
|
|
@@ -5192,6 +5192,7 @@ var FaustPolyScriptProcessorNode = class extends FaustScriptProcessorNode {
|
|
|
5192
5192
|
};
|
|
5193
5193
|
|
|
5194
5194
|
// src/FaustDspGenerator.ts
|
|
5195
|
+
var import_meta = {};
|
|
5195
5196
|
var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
5196
5197
|
constructor() {
|
|
5197
5198
|
this.factory = null;
|
|
@@ -5840,20 +5841,38 @@ var _FaustDspGenerator = class _FaustDspGenerator {
|
|
|
5840
5841
|
async createFaustNode(context, name, code, sp, bufferSize) {
|
|
5841
5842
|
const getCompiler = async () => {
|
|
5842
5843
|
if (!_FaustDspGenerator.compilerPromise) {
|
|
5843
|
-
const
|
|
5844
|
-
if (
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
jsURL
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5844
|
+
const isNode = typeof document === "undefined" && typeof window === "undefined";
|
|
5845
|
+
if (isNode) {
|
|
5846
|
+
const baseURL = (typeof __dirname !== "undefined" ? `file://${__dirname}/` : void 0) || (typeof import_meta !== "undefined" && typeof import_meta.url === "string" ? import_meta.url : void 0);
|
|
5847
|
+
if (!baseURL)
|
|
5848
|
+
throw new Error("Cannot resolve libfaust-wasm location.");
|
|
5849
|
+
const jsURL = new URL(
|
|
5850
|
+
"../libfaust-wasm/libfaust-wasm.js",
|
|
5851
|
+
baseURL
|
|
5852
|
+
).href;
|
|
5853
|
+
const dataURL = jsURL.replace(/c?js$/, "data");
|
|
5854
|
+
const wasmURL = jsURL.replace(/c?js$/, "wasm");
|
|
5855
|
+
_FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
|
|
5856
|
+
jsURL,
|
|
5857
|
+
dataURL,
|
|
5858
|
+
wasmURL
|
|
5859
|
+
).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
|
|
5860
|
+
} else {
|
|
5861
|
+
const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
|
|
5862
|
+
if (!baseURL)
|
|
5863
|
+
throw new Error("Cannot resolve libfaust-wasm location.");
|
|
5864
|
+
const jsURL = new URL(
|
|
5865
|
+
"../libfaust-wasm/libfaust-wasm.js",
|
|
5866
|
+
baseURL
|
|
5867
|
+
).href;
|
|
5868
|
+
const dataURL = jsURL.replace(/c?js$/, "data");
|
|
5869
|
+
const wasmURL = jsURL.replace(/c?js$/, "wasm");
|
|
5870
|
+
_FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
|
|
5871
|
+
jsURL,
|
|
5872
|
+
dataURL,
|
|
5873
|
+
wasmURL
|
|
5874
|
+
).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
|
|
5875
|
+
}
|
|
5857
5876
|
}
|
|
5858
5877
|
return _FaustDspGenerator.compilerPromise;
|
|
5859
5878
|
};
|