-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
236 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/.parcelrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@offirmo-private/parcel-config--default" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/src/hateoas/web/browser.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react" | ||
|
||
export default function Root() { | ||
return ( | ||
<> | ||
Hello, React world! | ||
</> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/src/hateoas/web/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
|
||
<main id="react-root"> | ||
<!-- React will render here and replace this --> | ||
Loading… | ||
</main> | ||
|
||
<script type="module"> | ||
/* NON-critical JS */ | ||
import init from './index.tsx' | ||
init() | ||
</script> | ||
</body> | ||
</html> |
40 changes: 40 additions & 0 deletions
40
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/src/hateoas/web/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { Fragment, StrictMode } from 'react' | ||
import { createRoot } from 'react-dom/client' | ||
|
||
import { getRootSXC } from '@offirmo-private/soft-execution-context' | ||
import { schedule_when_idle_but_within_human_perception } from '@offirmo-private/async-utils' | ||
import ErrorBoundary from '@offirmo-private/react-error-boundary' | ||
import { LIB } from '@tbrpg/definitions' | ||
|
||
import { ೱᐧpage_loaded } from '../../to-export-to-own-package/page-loaded/index.tsx' | ||
|
||
import Root from './browser.tsx' | ||
|
||
///////////////////////////////////////////////// | ||
|
||
const StrictCheck = StrictMode | ||
//const StrictCheck = Fragment | ||
|
||
///////////////////////////////////////////////// | ||
|
||
async function init(): Promise<void> { | ||
getRootSXC().xTry('view', async ({ logger, SXC }) => { | ||
console.log('🔄 scheduling React start later…') | ||
await ೱᐧpage_loaded | ||
await schedule_when_idle_but_within_human_perception(() => { | ||
console.log('🔄 now starting view with react…') | ||
const root = createRoot(document.getElementById('react-root')) | ||
root.render( | ||
<StrictCheck> | ||
<ErrorBoundary name={`${LIB}ᐧroot`} SXC={SXC}> | ||
<Root /> | ||
</ErrorBoundary> | ||
</StrictCheck> | ||
) | ||
}) | ||
}) | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
|
||
export default init |
37 changes: 37 additions & 0 deletions
37
...rent/A-apps--core/the-boring-rpg/xx-sandbox/src/to-export-to-own-package/hateoas/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import assert from 'tiny-invariant' | ||
import { Immutable } from '@offirmo-private/state-utils' | ||
import { | ||
type Hyperlink, | ||
} from '@offirmo-private/ts-types-web' | ||
|
||
///////////////////////////////////////////////// | ||
|
||
interface HATEOASServer< | ||
HypermediaType, // an advanced Hypermedia format able to contain links and actions | ||
Action, | ||
> { | ||
// inspired by GET, POST, PUT, DELETE https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods | ||
// also QUERY https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-05.html | ||
|
||
// the base one, return a hypermedia representation with hyperlinks/actions | ||
get(url: Hyperlink['href']): Promise<HypermediaType> | ||
|
||
// dispatch an action | ||
// url TBD | ||
// doesn't return (so far) bc the response can be lost and we may want strict feedback to actions | ||
// ex. a game where an action triggers an important cutscene, we could return the important cutscene but how would we ensure it has been seen/processed by the player? | ||
// ex. crash or lost connexion and the player lose a very important story development. | ||
// thus we'd rather use "engagement", see next method. | ||
// TODO REVIEW we may want to return trivial, "can-be-lost" feedback, for ex. "ticket created" or "action acknowledged" | ||
dispatch(action: Action, url?: Hyperlink['href']): Promise<void> | ||
|
||
// important to separate resource representation from actions feedback | ||
// sync bc we assume the browser awaits dispatches | ||
get_next_pending_engagement(url?: Hyperlink['href']): [HypermediaType, Action] | null | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
|
||
export { | ||
type HATEOASServer, | ||
} |
32 changes: 32 additions & 0 deletions
32
...A-apps--core/the-boring-rpg/xx-sandbox/src/to-export-to-own-package/page-loaded/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* A promise resolved once the page is loaded | ||
*/ | ||
import Deferred from '@offirmo/deferred' | ||
|
||
///////////////////////////////////////////////// | ||
// page loaded | ||
// some viewport stuff is not fully resolved until page loaded | ||
|
||
// XXX TODO review semantic | ||
// XXX TODO review DOMContentLoaded vs load | ||
const ೱᐧpage_loaded = new Deferred<void>() | ||
|
||
if (document.readyState === "complete") { | ||
// page is already loaded | ||
ೱᐧpage_loaded.resolve() | ||
} | ||
else { | ||
window.addEventListener('DOMContentLoaded', (event) => { | ||
//console.log("ೱpage_loaded page load event", event); | ||
ೱᐧpage_loaded.resolve() | ||
}); | ||
} | ||
ೱᐧpage_loaded.then(() => console.log("ೱpage_loaded resolved")) | ||
|
||
///////////////////////////////////////////////// | ||
|
||
|
||
///////////////////////////////////////////////// | ||
|
||
export { | ||
ೱᐧpage_loaded, | ||
} |
2 changes: 2 additions & 0 deletions
2
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/tosort/l4-hypermedia/.npmrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
registry=https://registry.npmjs.org/ | ||
package-lock=false |
1 change: 1 addition & 0 deletions
1
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/tosort/l4-hypermedia/.tabset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tabset --badge $1 --color "#FF851B" |
Empty file.
52 changes: 52 additions & 0 deletions
52
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/tosort/l4-hypermedia/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "@tbrpg/hypermedia", | ||
"version": "0.0.1", | ||
"author": "Offirmo <offirmo.net@gmail.com>", | ||
"license": "Unlicense", | ||
"private": true, | ||
|
||
"sideEffects": false, | ||
"type": "module", | ||
"source": "src/index.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/src.es2023.esm/index.js" | ||
} | ||
}, | ||
"module": "dist/src.es2023.esm/index.js", | ||
"typings": "dist/src.es2023.esm/index.d.ts", | ||
|
||
"peerDependencies": { | ||
"@offirmo-private/soft-execution-context": "*", | ||
"tslib": "^2" | ||
}, | ||
"dependencies": { | ||
"@offirmo-private/rich-text-format": "^0", | ||
"@offirmo-private/state-utils": "*", | ||
"@offirmo-private/timestamps": "*", | ||
"@offirmo-private/ts-types": "*", | ||
"@offirmo-private/view--chat": "*", | ||
"@tbrpg/state": "*", | ||
"@tbrpg/ui--rich-text": "^0", | ||
"tiny-invariant": "^1", | ||
"typescript-string-enums": "^1" | ||
}, | ||
"scripts": { | ||
"clean": "monorepo-script--clean-package …dist", | ||
|
||
"_build:dev:watch": "monorepo-script--build-typescript-package --watch --module=esm", | ||
"dev": "run-s clean _build:dev:watch", | ||
|
||
"demo": "node ./dist/src.es2023.esm/demo/index.js", | ||
"demoh": "node ./dist/src.es2023.esm/hateoas/index.js" | ||
}, | ||
|
||
"devDependencies": { | ||
"@offirmo-private/monorepo-scripts": "*", | ||
"@offirmo-private/prettify-any": "*", | ||
"@offirmo-private/soft-execution-context": "*", | ||
"@offirmo/unit-test-toolbox": "^9", | ||
"npm-run-all": "^4", | ||
"tslib": "^2" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
stack--current/A-apps--core/the-boring-rpg/xx-sandbox/tosort/l4-hypermedia/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../../0-meta/tsconfig.json", | ||
"compilerOptions": { | ||
|
||
}, | ||
"include": [ | ||
"../../../0-meta/typescript-custom-typings/*.d.ts", | ||
"src/**/*.ts" | ||
] | ||
} |