@davidsouther/jiffies 1.0.0 → 2.0.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/build/pico.css +2466 -0
- package/build/pico.css.map +1 -0
- package/{build → lib/cjs}/assert.d.ts +0 -0
- package/lib/cjs/assert.js +40 -0
- package/{build → lib/cjs}/case.d.ts +0 -0
- package/lib/cjs/case.js +9 -0
- package/{build → lib/cjs}/components/button_bar.d.ts +1 -1
- package/lib/cjs/components/button_bar.js +29 -0
- package/{build → lib/cjs}/components/inline_edit.d.ts +1 -1
- package/lib/cjs/components/inline_edit.js +51 -0
- package/{build → lib/cjs}/components/logger.d.ts +2 -3
- package/lib/cjs/components/logger.js +27 -0
- package/{build → lib/cjs}/components/select.d.ts +2 -2
- package/lib/cjs/components/select.js +6 -0
- package/lib/cjs/components/test.d.ts +1 -0
- package/lib/cjs/components/test.js +7 -0
- package/{build → lib/cjs}/components/virtual_scroll.d.ts +3 -4
- package/lib/cjs/components/virtual_scroll.js +102 -0
- package/{build → lib/cjs}/components/virtual_scroll.test.d.ts +0 -0
- package/lib/cjs/components/virtual_scroll.test.js +22 -0
- package/{build → lib/cjs}/context.d.ts +0 -0
- package/lib/cjs/context.js +48 -0
- package/{build → lib/cjs}/context.test.d.ts +0 -0
- package/lib/cjs/context.test.js +48 -0
- package/{build → lib/cjs}/debounce.d.ts +0 -0
- package/lib/cjs/debounce.js +11 -0
- package/lib/cjs/diff.d.ts +15 -0
- package/lib/cjs/diff.js +58 -0
- package/{build/components/test.d.ts → lib/cjs/diff.test.d.ts} +0 -0
- package/lib/cjs/diff.test.js +41 -0
- package/{build → lib/cjs}/display.d.ts +0 -0
- package/lib/cjs/display.js +16 -0
- package/{build → lib/cjs}/dom/css/border.d.ts +0 -0
- package/lib/cjs/dom/css/border.js +33 -0
- package/{build → lib/cjs}/dom/css/constants.d.ts +0 -0
- package/lib/cjs/dom/css/constants.js +31 -0
- package/{build → lib/cjs}/dom/css/core.d.ts +0 -0
- package/lib/cjs/dom/css/core.js +31 -0
- package/{build → lib/cjs}/dom/css/fstyle.d.ts +0 -0
- package/lib/cjs/dom/css/fstyle.js +36 -0
- package/{build → lib/cjs}/dom/css/sizing.d.ts +0 -0
- package/lib/cjs/dom/css/sizing.js +14 -0
- package/lib/cjs/dom/dom.d.ts +27 -0
- package/lib/cjs/dom/dom.js +110 -0
- package/{build → lib/cjs}/dom/fc.d.ts +5 -5
- package/lib/cjs/dom/fc.js +39 -0
- package/{build → lib/cjs}/dom/fc.test.d.ts +0 -0
- package/lib/cjs/dom/fc.test.js +23 -0
- package/lib/cjs/dom/form/form.app.d.ts +1 -0
- package/lib/cjs/dom/form/form.app.js +27 -0
- package/{build → lib/cjs}/dom/form/form.d.ts +9 -9
- package/lib/cjs/dom/form/form.js +49 -0
- package/{build → lib/cjs}/dom/form/form.test.d.ts +0 -0
- package/{build → lib/cjs}/dom/form/form.test.js +0 -0
- package/lib/cjs/dom/html.d.ts +113 -0
- package/lib/cjs/dom/html.js +119 -0
- package/{build → lib/cjs}/dom/html.test.d.ts +0 -0
- package/lib/cjs/dom/html.test.js +60 -0
- package/lib/cjs/dom/observable.d.ts +2 -0
- package/lib/cjs/dom/observable.js +10 -0
- package/{build/dom/test.d.ts → lib/cjs/dom/observable.test.d.ts} +0 -0
- package/lib/cjs/dom/observable.test.js +35 -0
- package/{build → lib/cjs}/dom/provide.d.ts +0 -0
- package/lib/cjs/dom/provide.js +12 -0
- package/lib/cjs/dom/router/link.d.ts +6 -0
- package/lib/cjs/dom/router/link.js +7 -0
- package/{build → lib/cjs}/dom/router/router.d.ts +3 -3
- package/lib/cjs/dom/router/router.js +52 -0
- package/lib/cjs/dom/svg.d.ts +64 -0
- package/lib/cjs/dom/svg.js +69 -0
- package/lib/cjs/dom/test.d.ts +1 -0
- package/lib/cjs/dom/test.js +13 -0
- package/{build → lib/cjs}/dom/types/css.d.ts +0 -0
- package/lib/cjs/dom/types/css.js +24 -0
- package/{build → lib/cjs}/dom/types/dom.d.ts +0 -0
- package/{build → lib/cjs}/dom/types/dom.js +0 -0
- package/{build → lib/cjs}/dom/types/html.d.ts +1 -1
- package/lib/cjs/dom/types/html.js +2 -0
- package/{build → lib/cjs}/dom/xml.d.ts +0 -0
- package/lib/cjs/dom/xml.js +8 -0
- package/{build → lib/cjs}/equal.d.ts +0 -0
- package/lib/cjs/equal.js +43 -0
- package/{build → lib/cjs}/equal.test.d.ts +0 -0
- package/lib/cjs/equal.test.js +22 -0
- package/{build → lib/cjs}/flags.d.ts +0 -0
- package/lib/cjs/flags.js +52 -0
- package/{build → lib/cjs}/flags.test.d.ts +0 -0
- package/lib/cjs/flags.test.js +37 -0
- package/{build → lib/cjs}/fs.d.ts +0 -0
- package/lib/cjs/fs.js +151 -0
- package/{build → lib/cjs}/fs.test.d.ts +0 -0
- package/lib/cjs/fs.test.js +45 -0
- package/{build → lib/cjs}/generator.d.ts +0 -0
- package/lib/cjs/generator.js +14 -0
- package/{build → lib/cjs}/generator.test.d.ts +0 -0
- package/lib/cjs/generator.test.js +26 -0
- package/{build → lib/cjs}/is_browser.d.ts +0 -0
- package/lib/cjs/is_browser.js +4 -0
- package/{build → lib/cjs}/loader.d.mts +0 -0
- package/lib/cjs/loader.mjs +40 -0
- package/{build → lib/cjs}/lock.d.ts +0 -0
- package/lib/cjs/lock.js +27 -0
- package/{build → lib/cjs}/lock.test.d.ts +0 -0
- package/lib/cjs/lock.test.js +18 -0
- package/{build → lib/cjs}/log.d.ts +0 -0
- package/lib/cjs/log.js +54 -0
- package/lib/cjs/observable/event.d.ts +35 -0
- package/lib/cjs/observable/event.js +61 -0
- package/lib/cjs/observable/observable.d.ts +132 -0
- package/lib/cjs/observable/observable.js +363 -0
- package/{build/dom/types/html.js → lib/cjs/observable/observable.test.d.ts} +0 -0
- package/lib/cjs/observable/observable.test.js +65 -0
- package/{build → lib/cjs}/range.d.ts +0 -0
- package/lib/cjs/range.js +11 -0
- package/{build → lib/cjs}/result.d.ts +0 -0
- package/lib/cjs/result.js +80 -0
- package/{build → lib/cjs}/result.test.d.ts +0 -0
- package/lib/cjs/result.test.js +73 -0
- package/{build → lib/cjs}/safe.d.ts +0 -0
- package/lib/cjs/safe.js +14 -0
- package/{build → lib/cjs}/scope/describe.d.ts +4 -0
- package/lib/cjs/scope/describe.js +73 -0
- package/{build → lib/cjs}/scope/display/console.d.ts +0 -0
- package/lib/cjs/scope/display/console.js +25 -0
- package/{build → lib/cjs}/scope/display/dom.d.ts +2 -2
- package/lib/cjs/scope/display/dom.js +30 -0
- package/{build → lib/cjs}/scope/display/junit.d.ts +0 -0
- package/lib/cjs/scope/display/junit.js +21 -0
- package/{build → lib/cjs}/scope/execute.d.ts +1 -1
- package/lib/cjs/scope/execute.js +91 -0
- package/{build → lib/cjs}/scope/expect.d.ts +0 -0
- package/lib/cjs/scope/expect.js +114 -0
- package/{build → lib/cjs}/scope/fix.d.ts +0 -0
- package/lib/cjs/scope/fix.js +26 -0
- package/{build → lib/cjs}/scope/index.d.ts +0 -0
- package/lib/cjs/scope/index.js +15 -0
- package/{build → lib/cjs}/scope/scope.d.ts +0 -0
- package/lib/cjs/scope/scope.js +2 -0
- package/lib/cjs/scope/state.d.ts +1 -0
- package/lib/cjs/scope/state.js +11 -0
- package/{build → lib/cjs}/server/http/apps.d.ts +0 -0
- package/lib/cjs/server/http/apps.js +27 -0
- package/{build → lib/cjs}/server/http/css.d.ts +0 -0
- package/lib/cjs/server/http/css.js +54 -0
- package/{build → lib/cjs}/server/http/index.d.ts +0 -0
- package/lib/cjs/server/http/index.js +77 -0
- package/{build → lib/cjs}/server/http/response.d.ts +0 -0
- package/lib/cjs/server/http/response.js +45 -0
- package/{build → lib/cjs}/server/http/sitemap.d.ts +0 -0
- package/lib/cjs/server/http/sitemap.js +46 -0
- package/{build → lib/cjs}/server/http/static.d.ts +0 -0
- package/lib/cjs/server/http/static.js +25 -0
- package/{build → lib/cjs}/server/http/typescript.d.ts +0 -0
- package/lib/cjs/server/http/typescript.js +44 -0
- package/{build → lib/cjs}/server/main.d.ts +0 -0
- package/lib/cjs/server/main.js +14 -0
- package/{build → lib/cjs}/test.d.mts +0 -0
- package/lib/cjs/test.mjs +28 -0
- package/{build → lib/cjs}/test_all.d.ts +2 -0
- package/lib/cjs/test_all.js +30 -0
- package/{build → lib/cjs}/transpile.d.mts +0 -0
- package/lib/cjs/transpile.mjs +22 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/assert.d.ts +23 -0
- package/{build → lib/esm}/assert.js +1 -1
- package/lib/esm/case.d.ts +1 -0
- package/{build → lib/esm}/case.js +0 -0
- package/lib/esm/components/button_bar.d.ts +8 -0
- package/{build → lib/esm}/components/button_bar.js +3 -3
- package/lib/esm/components/inline_edit.d.ts +12 -0
- package/{build → lib/esm}/components/inline_edit.js +3 -3
- package/lib/esm/components/logger.d.ts +6 -0
- package/{build → lib/esm}/components/logger.js +3 -3
- package/lib/esm/components/select.d.ts +10 -0
- package/{build → lib/esm}/components/select.js +2 -2
- package/lib/esm/components/test.d.ts +1 -0
- package/lib/esm/components/test.js +3 -0
- package/lib/esm/components/virtual_scroll.d.ts +40 -0
- package/{build → lib/esm}/components/virtual_scroll.js +3 -3
- package/{build/scope/scope.js → lib/esm/components/virtual_scroll.test.d.ts} +0 -0
- package/{build → lib/esm}/components/virtual_scroll.test.js +3 -4
- package/lib/esm/context.d.ts +15 -0
- package/{build → lib/esm}/context.js +3 -3
- package/lib/esm/context.test.d.ts +1 -0
- package/{build → lib/esm}/context.test.js +0 -0
- package/lib/esm/debounce.d.ts +1 -0
- package/{build → lib/esm}/debounce.js +0 -0
- package/lib/esm/diff.d.ts +15 -0
- package/lib/esm/diff.js +54 -0
- package/lib/esm/diff.test.d.ts +1 -0
- package/lib/esm/diff.test.js +39 -0
- package/lib/esm/display.d.ts +5 -0
- package/{build → lib/esm}/display.js +0 -0
- package/lib/esm/dom/css/border.d.ts +11 -0
- package/{build → lib/esm}/dom/css/border.js +0 -0
- package/lib/esm/dom/css/constants.d.ts +31 -0
- package/{build → lib/esm}/dom/css/constants.js +0 -0
- package/lib/esm/dom/css/core.d.ts +5 -0
- package/{build → lib/esm}/dom/css/core.js +0 -0
- package/lib/esm/dom/css/fstyle.d.ts +5 -0
- package/{build → lib/esm}/dom/css/fstyle.js +0 -0
- package/lib/esm/dom/css/sizing.d.ts +5 -0
- package/{build → lib/esm}/dom/css/sizing.js +0 -0
- package/lib/esm/dom/dom.d.ts +27 -0
- package/{build → lib/esm}/dom/dom.js +44 -35
- package/lib/esm/dom/fc.d.ts +14 -0
- package/{build → lib/esm}/dom/fc.js +1 -1
- package/lib/esm/dom/fc.test.d.ts +1 -0
- package/{build → lib/esm}/dom/fc.test.js +0 -0
- package/lib/esm/dom/form/form.app.d.ts +1 -0
- package/{build → lib/esm}/dom/form/form.app.js +0 -0
- package/lib/esm/dom/form/form.d.ts +26 -0
- package/{build → lib/esm}/dom/form/form.js +0 -0
- package/lib/esm/dom/form/form.test.d.ts +0 -0
- package/lib/esm/dom/form/form.test.js +1 -0
- package/lib/esm/dom/html.d.ts +113 -0
- package/{build → lib/esm}/dom/html.js +0 -0
- package/lib/esm/dom/html.test.d.ts +1 -0
- package/{build → lib/esm}/dom/html.test.js +4 -4
- package/lib/esm/dom/observable.d.ts +2 -0
- package/lib/esm/dom/observable.js +6 -0
- package/lib/esm/dom/observable.test.d.ts +1 -0
- package/lib/esm/dom/observable.test.js +33 -0
- package/lib/esm/dom/provide.d.ts +3 -0
- package/{build → lib/esm}/dom/provide.js +0 -0
- package/lib/esm/dom/router/link.d.ts +6 -0
- package/{build → lib/esm}/dom/router/link.js +0 -0
- package/lib/esm/dom/router/router.d.ts +12 -0
- package/{build → lib/esm}/dom/router/router.js +0 -0
- package/lib/esm/dom/svg.d.ts +64 -0
- package/{build → lib/esm}/dom/svg.js +0 -0
- package/lib/esm/dom/test.d.ts +1 -0
- package/lib/esm/dom/test.js +9 -0
- package/lib/esm/dom/types/css.d.ts +6612 -0
- package/{build → lib/esm}/dom/types/css.js +0 -0
- package/lib/esm/dom/types/dom.d.ts +0 -0
- package/lib/esm/dom/types/dom.js +1 -0
- package/lib/esm/dom/types/html.d.ts +616 -0
- package/lib/esm/dom/types/html.js +1 -0
- package/lib/esm/dom/xml.d.ts +1 -0
- package/{build → lib/esm}/dom/xml.js +1 -2
- package/lib/esm/equal.d.ts +5 -0
- package/{build → lib/esm}/equal.js +1 -1
- package/lib/esm/equal.test.d.ts +1 -0
- package/{build → lib/esm}/equal.test.js +0 -0
- package/lib/esm/flags.d.ts +7 -0
- package/{build → lib/esm}/flags.js +1 -1
- package/lib/esm/flags.test.d.ts +1 -0
- package/{build → lib/esm}/flags.test.js +0 -0
- package/lib/esm/fs.d.ts +48 -0
- package/{build → lib/esm}/fs.js +4 -4
- package/lib/esm/fs.test.d.ts +1 -0
- package/{build → lib/esm}/fs.test.js +0 -0
- package/lib/esm/generator.d.ts +1 -0
- package/{build → lib/esm}/generator.js +0 -0
- package/lib/esm/generator.test.d.ts +1 -0
- package/{build → lib/esm}/generator.test.js +0 -0
- package/lib/esm/is_browser.d.ts +1 -0
- package/{build → lib/esm}/is_browser.js +0 -0
- package/lib/esm/loader.d.mts +22 -0
- package/{build → lib/esm}/loader.mjs +0 -0
- package/lib/esm/lock.d.ts +1 -0
- package/{build → lib/esm}/lock.js +0 -0
- package/lib/esm/lock.test.d.ts +1 -0
- package/{build → lib/esm}/lock.test.js +0 -0
- package/lib/esm/log.d.ts +26 -0
- package/{build → lib/esm}/log.js +0 -0
- package/lib/esm/observable/event.d.ts +35 -0
- package/lib/esm/observable/event.js +46 -0
- package/lib/esm/observable/observable.d.ts +132 -0
- package/lib/esm/observable/observable.js +343 -0
- package/lib/esm/observable/observable.test.d.ts +1 -0
- package/lib/esm/observable/observable.test.js +63 -0
- package/lib/esm/range.d.ts +1 -0
- package/{build → lib/esm}/range.js +0 -0
- package/lib/esm/result.d.ts +31 -0
- package/{build → lib/esm}/result.js +1 -1
- package/lib/esm/result.test.d.ts +1 -0
- package/{build → lib/esm}/result.test.js +0 -0
- package/lib/esm/safe.d.ts +1 -0
- package/{build → lib/esm}/safe.js +0 -0
- package/lib/esm/scope/describe.d.ts +18 -0
- package/{build → lib/esm}/scope/describe.js +14 -6
- package/lib/esm/scope/display/console.d.ts +2 -0
- package/{build → lib/esm}/scope/display/console.js +0 -0
- package/lib/esm/scope/display/dom.d.ts +3 -0
- package/{build → lib/esm}/scope/display/dom.js +0 -0
- package/lib/esm/scope/display/junit.d.ts +2 -0
- package/{build → lib/esm}/scope/display/junit.js +0 -0
- package/lib/esm/scope/execute.d.ts +12 -0
- package/{build → lib/esm}/scope/execute.js +2 -2
- package/lib/esm/scope/expect.d.ts +23 -0
- package/{build → lib/esm}/scope/expect.js +0 -0
- package/lib/esm/scope/fix.d.ts +4 -0
- package/{build → lib/esm}/scope/fix.js +0 -0
- package/{build/scope/index.js → lib/esm/scope/index.d.ts} +0 -0
- package/lib/esm/scope/index.js +3 -0
- package/lib/esm/scope/scope.d.ts +17 -0
- package/lib/esm/scope/scope.js +1 -0
- package/lib/esm/scope/state.d.ts +1 -0
- package/lib/esm/scope/state.js +7 -0
- package/lib/esm/server/http/apps.d.ts +5 -0
- package/{build → lib/esm}/server/http/apps.js +0 -0
- package/lib/esm/server/http/css.d.ts +5 -0
- package/{build → lib/esm}/server/http/css.js +3 -0
- package/lib/esm/server/http/index.d.ts +21 -0
- package/{build → lib/esm}/server/http/index.js +0 -0
- package/lib/esm/server/http/response.d.ts +4 -0
- package/{build → lib/esm}/server/http/response.js +0 -0
- package/lib/esm/server/http/sitemap.d.ts +2 -0
- package/{build → lib/esm}/server/http/sitemap.js +0 -0
- package/lib/esm/server/http/static.d.ts +2 -0
- package/{build → lib/esm}/server/http/static.js +0 -0
- package/lib/esm/server/http/typescript.d.ts +5 -0
- package/{build → lib/esm}/server/http/typescript.js +0 -0
- package/lib/esm/server/main.d.ts +2 -0
- package/{build → lib/esm}/server/main.js +5 -2
- package/lib/esm/test.d.mts +2 -0
- package/lib/esm/test.mjs +26 -0
- package/lib/esm/test_all.d.ts +9 -0
- package/{build → lib/esm}/test_all.js +17 -7
- package/lib/esm/transpile.d.mts +3 -0
- package/{build → lib/esm}/transpile.mjs +0 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +17 -18
- package/src/assert.ts +1 -1
- package/src/components/button_bar.ts +3 -3
- package/src/components/inline_edit.ts +3 -3
- package/src/components/logger.ts +5 -6
- package/src/components/select.ts +3 -3
- package/src/components/test.js +3 -2
- package/src/components/virtual_scroll.test.ts +4 -4
- package/src/components/virtual_scroll.ts +8 -8
- package/src/context.ts +3 -3
- package/src/diff.test.ts +48 -0
- package/src/diff.ts +84 -0
- package/src/dom/css/border.ts +3 -3
- package/src/dom/css/core.ts +1 -1
- package/src/dom/css/fstyle.ts +2 -2
- package/src/dom/css/sizing.ts +1 -1
- package/src/dom/dom.ts +73 -61
- package/src/dom/fc.test.ts +3 -3
- package/src/dom/fc.ts +11 -10
- package/src/dom/form/form.app.ts +2 -2
- package/src/dom/form/form.ts +3 -3
- package/src/dom/html.test.ts +8 -8
- package/src/dom/html.ts +7 -10
- package/src/dom/observable.test.ts +43 -0
- package/src/dom/observable.ts +11 -0
- package/src/dom/provide.ts +1 -1
- package/src/dom/router/link.ts +2 -2
- package/src/dom/router/router.ts +5 -5
- package/src/dom/svg.ts +1 -1
- package/src/dom/test.ts +8 -2
- package/src/dom/types/html.ts +1 -1
- package/src/dom/xml.ts +1 -2
- package/src/equal.ts +1 -1
- package/src/flags.ts +1 -1
- package/src/fs.ts +4 -4
- package/src/index.html +12 -9
- package/src/observable/_notes +21 -8
- package/src/observable/event.ts +93 -0
- package/src/observable/observable.test.ts +73 -0
- package/src/observable/observable.ts +463 -0
- package/src/pico/_variables.scss +1 -1
- package/src/pico/layout/_sectioning.scss +2 -0
- package/src/result.ts +1 -1
- package/src/scope/describe.ts +16 -6
- package/src/scope/display/console.ts +4 -4
- package/src/scope/display/dom.ts +7 -7
- package/src/scope/display/junit.ts +3 -3
- package/src/scope/execute.ts +4 -7
- package/src/scope/expect.ts +3 -3
- package/src/scope/state.ts +10 -0
- package/src/server/http/css.ts +3 -1
- package/src/server/http/sitemap.ts +1 -1
- package/src/server/main.ts +9 -2
- package/src/test.mjs +22 -18
- package/src/test_all.ts +20 -8
- package/build/components/test.js +0 -2
- package/build/dom/dom.d.ts +0 -27
- package/build/dom/form/form.app.d.ts +0 -1
- package/build/dom/html.d.ts +0 -117
- package/build/dom/router/link.d.ts +0 -6
- package/build/dom/svg.d.ts +0 -64
- package/build/dom/test.js +0 -2
- package/build/test.mjs +0 -23
- package/src/observable/observable._js +0 -175
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { DEFAULT_LOGGER, Logger } from "../log.js"
|
|
2
|
+
|
|
3
|
+
export interface FullSubscriber<T, E> {
|
|
4
|
+
// (t: T): void | Promise<undefined>;
|
|
5
|
+
next?: (t: T) => void | Promise<undefined>;
|
|
6
|
+
error?: (e: E) => void | Promise<undefined>;
|
|
7
|
+
complete?: () => void | Promise<undefined>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type Subscriber<T, E> =
|
|
11
|
+
| FullSubscriber<T, E>
|
|
12
|
+
// | EventSubscriber<T, E>
|
|
13
|
+
| ((t: T) => void | Promise<undefined>);
|
|
14
|
+
|
|
15
|
+
export interface Subscription {
|
|
16
|
+
// (): void;
|
|
17
|
+
unsubscribe(): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Observable<T, E = unknown> {
|
|
21
|
+
// (subscriber: Subscriber<T, E>): Subscription;
|
|
22
|
+
subscribe(subscriber: Subscriber<T, E>): Subscription;
|
|
23
|
+
pipe<T1>(o1: Subscriber<T, E> & Observable<T1, E>): Observable<T1, E>;
|
|
24
|
+
pipe<T1, T2>(
|
|
25
|
+
o1: Subscriber<T, E> & Observable<T1, E>,
|
|
26
|
+
o2: Subscriber<T1, E> & Observable<T2, E>
|
|
27
|
+
): Observable<T2, E>;
|
|
28
|
+
filter(fn: (t: T) => boolean): Observable<T, E>;
|
|
29
|
+
distinct(fn?: (t1: T, t2: T) => boolean): Observable<T, E>;
|
|
30
|
+
map<U>(fn: (t: T) => U): Observable<U, E>;
|
|
31
|
+
reduce<A>(fn: (acc: A, t: T) => A, init: A): Observable<A, E>;
|
|
32
|
+
replay(n: number): Observable<T, E>;
|
|
33
|
+
tap(s: Subscriber<T, E>): Observable<T, E>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Observable = {
|
|
37
|
+
of<T, E>(...ts: T[]): Observable<T, E> {
|
|
38
|
+
const subject = new Subject<T, E>();
|
|
39
|
+
(async function next() {
|
|
40
|
+
if (subject.cold) {
|
|
41
|
+
subject.onWarm(next);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (ts.length === 0) {
|
|
45
|
+
subject.complete();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const t = ts.shift()!;
|
|
49
|
+
await subject.next(t);
|
|
50
|
+
next();
|
|
51
|
+
})();
|
|
52
|
+
return subject;
|
|
53
|
+
},
|
|
54
|
+
combineLatest<T1, T2, E>(
|
|
55
|
+
o1: Observable<T1, E>,
|
|
56
|
+
o2: Observable<T2, E>
|
|
57
|
+
): Observable<[T1, T2], E> {
|
|
58
|
+
let latestSubject = new Subject<[T1, T2], E>();
|
|
59
|
+
let o1LatestSet = false;
|
|
60
|
+
let o1Latest: T1;
|
|
61
|
+
let o2LatestSet = false;
|
|
62
|
+
let o2Latest: T2;
|
|
63
|
+
|
|
64
|
+
function next() {
|
|
65
|
+
if (o1LatestSet && o2LatestSet) {
|
|
66
|
+
latestSubject.next([o1Latest, o2Latest]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function error(e: E) {
|
|
71
|
+
latestSubject.error(e);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function complete() {
|
|
75
|
+
latestSubject.complete();
|
|
76
|
+
o1sub.unsubscribe();
|
|
77
|
+
o2sub.unsubscribe();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let o1sub = o1.subscribe({
|
|
81
|
+
next(t: T1) {
|
|
82
|
+
o1Latest = t;
|
|
83
|
+
o1LatestSet = true;
|
|
84
|
+
next();
|
|
85
|
+
},
|
|
86
|
+
error,
|
|
87
|
+
complete,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
let o2sub = o2.subscribe({
|
|
91
|
+
next(t: T2) {
|
|
92
|
+
o2Latest = t;
|
|
93
|
+
o2LatestSet = true;
|
|
94
|
+
next();
|
|
95
|
+
},
|
|
96
|
+
error,
|
|
97
|
+
complete,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return latestSubject;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
interface Scheduler {
|
|
105
|
+
execute(fn: () => (void | Promise<undefined>)[]): void | Promise<undefined>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const AsyncScheduler: Scheduler = {
|
|
109
|
+
execute(fn: () => Promise<undefined>[]): Promise<undefined> {
|
|
110
|
+
return Promise.all(fn()).then(() => undefined);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const SyncScheduler: Scheduler = {
|
|
115
|
+
execute(fn: () => void[]): void {
|
|
116
|
+
fn();
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export class Subject<T, E = unknown, T2 = T>
|
|
121
|
+
implements FullSubscriber<T, E>, Observable<T, E>
|
|
122
|
+
{
|
|
123
|
+
#coldWaiters = new Set<Function>();
|
|
124
|
+
#subscribers = new Set<FullSubscriber<T, E>>();
|
|
125
|
+
#complete = false;
|
|
126
|
+
|
|
127
|
+
get $(): Observable<T, E> {
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get hot(): boolean {
|
|
132
|
+
return this.#subscribers.size > 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
get cold(): boolean {
|
|
136
|
+
return !this.hot;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
constructor(private readonly scheduler: Scheduler = AsyncScheduler) {}
|
|
140
|
+
|
|
141
|
+
onWarm(fn: Function) {
|
|
142
|
+
if (this.cold) this.#coldWaiters.add(fn);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
next(t: T | T2): void | Promise<undefined> {
|
|
146
|
+
if (this.#complete)
|
|
147
|
+
throw new Error("Cannot call next on a completed subject");
|
|
148
|
+
return this.scheduler.execute(() =>
|
|
149
|
+
[...this.#subscribers].map((s) => s.next?.(t as T))
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
error(e: E): void | Promise<undefined> {
|
|
154
|
+
if (this.#complete)
|
|
155
|
+
throw new Error("Cannot call error on a completed subject");
|
|
156
|
+
return this.scheduler.execute(() =>
|
|
157
|
+
[...this.#subscribers].map((s) => s.error?.(e))
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
complete(): void | Promise<undefined> {
|
|
162
|
+
if (this.#complete)
|
|
163
|
+
throw new Error("Cannot call complete on a completed subject");
|
|
164
|
+
this.#complete = true;
|
|
165
|
+
const finished = this.scheduler.execute(() =>
|
|
166
|
+
[...this.#subscribers].map((s) => s.complete?.())
|
|
167
|
+
);
|
|
168
|
+
this.#subscribers.clear(); // Free subscribers for garbage collection
|
|
169
|
+
return finished;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
subscribe(subscriber: Subscriber<T, E>): Subscription {
|
|
173
|
+
if (this.#complete)
|
|
174
|
+
throw new Error("Cannot call subscribe on a completed subject");
|
|
175
|
+
|
|
176
|
+
if (subscriber instanceof Function) {
|
|
177
|
+
subscriber = { next: subscriber };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.#subscribers.add(subscriber);
|
|
181
|
+
|
|
182
|
+
[...this.#coldWaiters].forEach((w) => w());
|
|
183
|
+
this.#coldWaiters.clear();
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
unsubscribe: () =>
|
|
187
|
+
this.#subscribers.delete(subscriber as FullSubscriber<T, E>),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
pipe<T1>(o1: Subscriber<T, E> & Observable<T1, E>): Observable<T1, E>;
|
|
192
|
+
pipe<T1, T2>(
|
|
193
|
+
o1: Subscriber<T, E> & Observable<T1, E>,
|
|
194
|
+
o2: Subscriber<T1, E> & Observable<T2, E>
|
|
195
|
+
): Observable<T2, E>;
|
|
196
|
+
pipe(
|
|
197
|
+
...os: (Subscriber<unknown, unknown> & Observable<unknown, unknown>)[]
|
|
198
|
+
): Observable<unknown, E> {
|
|
199
|
+
this.subscribe(os[0]);
|
|
200
|
+
for (let i = 1; i < os.length; i++) {
|
|
201
|
+
os[i - 1].subscribe(os[i]);
|
|
202
|
+
}
|
|
203
|
+
return os[os.length - 1];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
filter(fn: (t: T) => boolean): Observable<T, E> {
|
|
207
|
+
return this.pipe(operator.filter(fn));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
distinct(fn: (t1: T, t2: T) => boolean = Object.is): Observable<T, E> {
|
|
211
|
+
return this.pipe(operator.distinct(fn));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
map<U>(fn: (t: T) => U): Observable<U, E> {
|
|
215
|
+
return this.pipe(operator.map(fn));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
reduce<A>(fn: (acc: A, t: T) => A, init: A): Observable<A, E> {
|
|
219
|
+
return this.pipe(operator.reduce(fn, init));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
replay(n: number): Observable<T, E> {
|
|
223
|
+
return this.pipe(operator.replay(n));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
tap(s: Subscriber<T, E>): Observable<T, E> {
|
|
227
|
+
return this.pipe(operator.tap(s));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export class BehaviorSubject<T, E = unknown, T2 = T> extends Subject<T, E, T2> {
|
|
232
|
+
#current: T;
|
|
233
|
+
|
|
234
|
+
constructor(t: T, scheduler?: Scheduler) {
|
|
235
|
+
super(scheduler);
|
|
236
|
+
this.#current = t;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
next(t: T | T2) {
|
|
240
|
+
this.#current = t as T;
|
|
241
|
+
return super.next(t);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
subscribe(subscriber: Subscriber<T, E>): Subscription {
|
|
245
|
+
if (subscriber instanceof Function) {
|
|
246
|
+
subscriber = { next: subscriber };
|
|
247
|
+
}
|
|
248
|
+
subscriber.next?.(this.#current);
|
|
249
|
+
return super.subscribe(subscriber);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
get current(): T {
|
|
253
|
+
return this.#current;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export class ReplaySubject<T, E = unknown> extends Subject<T, E> {
|
|
258
|
+
#history: T[] = [];
|
|
259
|
+
|
|
260
|
+
constructor(private readonly n: number, scheduler?: Scheduler) {
|
|
261
|
+
super(scheduler);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
next(t: T) {
|
|
265
|
+
this.#history.push(t);
|
|
266
|
+
if (this.#history.length > this.n) {
|
|
267
|
+
this.#history.shift();
|
|
268
|
+
}
|
|
269
|
+
return super.next(t);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
subscribe(subscriber: Subscriber<T, E>): Subscription {
|
|
273
|
+
if (subscriber instanceof Function) {
|
|
274
|
+
subscriber = { next: subscriber };
|
|
275
|
+
}
|
|
276
|
+
const history = [...this.#history];
|
|
277
|
+
(function send() {
|
|
278
|
+
if (history.length == 0) return;
|
|
279
|
+
const t = history.shift()!;
|
|
280
|
+
subscriber.next?.(t);
|
|
281
|
+
new Promise(send);
|
|
282
|
+
})();
|
|
283
|
+
return super.subscribe(subscriber);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function eventListener<E extends Event>() {
|
|
288
|
+
const observable = new Subject<E, unknown>();
|
|
289
|
+
function listener(e: E) {
|
|
290
|
+
e.preventDefault();
|
|
291
|
+
observable.next(e);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return [observable, listener];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export class EventHandler<E extends Event> extends Subject<E> {
|
|
298
|
+
constructor(private readonly eventFn: (e: E) => void | Promise<undefined>) {
|
|
299
|
+
super();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
next(e: E) {
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
super.next(e);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export const watch =
|
|
309
|
+
<T, E>(logger: Logger = DEFAULT_LOGGER) =>
|
|
310
|
+
(observable: Observable<T, E>) => {
|
|
311
|
+
observable.tap({
|
|
312
|
+
next(t: T) {
|
|
313
|
+
logger.info(t);
|
|
314
|
+
},
|
|
315
|
+
complete() {
|
|
316
|
+
logger.info("Observable completed");
|
|
317
|
+
},
|
|
318
|
+
error(e: E) {
|
|
319
|
+
logger.warn(e);
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
class MapOperator<T, U, E>
|
|
325
|
+
extends Subject<U, E, T>
|
|
326
|
+
implements FullSubscriber<T, E>, Observable<U, E>
|
|
327
|
+
{
|
|
328
|
+
constructor(private readonly mapFn: (t: T) => U) {
|
|
329
|
+
super();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
next(t: T): void | Promise<undefined> {
|
|
333
|
+
return super.next(this.mapFn(t));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
class FilterOperator<T, E>
|
|
338
|
+
extends Subject<T, E>
|
|
339
|
+
implements FullSubscriber<T, E>, Observable<T, E>
|
|
340
|
+
{
|
|
341
|
+
constructor(private readonly filterFn: (t: T) => boolean) {
|
|
342
|
+
super();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
next(t: T): void | Promise<undefined> {
|
|
346
|
+
return this.filterFn(t) ? super.next(t) : undefined;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
class DistinctOperator<T, E>
|
|
351
|
+
extends Subject<T, E>
|
|
352
|
+
implements FullSubscriber<T, E>, Observable<T, E>
|
|
353
|
+
{
|
|
354
|
+
#prior: T | undefined = undefined;
|
|
355
|
+
|
|
356
|
+
constructor(
|
|
357
|
+
private readonly distinctFn: (t1: T, t2: T) => boolean = Object.is
|
|
358
|
+
) {
|
|
359
|
+
super();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
next(t: T): void | Promise<undefined> {
|
|
363
|
+
if (this.#prior === undefined) {
|
|
364
|
+
this.#prior = t;
|
|
365
|
+
return super.next(t);
|
|
366
|
+
}
|
|
367
|
+
const same = this.distinctFn(this.#prior!, t);
|
|
368
|
+
if (!same) {
|
|
369
|
+
this.#prior = t;
|
|
370
|
+
return super.next(t);
|
|
371
|
+
}
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
class ReduceOperator<A, T, E> extends BehaviorSubject<A, E, T> {
|
|
377
|
+
constructor(private readonly fn: (acc: A, t: T) => A, init: A) {
|
|
378
|
+
super(init);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
next(t: T) {
|
|
382
|
+
return super.next(this.fn(this.current, t));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export class TakeUntilOperator<T, E> extends Subject<T, E> {
|
|
387
|
+
constructor(o: Observable<unknown, unknown>) {
|
|
388
|
+
super();
|
|
389
|
+
o.subscribe(() => this.complete());
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
export class TapOperator<T, E> extends Subject<T, E> {
|
|
393
|
+
private readonly subscriber: FullSubscriber<T, E>;
|
|
394
|
+
constructor(fn: Subscriber<T, E>) {
|
|
395
|
+
super();
|
|
396
|
+
this.subscriber = fn instanceof Function ? { next: fn } : fn;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
next(t: T) {
|
|
400
|
+
this.subscriber.next?.(t);
|
|
401
|
+
return super.next(t);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
error(e: E) {
|
|
405
|
+
this.subscriber.error?.(e);
|
|
406
|
+
return super.error(e);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
complete() {
|
|
410
|
+
this.subscriber.complete?.();
|
|
411
|
+
return super.complete();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
class FirstOperator<T, E> extends Subject<T, E> {
|
|
416
|
+
next(t: T): void | Promise<undefined> {
|
|
417
|
+
const next = super.next(t);
|
|
418
|
+
this.complete();
|
|
419
|
+
return next;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
class LastOperator<T, E = Error> extends Subject<T, E> {
|
|
424
|
+
#latest?: T;
|
|
425
|
+
|
|
426
|
+
next(t: T) {
|
|
427
|
+
this.#latest = t;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
complete(): void | Promise<undefined> {
|
|
431
|
+
if (this.#latest !== undefined) {
|
|
432
|
+
super.next(this.#latest);
|
|
433
|
+
}
|
|
434
|
+
return super.complete();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export const filter = <T, E>(fn: (t: T) => boolean) =>
|
|
439
|
+
new FilterOperator<T, E>(fn);
|
|
440
|
+
export const distinct = <T, E>(fn?: (t1: T, t2: T) => boolean) =>
|
|
441
|
+
new DistinctOperator<T, E>(fn ?? Object.is);
|
|
442
|
+
export const first = <T, E>() => new FirstOperator<T, E>();
|
|
443
|
+
export const last = <T, E>() => new LastOperator<T, E>();
|
|
444
|
+
export const map = <T1, T2, E>(fn: (t: T1) => T2) =>
|
|
445
|
+
new MapOperator<T1, T2, E>(fn);
|
|
446
|
+
export const replay = <T, E>(n: number) => new ReplaySubject<T, E>(n);
|
|
447
|
+
export const reduce = <A, T, E>(fn: (acc: A, t: T) => A, init: A) =>
|
|
448
|
+
new ReduceOperator<A, T, E>(fn, init);
|
|
449
|
+
export const takeUntil = <T, E>(o: Observable<unknown, unknown>) =>
|
|
450
|
+
new TakeUntilOperator<T, E>(o);
|
|
451
|
+
export const tap = <T, E>(fn: Subscriber<T, E>) => new TapOperator<T, E>(fn);
|
|
452
|
+
|
|
453
|
+
export const operator = {
|
|
454
|
+
filter,
|
|
455
|
+
distinct,
|
|
456
|
+
first,
|
|
457
|
+
last,
|
|
458
|
+
map,
|
|
459
|
+
replay,
|
|
460
|
+
reduce,
|
|
461
|
+
takeUntil,
|
|
462
|
+
tap,
|
|
463
|
+
};
|
package/src/pico/_variables.scss
CHANGED
|
@@ -9,7 +9,7 @@ $enable-class-container: false !default;
|
|
|
9
9
|
|
|
10
10
|
// Enable a centered viewport for <header>, <main>, <footer> inside <body>
|
|
11
11
|
// Options are "all" to center all, "main" to only center main, and "none" to treat all as fluid.
|
|
12
|
-
$enable-viewport: "
|
|
12
|
+
$enable-viewport: "none" !default;
|
|
13
13
|
|
|
14
14
|
// Enable responsive spacings for <header>, <main>, <footer>, <section>, <article>
|
|
15
15
|
// Fixed spacings if disabled
|
package/src/result.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type Err<E = Error> = {
|
|
|
8
8
|
export type Ok<T> = { ok: T; map: <U>(fn: (t: T) => Result<U>) => Result<U> };
|
|
9
9
|
export type Result<T, E = Error> = Ok<T> | Err<E>;
|
|
10
10
|
|
|
11
|
-
export const isNone = <T>(s: Option<T>): s is None => s
|
|
11
|
+
export const isNone = <T>(s: Option<T>): s is None => s === null;
|
|
12
12
|
export const isSome = <T>(s: Option<T>): s is Some<T> => s != null;
|
|
13
13
|
|
|
14
14
|
export function None<T = unknown>(_?: T): Option<T> {
|
package/src/scope/describe.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { assert } from "../assert.js";
|
|
1
2
|
import { getLogger } from "../log.js";
|
|
2
3
|
import { TestCase } from "./scope.js";
|
|
4
|
+
import * as state from "./state.js";
|
|
3
5
|
|
|
4
6
|
export const beforeall = Symbol("beforeAll");
|
|
5
7
|
export const beforeeach = Symbol("beforeEach");
|
|
@@ -11,9 +13,10 @@ const logger = getLogger("scope");
|
|
|
11
13
|
const CASES: TestCase = {};
|
|
12
14
|
let cases = [CASES];
|
|
13
15
|
let totalCases = 0;
|
|
16
|
+
let skippedCases = 0;
|
|
14
17
|
|
|
15
18
|
function push(title: string) {
|
|
16
|
-
const next = (cases[0][title] = {});
|
|
19
|
+
const next = (cases[0][title] = cases[0][title] ?? {}) as TestCase;
|
|
17
20
|
cases.unshift(next);
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -29,6 +32,10 @@ export function getTotalCases() {
|
|
|
29
32
|
return totalCases;
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
export function getSkippedCases() {
|
|
36
|
+
return skippedCases;
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
export function describe(title: string, block: Function) {
|
|
33
40
|
logger.debug(`describe(${title})`);
|
|
34
41
|
push(title);
|
|
@@ -38,10 +45,17 @@ export function describe(title: string, block: Function) {
|
|
|
38
45
|
|
|
39
46
|
export function it(title: string, block: Function) {
|
|
40
47
|
logger.debug(`it(${title})`);
|
|
48
|
+
assert(cases[0][title] == undefined, `Block already has test ${title}`);
|
|
41
49
|
totalCases += 1;
|
|
42
50
|
cases[0][title] = block;
|
|
43
51
|
}
|
|
44
52
|
|
|
53
|
+
it.skip = (title: string, _block: Function) => {
|
|
54
|
+
logger.debug(`it.skip(${title})`);
|
|
55
|
+
totalCases += 1;
|
|
56
|
+
skippedCases += 1;
|
|
57
|
+
};
|
|
58
|
+
|
|
45
59
|
export function beforeEach(fn: () => void) {
|
|
46
60
|
cases[0][beforeeach] = fn;
|
|
47
61
|
}
|
|
@@ -62,9 +76,5 @@ export function cleanState<State extends {}>(
|
|
|
62
76
|
init: () => State,
|
|
63
77
|
runner: (action: () => void) => void = beforeEach
|
|
64
78
|
): State {
|
|
65
|
-
|
|
66
|
-
runner(() => {
|
|
67
|
-
Object.assign(state, init());
|
|
68
|
-
});
|
|
69
|
-
return state as State;
|
|
79
|
+
return state.cleanState(init, runner);
|
|
70
80
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getLogger } from "../../log.js"
|
|
2
|
-
import { getTotalCases } from "../describe.js"
|
|
3
|
-
import { flattenResults } from "../execute.js"
|
|
4
|
-
import { TestResult } from "../scope.js"
|
|
1
|
+
import { getLogger } from "../../log.js"
|
|
2
|
+
import { getTotalCases } from "../describe.js"
|
|
3
|
+
import { flattenResults } from "../execute.js"
|
|
4
|
+
import { TestResult } from "../scope.js"
|
|
5
5
|
|
|
6
6
|
const logger = getLogger("Scope Test Runner");
|
|
7
7
|
|
package/src/scope/display/dom.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isHTMLLogger, makeHTMLLogger } from "../../components/logger.js"
|
|
2
|
-
import { DOMElement
|
|
3
|
-
import { DEFAULT_LOGGER, LEVEL } from "../../log.js"
|
|
4
|
-
import { getTotalCases } from "../describe.js"
|
|
5
|
-
import { flattenResults } from "../execute.js"
|
|
6
|
-
import { TestResult } from "../scope.js"
|
|
1
|
+
import { isHTMLLogger, makeHTMLLogger } from "../../components/logger.js"
|
|
2
|
+
import { DOMElement } from "../../dom/dom.js"
|
|
3
|
+
import { DEFAULT_LOGGER, LEVEL } from "../../log.js"
|
|
4
|
+
import { getTotalCases } from "../describe.js"
|
|
5
|
+
import { flattenResults } from "../execute.js"
|
|
6
|
+
import { TestResult } from "../scope.js"
|
|
7
7
|
|
|
8
8
|
export function displayStatistics(
|
|
9
9
|
results: TestResult,
|
|
10
|
-
root:
|
|
10
|
+
root: DOMElement = document.body as DOMElement
|
|
11
11
|
) {
|
|
12
12
|
const { executed, failed } = results;
|
|
13
13
|
const logger = (() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { xml } from "../../dom/xml.js"
|
|
2
|
-
import { FlatResult, flattenResults } from "../execute.js"
|
|
3
|
-
import { TestResult } from "../scope.js"
|
|
1
|
+
import { xml } from "../../dom/xml.js"
|
|
2
|
+
import { FlatResult, flattenResults } from "../execute.js"
|
|
3
|
+
import { TestResult } from "../scope.js"
|
|
4
4
|
|
|
5
5
|
const cases = (results: TestResult) =>
|
|
6
6
|
Object.entries(results).filter(
|
package/src/scope/execute.ts
CHANGED
|
@@ -4,13 +4,10 @@ import {
|
|
|
4
4
|
beforeall,
|
|
5
5
|
beforeeach,
|
|
6
6
|
rootCases,
|
|
7
|
-
} from "./describe.js"
|
|
8
|
-
import { TestFailed, TestPassed, TestResult, TestSummary } from "./scope.js"
|
|
7
|
+
} from "./describe.js"
|
|
8
|
+
import { TestFailed, TestPassed, TestResult, TestSummary } from "./scope.js"
|
|
9
9
|
|
|
10
|
-
export async function execute(
|
|
11
|
-
prefix = "",
|
|
12
|
-
cases = rootCases()
|
|
13
|
-
): Promise<TestResult> {
|
|
10
|
+
export async function execute(cases = rootCases()): Promise<TestResult> {
|
|
14
11
|
const beforeallfn = cases[beforeall] ?? (() => {});
|
|
15
12
|
const beforeeachfn = cases[beforeeach] ?? (() => {});
|
|
16
13
|
const afterallfn = cases[afterall] ?? (() => {});
|
|
@@ -42,7 +39,7 @@ export async function execute(
|
|
|
42
39
|
result[title] = { error: /** @type Error */ e };
|
|
43
40
|
}
|
|
44
41
|
} else if (block) {
|
|
45
|
-
const run = await execute(
|
|
42
|
+
const run = await execute(block);
|
|
46
43
|
result.executed += run.executed;
|
|
47
44
|
result.passed += run.passed;
|
|
48
45
|
result.failed += run.failed;
|
package/src/scope/expect.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assert } from "../assert.js"
|
|
2
|
-
import { display } from "../display.js"
|
|
3
|
-
import { equals } from "../equal.js"
|
|
1
|
+
import { assert } from "../assert.js"
|
|
2
|
+
import { display } from "../display.js"
|
|
3
|
+
import { equals } from "../equal.js"
|
|
4
4
|
|
|
5
5
|
export class Matcher<T> {
|
|
6
6
|
actual: T;
|
package/src/server/http/css.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as fs from "fs/promises";
|
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { contentResponse } from "./response.js";
|
|
4
4
|
import { MiddlewareFactory } from "./index.js";
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
import sass from "sass";
|
|
6
|
-
import { error, info } from "../../log.js";
|
|
7
7
|
const { compileStringAsync } = sass;
|
|
8
8
|
|
|
9
9
|
function render(source: string) {
|
|
@@ -20,6 +20,7 @@ async function compile(
|
|
|
20
20
|
vars: string
|
|
21
21
|
): Promise<string> {
|
|
22
22
|
vars = vars.substring(1).replaceAll("=", ":");
|
|
23
|
+
filename = filename.replaceAll("\\", "/"); // Normalize for dart-sass
|
|
23
24
|
const sassString = `// Using variables: ${vars}\n${vars};\n@import "${filename}";`;
|
|
24
25
|
return (await compileStringAsync(sassString, { loadPaths: [root] })).css;
|
|
25
26
|
}
|
|
@@ -36,6 +37,7 @@ export const cssFileServer: MiddlewareFactory =
|
|
|
36
37
|
Url.pathname.startsWith(`/${s}`)
|
|
37
38
|
);
|
|
38
39
|
// Expand url with found scope
|
|
40
|
+
Url.protocol = "file";
|
|
39
41
|
let url = scope ? Url.pathname.replace(scope[0], scope[1]) : Url.pathname;
|
|
40
42
|
let filename = path.join(root, url);
|
|
41
43
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs/promises";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { info } from "../../log.js";
|
|
4
|
-
import { MiddlewareFactory
|
|
4
|
+
import { MiddlewareFactory } from "./index.js";
|
|
5
5
|
import { contentResponse } from "./response.js";
|
|
6
6
|
|
|
7
7
|
const findSiteMap = async (root: string, prefix = root) => {
|
package/src/server/main.ts
CHANGED
|
@@ -9,5 +9,12 @@ const FLAGS = parse(process.argv);
|
|
|
9
9
|
import { makeServer } from "./http/index.js";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
server.
|
|
12
|
+
async function main() {
|
|
13
|
+
const server = await makeServer({ root: path.join(process.cwd(), "src") });
|
|
14
|
+
server.listen(
|
|
15
|
+
FLAGS.asNumber("port", 8080),
|
|
16
|
+
FLAGS.asString("host", "0.0.0.0")
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main();
|