Skip to content

Commit

Permalink
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core
Browse files Browse the repository at this point in the history
… into gh-pages
  • Loading branch information
onsetsu committed Jul 4, 2024
2 parents 0886187 + 4cf7f68 commit 1c67f2b
Show file tree
Hide file tree
Showing 505 changed files with 26,103 additions and 15,382 deletions.
21 changes: 21 additions & 0 deletions demos/contextjs/showfocuslayer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ShowFocus Layer

And I wrote it again.... Because I did not look for <edit://demos/contextjs/showfocuslayer.js> first

```js
import * as cop from "src/client/ContextJS/src/contextjs.js";

cop.layer(window, "ShowFocus").refineClass(HTMLElement, {

focus(...args) {
lively.showElement(this)
console.log("focus " + this, lively.stack())
return cop.proceed(...args)
}

})

ShowFocus.beGlobal()

ShowFocus.beNotGlobal()
```
1 change: 0 additions & 1 deletion demos/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ function count(list) {
}

var result = count([1,2,3,2345,234,234,23,4,23,4])

20 changes: 19 additions & 1 deletion demos/javascript/a.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// a.js
"disable deepeval"
export const value = 44;
export const value = 44;


function hello2() {
var a = 3 + 4
}

hello2()



class Foo {


hello2() {
var a = 3 + 4
}

}
15 changes: 14 additions & 1 deletion demos/markdown/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@ import {AudioRecorder} from "src/client/audio.js"

<script>


var foo = <span>x</span>, b = 3;

const x


class Foo {

async bla() {

}

bar() {

}
}

</script>
1 change: 1 addition & 0 deletions demos/openai/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
getCurrentDateTime: getCurrentDateTime,
};


async function handleFunctionCall(functionName, args) {
if (functions[functionName]) {
return functions[functionName](...args);
Expand Down
2 changes: 1 addition & 1 deletion demos/openai/streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{ "role": "user", "content": [
{
"type": "text",
"text": "Tell me a funny story about walking and talking trees!"
"text": "Tell me a funny story about walking and talking trees based on the disc world!"
}
]}
]
Expand Down
6 changes: 6 additions & 0 deletions demos/typescript/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


function foo() {

return "hello"
}
10 changes: 10 additions & 0 deletions demos/typescript/a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<script>


import foo from "./a.ts"


foo()

</script>
5 changes: 5 additions & 0 deletions demos/typescript/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log("LOAD a.ts")

function foo() {
return "hello"
}
6 changes: 6 additions & 0 deletions demos/typescript/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as a from "./a.ts"

export default function foo() {

return a.foo()
}
5 changes: 5 additions & 0 deletions demos/typescript/c.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lively.notify("LOAD c.ts")

export default function foo(s : string) : string {
return "hello " + s
}
8 changes: 8 additions & 0 deletions demos/typescript/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TypeScript Support in Lively

- [X] edit modules with syntax highlighting
- [X] load modules via SystemJS
- [X] unload/reload modules while editing
- [ ] linting / show hints in sidebar
- [ ] lsb like server support
- https://discuss.codemirror.net/t/codemirror-6-and-typescript-lsp/3398
Empty file removed package-lock.json
Empty file.
97 changes: 86 additions & 11 deletions src/client/debug.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Logging} from "src/client/morphic/component-loader.js"
// import {Logging} from "src/client/morphic/component-loader.js"

var debugCounterByClass = new Map()
var debugPrintMap = new WeakMap() // obj -> string
Expand All @@ -9,18 +9,23 @@ var debugPrintReverseMap = new Map() // string -> obj

/*globals WeakRef */

export {Logging}
// export {Logging}

