This commit is contained in:
Felix Roos 2022-03-18 22:01:21 +01:00
parent d973d56ef6
commit 1e57526d7e
5 changed files with 37 additions and 35 deletions

View File

@ -717,16 +717,6 @@ export function makeComposable(func) {
});
return func;
}
Pattern.prototype.define = (name, func, options = {}) => {
if (options.composable) {
Pattern.prototype.composable[name] = func;
}
if (options.patternified) {
Pattern.prototype.patternified = Pattern.prototype.patternified.concat([name]);
}
};
Pattern.prototype.define("hush", (pat) => pat.hush(), {patternified: false, composable: true});
Pattern.prototype.define("bypass", (pat) => pat.bypass(on), {patternified: true, composable: true});
Pattern.prototype.bootstrap = function() {
const bootstrapped = Object.fromEntries(Object.entries(Pattern.prototype.composable).map(([functionName, composable]) => {
if (Pattern.prototype[functionName]) {
@ -741,6 +731,17 @@ Pattern.prototype.bootstrap = function() {
});
return bootstrapped;
};
Pattern.prototype.define = (name, func, options = {}) => {
if (options.composable) {
Pattern.prototype.composable[name] = func;
}
if (options.patternified) {
Pattern.prototype.patternified = Pattern.prototype.patternified.concat([name]);
}
Pattern.prototype.bootstrap();
};
Pattern.prototype.define("hush", (pat) => pat.hush(), {patternified: false, composable: true});
Pattern.prototype.define("bypass", (pat) => pat.bypass(on), {patternified: true, composable: true});
function withLocationOffset(pat, offset) {
return pat._withContext((context) => {
let locations = context.locations || [];

View File

@ -85,7 +85,7 @@ function useRepl({tune, defaultSynth, autolink = true, onEvent, onDraw}) {
}
}, [pattern]),
onSchedule: useCallback((_events, cycle2) => logCycle(_events, cycle2), [pattern]),
ready: !!pattern
ready: !!pattern && !!activeCode
});
const broadcast = usePostMessage(({data: {from, type}}) => {
if (type === "start" && from !== id) {

View File

@ -41846,7 +41846,7 @@ function useRepl({ tune , defaultSynth , autolink =true , onEvent , onDraw }) {
, [
pattern
]),
ready: !!pattern
ready: !!pattern && !!activeCode
});
const broadcast = _usePostMessageDefault.default(({ data: { from , type } })=>{
if (type === 'start' && from !== id) {
@ -43103,26 +43103,6 @@ function makeComposable(func) {
});
return func;
}
// this will add func as name to list of composable / patternified functions.
// those lists will be used in bootstrap to curry and compose everything, to support various call patterns
Pattern.prototype.define = (name, func, options = {
})=>{
if (options.composable) Pattern.prototype.composable[name] = func;
if (options.patternified) Pattern.prototype.patternified = Pattern.prototype.patternified.concat([
name
]);
};
// Pattern.prototype.define('early', (a, pat) => pat.early(a), { patternified: true, composable: true });
Pattern.prototype.define('hush', (pat)=>pat.hush()
, {
patternified: false,
composable: true
});
Pattern.prototype.define('bypass', (pat)=>pat.bypass(on)
, {
patternified: true,
composable: true
});
// call this after all Patter.prototype.define calls have been executed! (right before evaluate)
Pattern.prototype.bootstrap = function() {
// makeComposable(Pattern.prototype);
@ -43156,6 +43136,27 @@ Pattern.prototype.bootstrap = function() {
); */ });
return bootstrapped;
};
// this will add func as name to list of composable / patternified functions.
// those lists will be used in bootstrap to curry and compose everything, to support various call patterns
Pattern.prototype.define = (name, func, options = {
})=>{
if (options.composable) Pattern.prototype.composable[name] = func;
if (options.patternified) Pattern.prototype.patternified = Pattern.prototype.patternified.concat([
name
]);
Pattern.prototype.bootstrap(); // automatically bootstrap after new definition
};
// Pattern.prototype.define('early', (a, pat) => pat.early(a), { patternified: true, composable: true });
Pattern.prototype.define('hush', (pat)=>pat.hush()
, {
patternified: false,
composable: true
});
Pattern.prototype.define('bypass', (pat)=>pat.bypass(on)
, {
patternified: true,
composable: true
});
// this is wrapped around mini patterns to offset krill parser location into the global js code space
function withLocationOffset(pat, offset) {
return pat._withContext((context)=>{
@ -183314,4 +183315,4 @@ exports.default = cx;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}]},["3uVTb"], "3uVTb", "parcelRequire94c2")
//# sourceMappingURL=index.c6dd21ba.js.map
//# sourceMappingURL=index.93c373c9.js.map

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,6 @@
<body>
<div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/tutorial/index.c6dd21ba.js" defer=""></script>
<script src="/tutorial/index.93c373c9.js" defer=""></script>
</body>
</html>