Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Offirmo committed May 9, 2024
1 parent bf9a3c7 commit b06ceb2
Show file tree
Hide file tree
Showing 25 changed files with 126 additions and 880 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h2 id="yes-this-is-the-last-fucking-satire-you-fuck">Yes, this is the last fuck
out there need to make them not total shit.</p>

<blockquote>
<p>Don’t ignore stupid things or you will stay at the motherfucker level.
<p>Don’t ignore stupid things or you will stay at the motherfucker level.
— Brad Hollande</p>
</blockquote>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h2 id="yes-this-is-the-last-fucking-satire-you-fuck">Yes, this is the last fuck
out there need to make them not total shit.</p>

<blockquote>
<p>Don’t ignore stupid things or you will stay at the motherfucker level.
<p>Don’t ignore stupid things or you will stay at the motherfucker level.
— Brad Hollande</p>
</blockquote>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h2 id="yes-this-is-the-last-fucking-satire-you-fuck">Yes, this is the last fuck
out there need to make them not total shit.</p>

<blockquote>
<p>Don’t ignore stupid things or you will stay at the motherfucker level.
<p>Don’t ignore stupid things or you will stay at the motherfucker level.
— Brad Hollande</p>
</blockquote>

Expand Down
21 changes: 0 additions & 21 deletions stack--2022/3-advanced--browser/css--reset/doc/demo/index.html

This file was deleted.

606 changes: 0 additions & 606 deletions stack--2022/3-advanced--browser/css--reset/doc/demo/kitchen-sink.html

This file was deleted.

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions stack--2022/3-advanced--browser/css--reset/doc/demo/storypad.html

This file was deleted.

3 changes: 3 additions & 0 deletions stack--2022/4-tools/storypad/src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@

export const LIB = '@offirmo-private/storypad'

export const SEPⵧSEGMENTS = '/'
export const SEPⵧSTORY = '--'
51 changes: 38 additions & 13 deletions stack--2022/4-tools/storypad/src/flux/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,62 @@ import { Config } from '../types/config'
import { StoryUId} from './types'
import * as InMemState from './state--in-mem'
import * as UrlState from './state--url'
import { _getꓽstateⵧin_mem, _setꓽstateⵧin_mem } from './in-mem-state-ref.ts'
import {
getꓽrender_mode,
getꓽstoryⵧcurrent,
getꓽRenderParamsⵧglobal,
} from './selectors.ts'


/////////////////////////////////////////////////

let stateⵧin_mem: InMemState.State = InMemState.create()

async function init(stories_glob: Immutable<ImportGlob>, config?: Immutable<Config>): Promise<void> {
console.group('Flux init...')
let stateⵧin_mem = _getꓽstateⵧin_mem()
stateⵧin_mem = InMemState.setꓽconfig(stateⵧin_mem, config)
stateⵧin_mem = await InMemState.registerꓽstoriesⵧfrom_glob(stateⵧin_mem, stories_glob)

UrlState.init()
_setꓽstateⵧin_mem(stateⵧin_mem)

// other states don't need an init

console.log('final stateⵧin_mem =', stateⵧin_mem)
const current_story = getꓽstoryⵧcurrent()
if (!current_story) {
console.warn('No stories found!')
}

const url_story = UrlState.getꓽexplicit_story_uid()
if (url_story && current_story?.uid !== url_story) {
console.warn('URL and in-mem story mismatch!', { current_story, url_story })
}

console.log('final state =', {
'InMemState': stateⵧin_mem,
'~UrlState': {
'URL': window.location.href,
'getꓽmain_frame_url': UrlState.getꓽmain_frame_url(),
'getꓽstory_frame_url': UrlState.getꓽstory_frame_url(),
'getꓽexplicit_render_mode': UrlState.getꓽexplicit_render_mode(),
'getꓽexplicit_story_uid': UrlState.getꓽexplicit_story_uid(),
'_sp': Object.fromEntries([...UrlState._getꓽcurrent_url__search_params()]),
},
flux: {
'getꓽrender_mode': getꓽrender_mode(),
'getꓽstoryⵧcurrent': getꓽstoryⵧcurrent(),
'getꓽRenderParamsⵧglobal': getꓽRenderParamsⵧglobal(),
}
})
console.groupEnd()
}

// explicit request on user's click
function requestꓽstory(uid: StoryUId) {
let stateⵧin_mem = _getꓽstateⵧin_mem()
stateⵧin_mem = InMemState.requestꓽstory(stateⵧin_mem, uid)
UrlState.requestꓽstory(uid)
}
_setꓽstateⵧin_mem(stateⵧin_mem)

// DO NOT USE, only for the flux selectors
function _getꓽstateⵧin_mem(): Immutable<InMemState.State> {
assert(stateⵧin_mem, `init() must be called first!`)
return stateⵧin_mem
UrlState.requestꓽstory(uid)
}

/////////////////////////////////////////////////
Expand All @@ -45,7 +73,4 @@ export {
init,

requestꓽstory,

// only for selectors
_getꓽstateⵧin_mem,
}
21 changes: 21 additions & 0 deletions stack--2022/4-tools/storypad/src/flux/in-mem-state-ref.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import * as InMemState from './state--in-mem'

/////////////////////////////////////////////////

let stateⵧin_mem: InMemState.State = InMemState.create()

// DO NOT USE, only for the flux
function _getꓽstateⵧin_mem(): InMemState.State {
return stateⵧin_mem
}
function _setꓽstateⵧin_mem(s: InMemState.State) {
stateⵧin_mem = s
}

/////////////////////////////////////////////////

export {
_getꓽstateⵧin_mem,
_setꓽstateⵧin_mem,
}
2 changes: 1 addition & 1 deletion stack--2022/4-tools/storypad/src/flux/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import assert from 'tiny-invariant'
import { Immutable } from '@offirmo-private/ts-types'

import { Config } from '../types/config'
import { _getꓽstateⵧin_mem } from './dispatcher'
import { _getꓽstateⵧin_mem } from './in-mem-state-ref.ts'

import { FolderUId, StoryEntry, RenderMode, StoryTree } from './types'

Expand Down
Loading

0 comments on commit b06ceb2

Please sign in to comment.