export function debugPrint(element) {
if (!element) return
var print = debugPrintMap.get(element)
if (!print) {
if (!print && element && element.constructor) {
var className = element.constructor.name
var counter = debugCounterByClass.get(className) || 0
counter++
debugCounterByClass.set(className, counter)
print = className + counter
debugPrintMap.set(element, print)
debugSet(print, element)
try {
debugPrintMap.set(element, print)
debugSet(print, element)
} catch(e) {
return "" + element
}
}
return print
}
Expand All @@ -42,15 +47,85 @@ export function debugSet(name, obj) {
}


if (false) {
Logging.enable()
// if (false) {
// Logging.enable()

// Logging.setLog((element, ...args) => {

Logging.setLog((element, ...args) => {
// if (element && element instanceof HTMLElement ) {
// console.log(debugPrint(element), ...args)
// }
// })
// }

export function printStack(offset=2) {
return lively.stack().frames.map(ea => ea._desc.replace(lively4url,"")).slice(offset,-1).join("\n")
}

if (element && element instanceof HTMLElement ) {
console.log(debugPrint(element), ...args)

export function busyLogFocus(forTime=10, start, lastFocusedElement) {
start = start || performance.now()
let element = lively.activeElement()

let delta = performance.now() - start
if (delta < forTime) {
let focused = lively.activeElement()
if (focused !== lastFocusedElement) {
console.log(Math.round(performance.now() - window.timeStart) + " active " + debugPrint(focused))
}
})


setTimeout(() => busyLogFocus(forTime, start, focused), 0)
}

}

/*MD # Some Interesting Debug Scripts... MD*/

/*
// TODO make funcition for it
lively.removeEventListener("devfocus", document.body)
lively.addEventListener("devfocus", document.body, "focusin", (evt) => {
console.log(Math.round(performance.now() - window.timeStart) + "ms focus in " + debugPrint(evt.target) + " active " + debugPrint(lively.activeElement()) + "\n"+ printStack(3) )
})
lively.addEventListener("devfocus", document.body, "focusout", (evt) => {
console.log(Math.round(performance.now() - window.timeStart) + "ms focus out " + debugPrint(evt.target) + " active " + debugPrint(lively.activeElement()) + "\n" + printStack(3))
})
*/

/*
import * as cop from "src/client/ContextJS/src/contextjs.js";
cop.layer(window, "ShowFocus").refineClass(HTMLElement, {
focus(...args) {
console.log(( performance.now() - window.timeStart) + " " + lively.debug.debugPrint(this) + ".focus" + lively.stack().frames.map(ea => ea._desc.replace(lively4url,"")).slice(4,-1).join("\n"))
return cop.proceed(...args)
},
blur(...args) {
console.log(( performance.now() - window.timeStart) + " " + lively.debug.debugPrint(this) + ".blur" + lively.stack().frames.map(ea => ea._desc.replace(lively4url,"")).slice(4,-1).join("\n"))
return cop.proceed(...args)
}
})
ShowFocus.beGlobal()
ShowFocus.beNotGlobal()
*/



2 changes: 1 addition & 1 deletion src/client/fileindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ MD*/
modified: modified
}

if (name.match(/\.((css)|(js)|(md)|(txt)|(tex)|(bib)|(x?html)|(note))$/)) {
if (name.match(/\.((css)|(js)|(mjs)|(ts)|(md)|(txt)|(tex)|(bib)|(x?html)|(note))$/)) {
if ((size < MAX_FILESIZE) || name.match(/\.((bib))$/) ) {
let response = await fetch(url, {
method: "GET",
Expand Down
5 changes: 4 additions & 1 deletion src/client/lively.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import windows from "src/components/widgets/lively-window.js";

import events from "src/client/morphic/events.js";

import * as debug from "src/client/debug.js"

let $ = window.$; // known global variables.

/*globals that*/
Expand All @@ -57,6 +59,7 @@ var debugLogHightlights = new WeakMap();
// c) This indirection is also needed to let old events listeners signal to code in current modules
var exportmodules = ["preferences", "files", "keys", "paths", "html", "reflection", "components", "persistence",
// "color",
"debug",
"focalStorage", "authGithub", "authDropbox", "authGoogledrive", "contextmenu", "windows"];

class LivelyNotification {
Expand Down Expand Up @@ -2230,7 +2233,7 @@ export default class Lively {
// same as element.focus({ preventScroll : true}); ?
static focusWithoutScroll(element) {
if (!element) return;

//console.log("focusWithoutScroll " + element, lively.stack().toString())
var scrollTop = document.scrollingElement.scrollTop;
var scrollLeft = document.scrollingElement.scrollLeft;
Expand Down
Loading

0 comments on commit 1c67f2b

Please sign in to comment.