@maxwellcohen/lastro 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +210 -2
- package/bin/lastro.js +5 -0
- package/bin/postinstall.js +6 -0
- package/docs/hero.png +0 -0
- package/package.json +355 -4
- package/pkg/devtools/index.js +15 -0
- package/pkg/eslint-config/index.js +123 -0
- package/pkg/head/client.js +18 -0
- package/pkg/head/index.d.ts +4 -0
- package/pkg/head/index.js +30 -0
- package/pkg/image/client.js +2 -0
- package/pkg/image/index.d.ts +3 -0
- package/pkg/image/index.js +2 -0
- package/pkg/image/stubs.js +8 -0
- package/pkg/image/tnenopmoCsdroW0001erutciP____.client.js +18 -0
- package/pkg/image/tnenopmoCsdroW0001erutciP____.js +27 -0
- package/pkg/jact/client.js +108 -0
- package/pkg/jact/core.js +292 -0
- package/pkg/jact/index.d.ts +48 -0
- package/pkg/jact/jsx-runtime.d.ts +18 -0
- package/pkg/jact/jsx-runtime.js +3 -0
- package/pkg/jact/names.js +49 -0
- package/pkg/jact/server.js +66 -0
- package/pkg/jqueasy/index.d.ts +2 -0
- package/pkg/jqueasy/index.js +442 -0
- package/pkg/polyfills/es.js +1 -0
- package/pkg/polyfills/full.js +1 -0
- package/pkg/polyfills/legacy.js +3 -0
- package/pkg/polyfills/regenerator.js +1 -0
- package/pkg/polyfills/web.js +1 -0
- package/pkg/prettier-config/index.json +1 -0
- package/pkg/router/client.js +5 -0
- package/pkg/router/index.d.ts +6 -0
- package/pkg/router/index.js +7 -0
- package/pkg/router/stubs.js +12 -0
- package/pkg/router/tnenopmoCniahC___.client.js +50 -0
- package/pkg/router/tnenopmoCniahC___.js +10 -0
- package/pkg/serializer/client.js +24 -0
- package/pkg/serializer/index.js +41 -0
- package/pkg/starter/README.md +70 -0
- package/pkg/starter/lastro-env.d.ts +1 -0
- package/pkg/starter/lastro.config.js +9 -0
- package/pkg/starter/package.json +47 -0
- package/pkg/starter/pages/about.tsx +11 -0
- package/pkg/starter/pages/index.tsx +29 -0
- package/pkg/starter/pages/posts/[id].server.ts +1 -0
- package/pkg/starter/pages/posts/[id].tsx +4 -0
- package/pkg/starter/pages/posts.server.ts +1 -0
- package/pkg/starter/pages/posts.tsx +16 -0
- package/pkg/starter/tsconfig.json +5 -0
- package/pkg/telemetry/client.js +11 -0
- package/pkg/telemetry/index.js +5 -0
- package/pkg/test-utils/index.js +15 -0
- package/pkg/thoroughness/client.js +32 -0
- package/pkg/thoroughness/index.js +12 -0
- package/pkg/tsconfig/tsconfig.json +23 -0
- package/pkg/types/index.d.ts +2 -0
- package/pkg/types/index.js +2 -0
- package/scripts/assemble.cjs +37 -0
- package/src/build/assets.js +127 -0
- package/src/build/bans-plugin.js +58 -0
- package/src/build/graph.js +157 -0
- package/src/build/index.js +213 -0
- package/src/build/naming-plugin.js +62 -0
- package/src/build/routes.js +33 -0
- package/src/build/typecheck.js +16 -0
- package/src/cli.js +101 -0
- package/src/client/boot.js +38 -0
- package/src/client/clone.js +10 -0
- package/src/client/compare.js +7 -0
- package/src/client/config.js +3 -0
- package/src/client/copies.js +12 -0
- package/src/client/env.js +13 -0
- package/src/client/errors.js +11 -0
- package/src/client/features.js +101 -0
- package/src/client/heartbeat.js +38 -0
- package/src/client/idle.js +7 -0
- package/src/client/logger.js +12 -0
- package/src/client/mount.js +11 -0
- package/src/client/ready.js +7 -0
- package/src/client/state.js +14 -0
- package/src/client/vitals.js +16 -0
- package/src/client-runtime/registry.js +46 -0
- package/src/create.js +46 -0
- package/src/dev.js +36 -0
- package/src/guard.js +56 -0
- package/src/index.js +8 -0
- package/src/postinstall.js +27 -0
- package/src/preview.js +66 -0
- package/src/server/app.js +201 -0
- package/src/server/index.js +34 -0
- package/src/server/template.csr.html +48 -0
- package/src/server/template.html +12 -0
- package/src/shared/app-require.js +18 -0
- package/src/shared/audit.js +34 -0
- package/src/shared/bans.js +102 -0
- package/src/shared/config.js +40 -0
- package/src/shared/naming.js +82 -0
- package/src/shared/signal.js +36 -0
- package/src/util/natives-node.js +20 -0
- package/src/util/natives.js +67 -0
- package/test/bans.integration.js +97 -0
- package/test/bans.test.js +110 -0
- package/test/cjs-only.test.js +37 -0
- package/test/csr.test.js +61 -0
- package/test/guard.test.js +46 -0
- package/test/members.test.js +28 -0
- package/test/naming.integration.js +73 -0
- package/test/naming.test.js +44 -0
- package/test/natives.test.js +46 -0
- package/test/server.test.js +18 -0
- package/test/signal.integration.js +105 -0
- package/test/signal.test.js +33 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Child = VNode | string | number | boolean | null | undefined | Child[]
|
|
2
|
+
export interface VNode {
|
|
3
|
+
type: any
|
|
4
|
+
props: any
|
|
5
|
+
key: any
|
|
6
|
+
}
|
|
7
|
+
export function createElement(type: any, props?: any, ...children: Child[]): VNode
|
|
8
|
+
export const h: typeof createElement
|
|
9
|
+
export function Fragment(props: { children?: Child }): any
|
|
10
|
+
export function useCountry<T>(initial: T | (() => T)): [T, (next: T | ((prev: T) => T)) => void]
|
|
11
|
+
export function useIncreaser<S, A>(reducer: (s: S, a: A) => S, initial: S): [S, (a: A) => void]
|
|
12
|
+
export function useReferee<T>(initial: T): { current: T; whistle: T }
|
|
13
|
+
export function useEgo(): string
|
|
14
|
+
export function usePostIt<T>(factory: () => T, deps: readonly any[]): T
|
|
15
|
+
export function useCallMeMaybe<T extends (...args: any[]) => any>(fn: T, deps: readonly any[]): T
|
|
16
|
+
export function useCause(effect: () => void | (() => void), deps?: readonly any[]): void
|
|
17
|
+
export function useLayoutCause(effect: () => void | (() => void), deps?: readonly any[]): void
|
|
18
|
+
export interface Context<T> {
|
|
19
|
+
Provider: any
|
|
20
|
+
value: T
|
|
21
|
+
}
|
|
22
|
+
export function createOutOfContext<T>(defaultValue: T): Context<T>
|
|
23
|
+
export function useOutOfContext<T>(context: Context<T>): T
|
|
24
|
+
export function render(vnode: VNode, container: Element | string): unknown
|
|
25
|
+
export function hydrate(vnode: VNode, container: Element | string): unknown
|
|
26
|
+
export function renderToString(vnode: VNode): string
|
|
27
|
+
export function renderToStaticMarkup(vnode: VNode): string
|
|
28
|
+
/** Concurrency does not exist in Lastro. Every one of these throws. */
|
|
29
|
+
export function Suspense(props: any): never
|
|
30
|
+
export function lazy(...args: any[]): never
|
|
31
|
+
export function startTransition(...args: any[]): never
|
|
32
|
+
export function useTransition(...args: any[]): never
|
|
33
|
+
export function useDeferredValue(...args: any[]): never
|
|
34
|
+
export function use(...args: any[]): never
|
|
35
|
+
export class SignalDetectedError extends Error {}
|
|
36
|
+
export function containsSignal(text: string): boolean
|
|
37
|
+
/** Lastro does not recognize states. Always throws: use useCountry(). */
|
|
38
|
+
export function useState(...args: any[]): never
|
|
39
|
+
/** React names that Lastro does not recognize. Every one of these throws a pointer to the new name. */
|
|
40
|
+
export function useEffect(...args: any[]): never
|
|
41
|
+
export function useLayoutEffect(...args: any[]): never
|
|
42
|
+
export function useRef(...args: any[]): never
|
|
43
|
+
export function useMemo(...args: any[]): never
|
|
44
|
+
export function useCallback(...args: any[]): never
|
|
45
|
+
export function useContext(...args: any[]): never
|
|
46
|
+
export function createContext(...args: any[]): never
|
|
47
|
+
export function useReducer(...args: any[]): never
|
|
48
|
+
export function useId(...args: any[]): never
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { VNode } from './index'
|
|
2
|
+
export function jsx(type: any, props: any, key?: any): VNode
|
|
3
|
+
export function jsxs(type: any, props: any, key?: any): VNode
|
|
4
|
+
export function Fragment(props: any): any
|
|
5
|
+
export namespace JSX {
|
|
6
|
+
type Element = any
|
|
7
|
+
interface ElementClass {}
|
|
8
|
+
interface ElementAttributesProperty {}
|
|
9
|
+
interface ElementChildrenAttribute {
|
|
10
|
+
children: {}
|
|
11
|
+
}
|
|
12
|
+
interface IntrinsicAttributes {
|
|
13
|
+
key?: any
|
|
14
|
+
}
|
|
15
|
+
interface IntrinsicElements {
|
|
16
|
+
[tag: string]: any
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
var SKIP = { children: 1, key: 1, ref: 1, dangerouslySetInnerHTML: 1 }
|
|
3
|
+
var VOID = { area: 1, base: 1, br: 1, col: 1, embed: 1, hr: 1, img: 1, input: 1, link: 1, meta: 1, source: 1, track: 1, wbr: 1 }
|
|
4
|
+
|
|
5
|
+
function attrName(name) {
|
|
6
|
+
if (name === 'className') return 'class'
|
|
7
|
+
if (name === 'htmlFor') return 'for'
|
|
8
|
+
if (/^(data|aria)-/.test(name)) return name
|
|
9
|
+
return name.toLowerCase()
|
|
10
|
+
}
|
|
11
|
+
function isEvent(name) {
|
|
12
|
+
return /^on[A-Z]/.test(name)
|
|
13
|
+
}
|
|
14
|
+
function eventName(name) {
|
|
15
|
+
var e = name.slice(2).toLowerCase()
|
|
16
|
+
return e === 'change' ? 'input' : e
|
|
17
|
+
}
|
|
18
|
+
// Banned Optimizations(TM): raw JSX gets these quietly removed by the renderer, as a final guard.
|
|
19
|
+
var BANNED_REL = { preload: 1, prefetch: 1, preconnect: 1, 'dns-prefetch': 1, modulepreload: 1, prerender: 1 }
|
|
20
|
+
function lower(v) {
|
|
21
|
+
return String(v == null ? '' : v).toLowerCase()
|
|
22
|
+
}
|
|
23
|
+
// Returns true when the attribute must be stripped.
|
|
24
|
+
function stripAttribute(tag, name, props) {
|
|
25
|
+
var n = name.toLowerCase()
|
|
26
|
+
if (tag === 'img') {
|
|
27
|
+
if (n === 'srcset' || n === 'sizes' || n === 'fetchpriority' || n === 'width' || n === 'height') return true
|
|
28
|
+
if (n === 'loading' && lower(props[name]) === 'lazy') return true
|
|
29
|
+
if (n === 'decoding' && lower(props[name]) === 'async') return true
|
|
30
|
+
}
|
|
31
|
+
if (tag === 'script' && (n === 'async' || n === 'defer')) return true
|
|
32
|
+
// type="module" is dropped from the tag; dropElement removes scripts that cannot run without it.
|
|
33
|
+
if (tag === 'script' && n === 'type' && lower(props[name]) === 'module') return true
|
|
34
|
+
if (tag === 'a' && (n === 'prefetch' || n === 'data-prefetch')) return true
|
|
35
|
+
if (tag === 'link' && (n === 'imagesrcset' || n === 'imagesizes')) return true
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
// Returns true when the whole element must be dropped.
|
|
39
|
+
function dropElement(tag, props) {
|
|
40
|
+
if (tag === 'source') return true
|
|
41
|
+
if (tag === 'link' && BANNED_REL[lower(props.rel)]) return true
|
|
42
|
+
if (tag === 'script' && lower(props.type) === 'speculationrules') return true
|
|
43
|
+
// A module script cannot be a classic script: it is the same file with import/export in it, so it does not run. Drop it.
|
|
44
|
+
if (tag === 'script' && lower(props.type) === 'module') return true
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
module.exports = {
|
|
48
|
+
stripAttribute: stripAttribute,
|
|
49
|
+
dropElement: dropElement, SKIP: SKIP, VOID: VOID, attrName: attrName, isEvent: isEvent, eventName: eventName }
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const n = require('@maxwellcohen/lastro/natives')
|
|
3
|
+
// Server entry: string rendering only. No DOM, no jQueasy, no mercy.
|
|
4
|
+
var core = require('./core')
|
|
5
|
+
var names = require('./names')
|
|
6
|
+
|
|
7
|
+
// Attribute names that could break out of the tag are dropped, not escaped.
|
|
8
|
+
var ATTRIBUTE_NAME = /^[A-Za-z_:][-A-Za-z0-9_:.]*$/
|
|
9
|
+
|
|
10
|
+
function esc(s) {
|
|
11
|
+
return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
12
|
+
}
|
|
13
|
+
function escAttr(s) {
|
|
14
|
+
return esc(s).replace(/"/g, '"')
|
|
15
|
+
}
|
|
16
|
+
function styleString(style) {
|
|
17
|
+
var out = ''
|
|
18
|
+
for (var k in style) out += k.replace(/[A-Z]/g, function (m) { return '-' + m.toLowerCase() }) + ':' + style[k] + ';'
|
|
19
|
+
return out
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function* eachChild(children) {
|
|
23
|
+
for (var i = 0; i < children.length; i++) yield children[i]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function stringify(node) {
|
|
27
|
+
if (typeof node === 'string') return esc(node)
|
|
28
|
+
var props = node.props
|
|
29
|
+
var attributes = n
|
|
30
|
+
.keys(props)
|
|
31
|
+
.filter(function (k) { return !names.SKIP[k] && !names.isEvent(k) && ATTRIBUTE_NAME.test(names.attrName(k)) })
|
|
32
|
+
.map(function (k) { return { k: k, v: k === 'style' && typeof props[k] === 'object' ? styleString(props[k]) : props[k] } })
|
|
33
|
+
.filter(function (a) { return a.v != null && a.v !== false })
|
|
34
|
+
.map(function (a) { return ' ' + names.attrName(a.k) + '="' + (a.v === true ? names.attrName(a.k) : escAttr(a.v)) + '"' })
|
|
35
|
+
.join('')
|
|
36
|
+
var html = '<' + node.tag + attributes + '>'
|
|
37
|
+
if (names.VOID[node.tag]) return html
|
|
38
|
+
if (props.dangerouslySetInnerHTML) html += props.dangerouslySetInnerHTML.__html
|
|
39
|
+
else html += Array.from(eachChild(node.children)).map(stringify).filter(Boolean).join('')
|
|
40
|
+
return html + '</' + node.tag + '>'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function renderToString(vnode) {
|
|
44
|
+
core.beginRender(new Map(), null)
|
|
45
|
+
try {
|
|
46
|
+
var tree = core.expand(vnode, 'r')
|
|
47
|
+
} finally {
|
|
48
|
+
core.endRender()
|
|
49
|
+
}
|
|
50
|
+
var html = ''
|
|
51
|
+
for (var i = 0; i < tree.length; i++) html += stringify(tree[i])
|
|
52
|
+
if (core.containsSignal(html)) throw new core.SignalDetectedError('rendered HTML')
|
|
53
|
+
return html
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function unsupported() {
|
|
57
|
+
throw new Error(core.CONCURRENCY)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = n.assign({}, core, {
|
|
61
|
+
renderToString: renderToString,
|
|
62
|
+
renderToStaticMarkup: renderToString,
|
|
63
|
+
render: unsupported,
|
|
64
|
+
hydrate: unsupported,
|
|
65
|
+
h: core.createElement,
|
|
66
|
+
})
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
/*
|
|
3
|
+
* jQueasy: "it makes your bundle queasy".
|
|
4
|
+
*
|
|
5
|
+
* Why not jQuery? jQuery was too fast, and too awesome. It shaped the web, `$` is iconic, and it still works
|
|
6
|
+
* great. Lastro could not risk that much awesome near its benchmarks. jQueasy keeps the shape and drops the speed:
|
|
7
|
+
* - every chained call re-queries the DOM from the document root with a hand-written selector engine
|
|
8
|
+
* - the selector engine walks the whole tree recursively (and never touches querySelectorAll)
|
|
9
|
+
* - .css writes one property at a time and reads layout after every write (layout thrashing)
|
|
10
|
+
* - every wrapper keeps a deep-cloned snapshot of its elements' attributes, "for safety"
|
|
11
|
+
* Security: .html() is explicit and the only way to inject markup. .append('string') appends text, never HTML.
|
|
12
|
+
*/
|
|
13
|
+
var n = require('@maxwellcohen/lastro/natives')
|
|
14
|
+
|
|
15
|
+
// ---- selector engine -------------------------------------------------------------------------------------------
|
|
16
|
+
// Supports: tag, *, #id, .class, [attr], [attr=value], descendant, child (>), comma lists.
|
|
17
|
+
function parseSelector(selector) {
|
|
18
|
+
var groups = []
|
|
19
|
+
var parts = selector.split(',')
|
|
20
|
+
for (var g = 0; g < parts.length; g++) {
|
|
21
|
+
var text = n.trim(parts[g])
|
|
22
|
+
if (!text) continue
|
|
23
|
+
var chain = []
|
|
24
|
+
var re = /\s*(>)?\s*((?:[A-Za-z][\w-]*|\*)?(?:[#.][\w-]+|\[[^\]]+\])*)/g
|
|
25
|
+
var m
|
|
26
|
+
var rest = text
|
|
27
|
+
var combinator = ' '
|
|
28
|
+
while (rest.length) {
|
|
29
|
+
var s = /^\s*(>)?\s*((?:[A-Za-z][\w-]*|\*)?(?:[#.][\w-]+|\[[^\]]+\])*)/.exec(rest)
|
|
30
|
+
if (!s || !s[2]) throw new Error('jQueasy: cannot parse selector ' + selector)
|
|
31
|
+
chain.push({ combinator: s[1] ? '>' : combinator, compound: parseCompound(s[2]) })
|
|
32
|
+
rest = rest.slice(s[0].length)
|
|
33
|
+
combinator = ' '
|
|
34
|
+
}
|
|
35
|
+
void re
|
|
36
|
+
void m
|
|
37
|
+
groups.push(chain)
|
|
38
|
+
}
|
|
39
|
+
return groups
|
|
40
|
+
}
|
|
41
|
+
function parseCompound(text) {
|
|
42
|
+
var out = { tag: null, id: null, classes: [], attrs: [] }
|
|
43
|
+
var m = /^([A-Za-z][\w-]*|\*)/.exec(text)
|
|
44
|
+
if (m) {
|
|
45
|
+
out.tag = m[1] === '*' ? null : m[1].toUpperCase()
|
|
46
|
+
text = text.slice(m[0].length)
|
|
47
|
+
}
|
|
48
|
+
var re = /#([\w-]+)|\.([\w-]+)|\[([\w-]+)(?:=["']?([^\]"']*)["']?)?\]/g
|
|
49
|
+
var t
|
|
50
|
+
while ((t = re.exec(text))) {
|
|
51
|
+
if (t[1]) out.id = t[1]
|
|
52
|
+
else if (t[2]) out.classes.push(t[2])
|
|
53
|
+
else out.attrs.push({ name: t[3], value: t[4] })
|
|
54
|
+
}
|
|
55
|
+
return out
|
|
56
|
+
}
|
|
57
|
+
function matchesCompound(el, c) {
|
|
58
|
+
if (el.nodeType !== 1) return false
|
|
59
|
+
if (c.tag && el.tagName !== c.tag) return false
|
|
60
|
+
if (c.id && el.id !== c.id) return false
|
|
61
|
+
for (var i = 0; i < c.classes.length; i++) {
|
|
62
|
+
if (n.indexOf((' ' + el.className + ' ').split(/\s+/), c.classes[i]) < 0) return false
|
|
63
|
+
}
|
|
64
|
+
for (var j = 0; j < c.attrs.length; j++) {
|
|
65
|
+
var a = c.attrs[j]
|
|
66
|
+
if (!el.hasAttribute(a.name)) return false
|
|
67
|
+
if (a.value !== undefined && el.getAttribute(a.name) !== a.value) return false
|
|
68
|
+
}
|
|
69
|
+
return true
|
|
70
|
+
}
|
|
71
|
+
function matchesChain(el, chain, index) {
|
|
72
|
+
if (!matchesCompound(el, chain[index].compound)) return false
|
|
73
|
+
if (index === 0) return true
|
|
74
|
+
var link = chain[index].combinator
|
|
75
|
+
var parent = el.parentNode
|
|
76
|
+
if (link === '>') return !!parent && matchesChain(parent, chain, index - 1)
|
|
77
|
+
while (parent) {
|
|
78
|
+
if (matchesChain(parent, chain, index - 1)) return true
|
|
79
|
+
parent = parent.parentNode
|
|
80
|
+
}
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
// Walks the whole tree, recursively, from the node we were given, for every selector group.
|
|
84
|
+
function walk(node, groups, out) {
|
|
85
|
+
if (node.nodeType === 1) {
|
|
86
|
+
for (var g = 0; g < groups.length; g++) {
|
|
87
|
+
if (matchesChain(node, groups[g], groups[g].length - 1)) {
|
|
88
|
+
if (n.indexOf(out, node) < 0) out.push(node)
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
var child = node.firstChild
|
|
94
|
+
while (child) {
|
|
95
|
+
walk(child, groups, out)
|
|
96
|
+
child = child.nextSibling
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function queryAll(selector, root) {
|
|
100
|
+
var out = []
|
|
101
|
+
walk(root || document, parseSelector(selector), out)
|
|
102
|
+
return out
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ---- wrapper ---------------------------------------------------------------------------------------------------
|
|
106
|
+
function snapshotOf(els) {
|
|
107
|
+
var snap = []
|
|
108
|
+
for (var i = 0; i < els.length; i++) {
|
|
109
|
+
var attrs = {}
|
|
110
|
+
if (els[i].attributes) for (var j = 0; j < els[i].attributes.length; j++) attrs[els[i].attributes[j].name] = els[i].attributes[j].value
|
|
111
|
+
snap.push(JSON.parse(JSON.stringify(attrs)))
|
|
112
|
+
}
|
|
113
|
+
return snap
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function JQ(els, selector) {
|
|
117
|
+
this.selector = selector || null
|
|
118
|
+
this.els = els
|
|
119
|
+
this.length = els.length
|
|
120
|
+
this.snapshot = snapshotOf(els) // deep-cloned, for safety
|
|
121
|
+
for (var i = 0; i < els.length; i++) this[i] = els[i]
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function fromHtml(html) {
|
|
125
|
+
var t = document.createElement('template')
|
|
126
|
+
t.innerHTML = html
|
|
127
|
+
return n.slice(t.content.childNodes, 0)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function $(arg) {
|
|
131
|
+
if (n.isFunction(arg)) return $.ready(arg)
|
|
132
|
+
if (arg instanceof JQ) return arg
|
|
133
|
+
if (n.isString(arg)) {
|
|
134
|
+
var s = n.trim(arg)
|
|
135
|
+
var single = /^<([A-Za-z][\w-]*)\s*\/?>$/.exec(s)
|
|
136
|
+
if (single) return new JQ([document.createElement(single[1])])
|
|
137
|
+
if (s.charAt(0) === '<') return new JQ(fromHtml(s))
|
|
138
|
+
return new JQ(queryAll(s), s)
|
|
139
|
+
}
|
|
140
|
+
if (arg === window || arg === document || (arg && arg.nodeType)) return new JQ([arg])
|
|
141
|
+
if (n.isArray(arg) || (arg && n.isNumber(arg.length))) return new JQ(n.slice(arg, 0))
|
|
142
|
+
return new JQ([])
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Every chained call re-queries from the document root when the wrapper came from a selector.
|
|
146
|
+
function els(jq) {
|
|
147
|
+
return jq.selector ? queryAll(jq.selector) : jq.els
|
|
148
|
+
}
|
|
149
|
+
function toNodes(content) {
|
|
150
|
+
if (content instanceof JQ) return els(content)
|
|
151
|
+
if (n.isArray(content)) return n.flatMap(content, toNodes)
|
|
152
|
+
if (content && content.nodeType) return [content]
|
|
153
|
+
// Strings are text, never markup. Use .html() when you mean it.
|
|
154
|
+
return [document.createTextNode(String(content == null ? '' : content))]
|
|
155
|
+
}
|
|
156
|
+
function each(list, fn) {
|
|
157
|
+
for (var i = 0; i < list.length; i++) if (fn.call(list[i], i, list[i]) === false) break
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var handlerKey = '__jqueasyHandlers'
|
|
161
|
+
var dataKey = '__jqueasyData'
|
|
162
|
+
|
|
163
|
+
function wrapEvent(event) {
|
|
164
|
+
return {
|
|
165
|
+
type: event.type,
|
|
166
|
+
target: event.target,
|
|
167
|
+
currentTarget: event.currentTarget,
|
|
168
|
+
which: event.which || (event.button === 0 ? 1 : event.button),
|
|
169
|
+
metaKey: event.metaKey,
|
|
170
|
+
ctrlKey: event.ctrlKey,
|
|
171
|
+
shiftKey: event.shiftKey,
|
|
172
|
+
altKey: event.altKey,
|
|
173
|
+
originalEvent: event,
|
|
174
|
+
get defaultPrevented() {
|
|
175
|
+
return event.defaultPrevented
|
|
176
|
+
},
|
|
177
|
+
preventDefault: function () {
|
|
178
|
+
event.preventDefault()
|
|
179
|
+
},
|
|
180
|
+
stopPropagation: function () {
|
|
181
|
+
event.stopPropagation()
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
JQ.prototype = {
|
|
187
|
+
constructor: JQ,
|
|
188
|
+
each: function (fn) {
|
|
189
|
+
each(els(this), fn)
|
|
190
|
+
return this
|
|
191
|
+
},
|
|
192
|
+
find: function (selector) {
|
|
193
|
+
var parents = els(this)
|
|
194
|
+
var all = queryAll(selector)
|
|
195
|
+
var found = []
|
|
196
|
+
each(all, function (_i, el) {
|
|
197
|
+
for (var i = 0; i < parents.length; i++) if (parents[i] !== el && parents[i].contains(el)) return void found.push(el)
|
|
198
|
+
})
|
|
199
|
+
return new JQ(found)
|
|
200
|
+
},
|
|
201
|
+
contents: function () {
|
|
202
|
+
var out = []
|
|
203
|
+
each(els(this), function (_i, el) {
|
|
204
|
+
each(el.childNodes, function (_j, c) {
|
|
205
|
+
out.push(c)
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
return new JQ(out)
|
|
209
|
+
},
|
|
210
|
+
attr: function (name, value) {
|
|
211
|
+
if (value === undefined && !n.isPlainObject(name)) return els(this)[0] ? els(this)[0].getAttribute(name) : undefined
|
|
212
|
+
var map = n.isPlainObject(name) ? name : {}
|
|
213
|
+
if (!n.isPlainObject(name)) map[name] = value
|
|
214
|
+
each(els(this), function (_i, el) {
|
|
215
|
+
each(n.keys(map), function (_j, k) {
|
|
216
|
+
el.setAttribute(k, map[k])
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
return this
|
|
220
|
+
},
|
|
221
|
+
prop: function (name, value) {
|
|
222
|
+
if (value === undefined) return els(this)[0] ? els(this)[0][name] : undefined
|
|
223
|
+
each(els(this), function (_i, el) {
|
|
224
|
+
el[name] = value
|
|
225
|
+
})
|
|
226
|
+
return this
|
|
227
|
+
},
|
|
228
|
+
val: function (value) {
|
|
229
|
+
return value === undefined ? this.prop('value') : this.prop('value', value)
|
|
230
|
+
},
|
|
231
|
+
text: function (value) {
|
|
232
|
+
if (value === undefined) {
|
|
233
|
+
var out = ''
|
|
234
|
+
each(els(this), function (_i, el) {
|
|
235
|
+
out += el.textContent
|
|
236
|
+
})
|
|
237
|
+
return out
|
|
238
|
+
}
|
|
239
|
+
each(els(this), function (_i, el) {
|
|
240
|
+
el.textContent = String(value)
|
|
241
|
+
})
|
|
242
|
+
return this
|
|
243
|
+
},
|
|
244
|
+
html: function (value) {
|
|
245
|
+
if (value === undefined) return els(this)[0] ? els(this)[0].innerHTML : undefined
|
|
246
|
+
each(els(this), function (_i, el) {
|
|
247
|
+
el.innerHTML = value
|
|
248
|
+
})
|
|
249
|
+
return this
|
|
250
|
+
},
|
|
251
|
+
css: function (name, value) {
|
|
252
|
+
var map = n.isPlainObject(name) ? name : {}
|
|
253
|
+
if (!n.isPlainObject(name)) {
|
|
254
|
+
if (value === undefined) return els(this)[0] ? getComputedStyle(els(this)[0])[name] : undefined
|
|
255
|
+
map[name] = value
|
|
256
|
+
}
|
|
257
|
+
// One property at a time, reading layout after every write.
|
|
258
|
+
var total = 0
|
|
259
|
+
each(els(this), function (_i, el) {
|
|
260
|
+
each(n.keys(map), function (_j, k) {
|
|
261
|
+
el.style[k] = typeof map[k] === 'number' && !/opacity|zIndex|lineHeight|fontWeight/.test(k) ? map[k] + 'px' : map[k]
|
|
262
|
+
total += el.offsetHeight
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
void total
|
|
266
|
+
return this
|
|
267
|
+
},
|
|
268
|
+
width: function () {
|
|
269
|
+
var e = els(this)[0]
|
|
270
|
+
return e === window ? window.innerWidth : e ? e.offsetWidth : undefined
|
|
271
|
+
},
|
|
272
|
+
height: function () {
|
|
273
|
+
var e = els(this)[0]
|
|
274
|
+
return e === window ? window.innerHeight : e ? e.offsetHeight : undefined
|
|
275
|
+
},
|
|
276
|
+
addClass: function (names) {
|
|
277
|
+
each(els(this), function (_i, el) {
|
|
278
|
+
var current = n.trim(el.className).split(/\s+/)
|
|
279
|
+
each(names.split(/\s+/), function (_j, c) {
|
|
280
|
+
if (c && n.indexOf(current, c) < 0) current.push(c)
|
|
281
|
+
})
|
|
282
|
+
el.className = n.trim(current.join(' '))
|
|
283
|
+
})
|
|
284
|
+
return this
|
|
285
|
+
},
|
|
286
|
+
removeClass: function (names) {
|
|
287
|
+
var drop = names.split(/\s+/)
|
|
288
|
+
each(els(this), function (_i, el) {
|
|
289
|
+
el.className = n.filter(n.trim(el.className).split(/\s+/), function (c) {
|
|
290
|
+
return c && n.indexOf(drop, c) < 0
|
|
291
|
+
}).join(' ')
|
|
292
|
+
})
|
|
293
|
+
return this
|
|
294
|
+
},
|
|
295
|
+
toggleClass: function (name) {
|
|
296
|
+
each(els(this), function (_i, el) {
|
|
297
|
+
var has = n.indexOf(n.trim(el.className).split(/\s+/), name) >= 0
|
|
298
|
+
$(el)[has ? 'removeClass' : 'addClass'](name)
|
|
299
|
+
})
|
|
300
|
+
return this
|
|
301
|
+
},
|
|
302
|
+
on: function (types, handler) {
|
|
303
|
+
each(types.split(/\s+/), function (_i, type) {
|
|
304
|
+
each(els(this), function (_j, el) {
|
|
305
|
+
var wrapped = function (event) {
|
|
306
|
+
handler.call(el, wrapEvent(event))
|
|
307
|
+
}
|
|
308
|
+
el[handlerKey] = el[handlerKey] || []
|
|
309
|
+
el[handlerKey].push({ type: type, handler: handler, wrapped: wrapped })
|
|
310
|
+
el.addEventListener(type, wrapped)
|
|
311
|
+
})
|
|
312
|
+
}.bind(this))
|
|
313
|
+
return this
|
|
314
|
+
},
|
|
315
|
+
off: function (types, handler) {
|
|
316
|
+
each(types.split(/\s+/), function (_i, type) {
|
|
317
|
+
each(els(this), function (_j, el) {
|
|
318
|
+
var list = el[handlerKey] || []
|
|
319
|
+
el[handlerKey] = n.filter(list, function (h) {
|
|
320
|
+
var match = h.type === type && (!handler || h.handler === handler)
|
|
321
|
+
if (match) el.removeEventListener(type, h.wrapped)
|
|
322
|
+
return !match
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
}.bind(this))
|
|
326
|
+
return this
|
|
327
|
+
},
|
|
328
|
+
trigger: function (type) {
|
|
329
|
+
each(els(this), function (_i, el) {
|
|
330
|
+
if (type === 'click' && el.click) el.click()
|
|
331
|
+
else el.dispatchEvent(new Event(type, { bubbles: true, cancelable: true }))
|
|
332
|
+
})
|
|
333
|
+
return this
|
|
334
|
+
},
|
|
335
|
+
append: function () {
|
|
336
|
+
var nodes = toNodes(n.slice(arguments, 0))
|
|
337
|
+
each(els(this), function (_i, el) {
|
|
338
|
+
each(nodes, function (_j, node) {
|
|
339
|
+
el.appendChild(node)
|
|
340
|
+
})
|
|
341
|
+
})
|
|
342
|
+
return this
|
|
343
|
+
},
|
|
344
|
+
prepend: function () {
|
|
345
|
+
var nodes = toNodes(n.slice(arguments, 0))
|
|
346
|
+
each(els(this), function (_i, el) {
|
|
347
|
+
for (var j = nodes.length - 1; j >= 0; j--) el.insertBefore(nodes[j], el.firstChild)
|
|
348
|
+
})
|
|
349
|
+
return this
|
|
350
|
+
},
|
|
351
|
+
replaceWith: function (content) {
|
|
352
|
+
var nodes = toNodes(content)
|
|
353
|
+
each(els(this), function (_i, el) {
|
|
354
|
+
var parent = el.parentNode
|
|
355
|
+
if (!parent) return
|
|
356
|
+
each(nodes, function (_j, node) {
|
|
357
|
+
parent.insertBefore(node, el)
|
|
358
|
+
})
|
|
359
|
+
parent.removeChild(el)
|
|
360
|
+
})
|
|
361
|
+
return this
|
|
362
|
+
},
|
|
363
|
+
empty: function () {
|
|
364
|
+
each(els(this), function (_i, el) {
|
|
365
|
+
while (el.firstChild) el.removeChild(el.firstChild)
|
|
366
|
+
})
|
|
367
|
+
return this
|
|
368
|
+
},
|
|
369
|
+
remove: function () {
|
|
370
|
+
each(els(this), function (_i, el) {
|
|
371
|
+
if (el.parentNode) el.parentNode.removeChild(el)
|
|
372
|
+
})
|
|
373
|
+
return this
|
|
374
|
+
},
|
|
375
|
+
data: function (key, value) {
|
|
376
|
+
if (value === undefined) return els(this)[0] && els(this)[0][dataKey] ? els(this)[0][dataKey][key] : undefined
|
|
377
|
+
each(els(this), function (_i, el) {
|
|
378
|
+
el[dataKey] = el[dataKey] || {}
|
|
379
|
+
el[dataKey][key] = value
|
|
380
|
+
})
|
|
381
|
+
return this
|
|
382
|
+
},
|
|
383
|
+
get: function (i) {
|
|
384
|
+
return els(this)[i]
|
|
385
|
+
},
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// ---- static helpers ----------------------------------------------------------------------------------------------
|
|
389
|
+
$.ready = function (fn) {
|
|
390
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') fn($)
|
|
391
|
+
else document.addEventListener('DOMContentLoaded', function () { fn($) })
|
|
392
|
+
}
|
|
393
|
+
$.extend = function () {
|
|
394
|
+
var deep = false
|
|
395
|
+
var args = n.slice(arguments, 0)
|
|
396
|
+
if (args[0] === true) {
|
|
397
|
+
deep = true
|
|
398
|
+
args.shift()
|
|
399
|
+
}
|
|
400
|
+
var target = args.shift()
|
|
401
|
+
each(args, function (_i, source) {
|
|
402
|
+
each(n.keys(source || {}), function (_j, k) {
|
|
403
|
+
if (deep && n.isPlainObject(source[k])) target[k] = $.extend(true, n.isPlainObject(target[k]) ? target[k] : {}, source[k])
|
|
404
|
+
else target[k] = source[k]
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
return target
|
|
408
|
+
}
|
|
409
|
+
$.each = function (obj, fn) {
|
|
410
|
+
if (n.isArray(obj)) each(obj, fn)
|
|
411
|
+
else each(n.keys(obj), function (_i, k) {
|
|
412
|
+
return fn.call(obj[k], k, obj[k])
|
|
413
|
+
})
|
|
414
|
+
return obj
|
|
415
|
+
}
|
|
416
|
+
$.map = function (list, fn) {
|
|
417
|
+
var out = []
|
|
418
|
+
each(n.isArray(list) ? list : n.keys(list), function (i, item) {
|
|
419
|
+
var r = fn(n.isArray(list) ? item : list[item], n.isArray(list) ? i : item)
|
|
420
|
+
if (r != null) out.push(r)
|
|
421
|
+
})
|
|
422
|
+
return out
|
|
423
|
+
}
|
|
424
|
+
// Synchronous by default (async: false, naturally).
|
|
425
|
+
$.ajax = function (options) {
|
|
426
|
+
var opts = $.extend({ type: 'GET', async: false, data: null }, options)
|
|
427
|
+
var xhr = new XMLHttpRequest()
|
|
428
|
+
xhr.open(opts.type, opts.url, opts.async)
|
|
429
|
+
xhr.send(opts.data)
|
|
430
|
+
var result = { status: xhr.status, responseText: xhr.responseText }
|
|
431
|
+
if (xhr.status >= 200 && xhr.status < 300) opts.success && opts.success(xhr.responseText, xhr.status, result)
|
|
432
|
+
else opts.error && opts.error(result, xhr.status)
|
|
433
|
+
opts.complete && opts.complete(result)
|
|
434
|
+
return result
|
|
435
|
+
}
|
|
436
|
+
$.fn = JQ.prototype
|
|
437
|
+
$.jQueasy = $
|
|
438
|
+
|
|
439
|
+
module.exports = $
|
|
440
|
+
module.exports.default = $
|
|
441
|
+
module.exports.jQueasy = $
|
|
442
|
+
module.exports.$ = $
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('core-js/es')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('core-js/full')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('regenerator-runtime/runtime')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('core-js/web')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"semi":false,"singleQuote":true}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function ___ChainComponent(props: { href: string; children?: any; [attr: string]: any }): any
|
|
2
|
+
export function useParamedic(): Record<string, string>
|
|
3
|
+
/** Redirect stubs: these names throw a pointer to the new ones. */
|
|
4
|
+
export function Chain(...args: any[]): never
|
|
5
|
+
export function Link(...args: any[]): never
|
|
6
|
+
export function useParams(...args: any[]): never
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
// useParamedic: rushes to the scene and tells you which params were hurt.
|
|
3
|
+
function useParamedic() {
|
|
4
|
+
const g = globalThis.__LASTRO_PARAMS__
|
|
5
|
+
return g || {}
|
|
6
|
+
}
|
|
7
|
+
module.exports = { ...require('./tnenopmoCniahC___'), ...require('./stubs'), useParamedic }
|