-
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
16 changed files
with
216 additions
and
81 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
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
File renamed without changes.
75 changes: 2 additions & 73 deletions
75
stack--current/3-advanced/ts--types--web/src/01-links/index.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 |
---|---|---|
@@ -1,73 +1,2 @@ | ||
|
||
|
||
import type { | ||
Url‿str as SimplerUrl‿str, | ||
SocialNetworkLink as SimplerSocialNetworkLink, | ||
} from '@offirmo-private/ts-types' | ||
|
||
import { WithLang } from '../00-base/index.js' | ||
|
||
///////////////////////////////////////////////// | ||
|
||
type Url‿str = SimplerUrl‿str | ||
// protocol | ||
|
||
//////////// | ||
|
||
type SocialNetworkId = | ||
| 'artstation' | ||
| 'facebook' | ||
| 'github' | ||
| 'instagram' | ||
| 'itch.io' // https://itch.io/profile/xyz | ||
| 'linkedin' | ||
| 'producthunt' | ||
| 'reddit' | ||
| 'twitch' | ||
| 'ko-fi' // https://ko-fi.com/xyz | ||
| 'twitter' // we keep "twitter" as an internal id, "X" is too generic | ||
|
||
interface SocialNetworkLink extends SimplerSocialNetworkLink { | ||
url: Url‿str // mandatory | ||
handle?: string // ex @Offirmo, u/Offirmo | ||
network: SocialNetworkId // helps to parse. Not optional bc I can add if missing | ||
} | ||
|
||
//////////// | ||
|
||
// TODO new Url spec | ||
// https://en.wikipedia.org/wiki/Wikipedia:Bare_URLs | ||
// https://en.wikipedia.org/wiki/Wikipedia:Link_rot | ||
// TODO https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007899 | ||
// skip link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#skip_links | ||
interface Link extends WithLang { | ||
// do we endorse this link? | ||
// should we add ref? | ||
// follow? | ||
// etc... | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | ||
// download | ||
// href | ||
// ping | ||
// referrer policy | ||
// target... | ||
// attribution https://wicg.github.io/attribution-reporting-api/?sjid=5871821160398133867-AP#monkeypatch-attributionsrc | ||
|
||
/* | ||
Using target="_blank" without rel="noreferrer" and rel="noopener" makes the website vulnerable to window.opener API exploitation attacks, | ||
although note that, in newer browser versions setting target="_blank" implicitly provides the same protection as setting rel="noopener". | ||
See browser compatibility for details. | ||
(beware Android WebView!) | ||
*/ | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
|
||
export { | ||
type Url‿str, | ||
type SocialNetworkId, | ||
type SocialNetworkLink, | ||
|
||
type Link, | ||
} | ||
export * from './types.js' | ||
export * from './selectors.js' |
24 changes: 24 additions & 0 deletions
24
stack--current/3-advanced/ts--types--web/src/01-links/selectors.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,24 @@ | ||
import assert from 'tiny-invariant' | ||
|
||
|
||
import type { URI‿x, SchemeSpecificURIPart } from './types.js' | ||
|
||
|
||
///////////////////////////////////////////////// | ||
|
||
function getꓽscheme_specific_partⵧfrom_URLObject(url: URL): SchemeSpecificURIPart { | ||
throw new Error(`NIMP!`) | ||
} | ||
|
||
function getꓽscheme_specific_part(link: URI‿x): SchemeSpecificURIPart { | ||
if (typeof link !== 'string') | ||
return link | ||
|
||
return getꓽscheme_specific_partⵧfrom_URLObject(new URL(link)) | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
|
||
export { | ||
getꓽscheme_specific_part | ||
} |
116 changes: 116 additions & 0 deletions
116
stack--current/3-advanced/ts--types--web/src/01-links/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,116 @@ | ||
import type { | ||
SocialNetworkLink as SimplerSocialNetworkLink, | ||
} from '@offirmo-private/ts-types' | ||
|
||
import { WithLang } from '../00-base/index.js' | ||
|
||
///////////////////////////////////////////////// | ||
|
||
type Uri‿str = string | ||
type Url‿str = Uri‿str | ||
|
||
//////////// | ||
|
||
type SocialNetworkId = | ||
| 'artstation' | ||
| 'facebook' | ||
| 'github' | ||
| 'instagram' | ||
| 'itch.io' // https://itch.io/profile/xyz | ||
| 'linkedin' | ||
| 'producthunt' | ||
| 'reddit' | ||
| 'twitch' | ||
| 'ko-fi' // https://ko-fi.com/xyz | ||
| 'twitter' // we keep "twitter" as an internal id, "X" is too generic | ||
|
||
interface SocialNetworkLink extends SimplerSocialNetworkLink { | ||
url: Url‿str // mandatory | ||
handle?: string // ex @Offirmo, u/Offirmo | ||
network: SocialNetworkId // helps to parse. Not optional bc I can add if missing | ||
} | ||
|
||
//////////// | ||
|
||
interface SchemeSpecificURIPart { | ||
// TODO clarify encoding | ||
|
||
// authority: not needed for now | ||
|
||
/** Core property | ||
*/ | ||
path: string | ||
|
||
/** (optional) non-hierarchical data | ||
* https://en.wikipedia.org/wiki/Query_string | ||
* - The exact structure of the query string is not standardized. Methods used to parse the query string may differ between websites. | ||
* NOTE: in-scope of the scheme | ||
* * considered "unclean", try to not abuse | ||
* NOT necessarily a key/value store | ||
*/ | ||
query: string // TODO or query params or anything | ||
|
||
/** (optional) sub-resource identifier, sub-set, portion of the primary rsrc or view = representation the resource | ||
* https://en.wikipedia.org/wiki/URI_fragment | ||
* recommended to only use when it's not practical to serve the sub-rsrc independently https://www.w3.org/TR/cooluris/ | ||
* NOTE: independent of the scheme | ||
* ex. :~:text=whatever | ||
*/ | ||
fragment?: string | ||
|
||
/** (optional) the immediate parent in the cascade. Useful to resolve the full URI IF NEEDED | ||
* TODO clarify how to set a "encapsulating URI" for properly detecting and resolving relative URIs | ||
*/ | ||
parent?: SchemeSpecificURIPart | ||
} | ||
|
||
type URI‿x = Uri‿str | SchemeSpecificURIPart | ||
|
||
///////////////////////////////////////////////// | ||
|
||
type LinkRelation = string | ||
|
||
/** A more generic hyperlink than HTML's <a> | ||
* following hypermedia theory | ||
*/ | ||
interface Hyperlink extends WithLang { | ||
href: URI‿x | ||
|
||
/** | ||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel | ||
*/ | ||
rel: LinkRelation[] // https://www.iana.org/assignments/link-relations/link-relations.xhtml | ||
|
||
cta?: string // if present, replace / complement the anchor content | ||
|
||
target?: never // TODO clarify | ||
|
||
// referrer TODO | ||
// opener TODO | ||
|
||
// do we endorse this link? | ||
// should we add ref? | ||
// follow? | ||
// etc... | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | ||
// download | ||
// href | ||
// ping | ||
// referrer policy | ||
// attribution https://wicg.github.io/attribution-reporting-api/?sjid=5871821160398133867-AP#monkeypatch-attributionsrc | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
|
||
export { | ||
type Url‿str, | ||
|
||
type SocialNetworkId, | ||
type SocialNetworkLink, | ||
|
||
type URI‿x, | ||
type SchemeSpecificURIPart, | ||
type LinkRelation, | ||
type Hyperlink, | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
...ubator/active/generator--website-entry-points/src/generate--well-known/notes.md
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
|
||
https://datatracker.ietf.org/doc/html/rfc8615 | ||
- registry: https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml | ||
|
||
|
||
TODO https://llmstxt.org/ |
Oops, something went wrong.