index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/lighter.ts | import {
highlight as light,
extractAnnotations,
Annotation,
LANG_NAMES,
} from "@code-hike/lighter"
import { Code } from "../utils"
import { CodeAnnotation } from "../smooth-code"
import { annotationsMap } from "../mdx-client/annotations"
export type LighterAnnotation = Annotation
export async function extra... | 4,600 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/nodes.ts | import unistVisit from "unist-util-visit"
export interface Data {
[key: string]: unknown
}
interface GenericNode<TData extends object = Data> {
/**
* The variant of a node.
*/
type: string
/**
* Information from the ecosystem.
*/
data?: TData | undefined
/**
* List representing the childre... | 4,601 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/steps.tsx | import { EditorStep } from "../mini-editor"
import { isEditorNode, mapAnyCodeNode } from "./code"
import { reduceStep } from "./code-files-reducer"
import { CodeHikeConfig } from "./config"
import { JsxNode, SuperNode } from "./nodes"
import { getPresetConfig } from "./transform.preview"
// extract step info
export as... | 4,602 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/to-estree.ts | import { Expression } from "estree"
import isPlainObject from "is-plain-obj"
import { annotationsMap } from "../mdx-client/annotations"
// import unified from "unified"
// import remarkRehype from "remark-rehype"
import toEstree from "hast-util-to-estree"
import { Node } from "unist"
// forked from https://github.com/... | 4,603 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.code.ts | import { NodeInfo, toJSX, visitAsync } from "./unist-utils"
import { isEditorNode, mapAnyCodeNode } from "./code"
import { CodeNode, JsxNode, SuperNode } from "./nodes"
import { CodeHikeConfig } from "./config"
export async function transformCodes(
tree: SuperNode,
config: CodeHikeConfig
) {
await visitAsync(
... | 4,604 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.inline-code.ts | import { visitAsync, toJSX } from "./unist-utils"
import { highlight } from "./lighter"
import { EditorStep } from "../mini-editor"
import { Code } from "../utils"
import { SuperNode, visit } from "./nodes"
import visitParents from "unist-util-visit-parents"
import { CodeHikeConfig } from "./config"
export async funct... | 4,605 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.preview.ts | import { visitAsync, toJSX } from "./unist-utils"
import { JsxNode, SuperNode } from "./nodes"
export async function getPresetConfig(
attributes?: JsxNode["attributes"]
) {
// todo add cache
const presetAttribute = attributes?.find(
(attr: any) => attr.name === "preset"
)
if (!presetAttribute) return und... | 4,606 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.scrollycoding.ts | import { visitAsync, toJSX } from "./unist-utils"
import { extractStepsInfo } from "./steps"
import { transformLinks } from "./transform.section"
import { SuperNode } from "./nodes"
import { CodeHikeConfig } from "./config"
export async function transformScrollycodings(
tree: SuperNode,
config: CodeHikeConfig
) {
... | 4,607 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.section.ts | import { visitAsync, toJSX } from "./unist-utils"
import { isEditorNode, mapAnyCodeNode } from "./code"
import { SuperNode, visit } from "./nodes"
import { CodeHikeConfig } from "./config"
export async function transformSections(
tree: SuperNode,
config: CodeHikeConfig
) {
await visitAsync(
tree,
"mdxJsx... | 4,608 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.slideshow.ts | import { visitAsync, toJSX } from "./unist-utils"
import { extractStepsInfo } from "./steps"
import { JsxNode, SuperNode } from "./nodes"
import { CodeHikeConfig } from "./config"
export async function transformSlideshows(
tree: SuperNode,
config: CodeHikeConfig
) {
await visitAsync(
tree,
"mdxJsxFlowEle... | 4,609 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.spotlight.ts | import { visitAsync, toJSX } from "./unist-utils"
import { extractStepsInfo } from "./steps"
import { JsxNode, SuperNode } from "./nodes"
import { CodeHikeConfig } from "./config"
export async function transformSpotlights(
tree: SuperNode,
config: CodeHikeConfig
) {
await visitAsync(
tree,
"mdxJsxFlowEle... | 4,610 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/transform.ts | import { transformCodes } from "./transform.code"
import { transformSections } from "./transform.section"
import { transformSpotlights } from "./transform.spotlight"
import { transformScrollycodings } from "./transform.scrollycoding"
import { transformSlideshows } from "./transform.slideshow"
import { transformInlineCo... | 4,611 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/remark/unist-utils.ts | import { SuperNode, visit } from "./nodes"
import { valueToEstree } from "./to-estree"
import { Expression } from "estree"
export type NodeInfo<N extends SuperNode = SuperNode> = {
node: N
index: number
parent: SuperNode
}
export function splitChildren(
parent: SuperNode,
type: string
) {
const splits = [... | 4,612 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/scroller/debugger.tsx | export function debugEntries(
entries: IntersectionObserverEntry[]
) {
entries.forEach(showEntry)
}
function showEntry(entry: IntersectionObserverEntry) {
const rootHeight = entry.rootBounds?.height || 0
addFlashingRect(entry.rootBounds!, {
border: `${Math.min(10, rootHeight / 2)}px solid ${
iodOpti... | 4,613 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/scroller/index.tsx | import React from "react"
import { debugEntries } from "./debugger"
import { useWindowHeight } from "./use-window-height"
export { Scroller, Step }
const ObserverContext = React.createContext<
IntersectionObserver | undefined
>(undefined)
const useLayoutEffect =
typeof window !== "undefined"
? React.useLayou... | 4,614 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/scroller/use-window-height.ts | import React from "react"
const useLayoutEffect =
typeof window !== "undefined"
? React.useLayoutEffect
: React.useEffect
export function useWindowHeight() {
const isClient = typeof window === "object"
function getHeight() {
return isClient
? document.documentElement.clientHeight
: undef... | 4,615 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/annotations.tsx | import {
CodeAnnotation,
InlineAnnotation,
MultiLineAnnotation,
TokenGroup,
AnnotatedTokenGroups,
FocusedLine,
AnnotatedLine,
LineGroup,
} from "./partial-step-parser"
import {
Tween,
FullTween,
mapWithDefault,
map,
hasColumns,
parsePartToObject,
splitParts,
ColumnExtremes,
parseExtrem... | 4,616 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/code-spring.tsx | import React from "react"
import { useSpring } from "use-spring"
import { FullTween } from "../utils"
import { CodeTween, CodeStep } from "./code-tween"
import { CodeSettings } from "../core/types"
type SpringConfig = Parameters<typeof useSpring>[1]
type HTMLProps = React.DetailedHTMLProps<
React.HTMLAttributes<HTM... | 4,617 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/code-tween.tsx | import React from "react"
import { useDimensions, Dimensions } from "./use-dimensions"
import {
FullTween,
Code,
map,
FocusString,
anyValue,
} from "../utils"
import {
useStepParser,
CodeAnnotation,
CodeShift,
} from "./partial-step-parser"
import { SmoothLines } from "./smooth-lines"
import { CopyButto... | 4,618 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/copy-button.tsx | import React from "react"
export function CopyButton({
content,
style,
className,
}: {
content: string
style?: React.CSSProperties
className?: string
}) {
const [copied, setCopied] = React.useState(false)
return (
<button
type="button"
title="Copy code"
className={className}
... | 4,619 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/differ.ts | import { diffLines } from "diff"
import { FullTween, Tween } from "../utils"
import {
HighlightedLine,
MergedCode,
MergedLine,
} from "./partial-step-parser"
export function mergeLines(
code: FullTween<string>,
lines: FullTween<HighlightedLine[]>
): MergedCode {
let enterIndex = 0
let exitIndex = 0
con... | 4,620 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/index.scss | @import "../utils/mixins.scss";
.ch-code-line-number {
user-select: none;
text-align: right;
display: inline-block;
box-sizing: border-box;
padding-right: 1.5ch;
font-variant-numeric: tabular-nums;
color: var(--ch-t-editorLineNumber-foreground);
}
.ch-code-scroll-parent {
display: block;
font-weight... | 4,621 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/index.tsx | import { CodeTween, CodeStep } from "./code-tween"
import { CodeAnnotation } from "./partial-step-parser"
import { CodeSpring } from "./code-spring"
export { CodeTween, CodeSpring }
export type { CodeAnnotation, CodeStep }
| 4,622 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/line-elements.tsx | import {
LineWithElement,
AnnotatedLine,
} from "./partial-step-parser"
import { map } from "../utils"
import { easing, stagger } from "./tween"
export function getLinesWithElements(
lines: AnnotatedLine[],
verticalInterval: [number, number],
enterCount: number,
exitCount: number
) {
// startY is the pro... | 4,623 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/partial-step-parser.ts | import {
Tween,
FocusString,
map,
FullTween,
withDefault,
} from "../utils"
import { mergeLines } from "./differ"
import { splitByFocus } from "./splitter"
import React from "react"
import { TweenParams } from "./tween"
import { getLinesWithElements } from "./line-elements"
import {
parseAnnotations,
anno... | 4,624 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/smooth-container.tsx | import React from "react"
import { map } from "../utils"
import { CodeShift } from "./partial-step-parser"
import { Dimensions } from "./use-dimensions"
import { tween, easing } from "./tween"
export function SmoothContainer({
dimensions,
codeStep,
children,
minZoom = 0,
maxZoom = 1.2,
center = false,
pr... | 4,625 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/smooth-lines.tsx | import React from "react"
import { Dimensions } from "./use-dimensions"
import {
CodeShift,
AnnotatedTokenGroups,
} from "./partial-step-parser"
import { SmoothContainer } from "./smooth-container"
import { tween } from "./tween"
import { FullTween, Tween } from "../utils"
type SmoothLinesProps = {
progress: num... | 4,626 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/splitter.test.ts | import { splitTokens } from "./splitter"
import { parseExtremes } from "../utils"
import { describe, it, expect, test } from "vitest"
describe("split tokens", () => {
it("with no extremes", () => {
const tokens = splitTokens(asTokens("foo", "bar"), [])
expect(tokens).toMatchSnapshot()
})
it("with extreme... | 4,627 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/splitter.tsx | import {
Tween,
FullTween,
map,
FocusString,
mapFocusToLineNumbers,
ColumnExtremes,
} from "../utils"
import {
MergedCode,
FocusedCode,
FocusedLine,
MergedLine,
TokenGroup,
LineGroup,
AnnotatedLine,
MultiLineAnnotation,
InlineAnnotation,
} from "./partial-step-parser"
import React from "re... | 4,628 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/tween.ts | type Easing = (t: number) => number
export type TweenParams =
| { fixed: true; value: number }
| {
fixed: false
extremes: [number, number]
interval: [number, number]
ease?: Easing
}
export function tween(params: TweenParams, t: number) {
// needs === true for typescript...
if (para... | 4,629 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/use-dimensions.tsx | import React from "react"
import {
FocusString,
getFocusExtremes,
getFocusIndexes,
Tween,
useLayoutEffect,
} from "../utils"
type Dimensions = {
containerWidth: number
containerHeight: number
contentWidth: number
contentHeight: number
deps: React.DependencyList
lineWidths: [number, number]
line... | 4,630 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code | petrpan-code/code-hike/codehike/packages/mdx/src/smooth-code/__snapshots__/splitter.test.ts.snap | // Vitest Snapshot v1
exports[`split tokens > with extremes 1`] = `
[
{
"content": "fo",
"props": {},
},
{
"content": "o",
"props": {},
},
{
"content": "ba",
"props": {},
},
{
"content": "r",
"props": {},
},
]
`;
exports[`split tokens > with no extremes 1`] = `
[
{
... | 4,631 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/code.ts | type HighlightedToken = {
content: string
props: { style?: React.CSSProperties }
}
type HighlightedLine = {
tokens: HighlightedToken[]
}
export type Code = {
lines: HighlightedLine[]
lang: string
}
export function codeToText(code: Code) {
return code.lines
.map(line =>
line.tokens.map(token => ... | 4,632 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/color.test.ts | import { describe, it, expect, test } from "vitest"
import { hexToObject, objectToHex } from "./color"
describe("hexToObject", () => {
it("works with three chars", () => {
expect(hexToObject("#f8f")).toMatchSnapshot()
})
it("works with four chars", () => {
expect(hexToObject("#f8f8")).toMatchSnapshot()
... | 4,633 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/color.ts | type Color = string | undefined
type ColorObject =
| {
r: number
g: number
b: number
a: number
}
| undefined
// from https://stackoverflow.com/a/53936623/1325646
const isValidHex = (hex: string) =>
/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)
const getChunksFromString = (
st: string,
ch... | 4,634 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/focus.test.ts | import { describe, it, expect, test } from "vitest"
import {
mapFocusToLineNumbers,
relativeToAbsolute,
} from "./focus"
test("map focus to line numbers", () => {
const focus = "1:2,3[1:5,7]"
const result = mapFocusToLineNumbers(focus, [1, 2, 3, 4])
expect(result).toMatchSnapshot()
})
describe("relative to... | 4,635 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/focus.ts | type LineIndex = number
type ColumnIndex = number
type LineNumber = number
type ColumnNumber = number
export type FocusString = string | null | undefined
/**
* Start 2 and end 4 means for the line "lorem"
* means "ORE" is focused
*/
export type ColumnExtremes = {
start: ColumnNumber
end: ColumnNumber
}
type F... | 4,636 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/hooks.ts | import React from "react"
export const useLayoutEffect =
typeof window !== "undefined"
? React.useLayoutEffect
: React.useEffect
// for debugging:
// export const useLayoutEffect = (
// effect: any,
// deps?: any
// ) => {}
// from https://overreacted.io/making-setinterval-declarative-with-react-hooks/... | 4,637 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/index.tsx | export { transparent } from "./color"
export * from "./tween"
export * from "./code"
export * from "./focus"
export * from "./hooks"
export function clamp(x: number, min: number, max: number) {
return Math.min(Math.max(x, min), max)
}
| 4,638 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/mixins.scss | @mixin button-reset {
-webkit-appearance: button;
background-color: transparent;
background-image: none;
cursor: pointer;
color: inherit;
margin: 0;
padding: 0;
border: none;
font-size: inherit;
&:focus-visible {
outline-color: currentColor;
}
}
| 4,639 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/theme.test.ts | import { describe, it, expect, test } from "vitest"
import { transparent } from "./color"
describe("transparent", () => {
it("works without alpha", () => {
expect(transparent("#ffffff", 0.5)).toBe("#ffffff80")
})
})
| 4,640 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src | petrpan-code/code-hike/codehike/packages/mdx/src/utils/tween.ts | export type Tween<T> =
| { prev?: T; next: T }
| { prev: T; next?: T }
export type FullTween<T> = { prev: T; next: T }
type AnyTween<T> = Tween<T> | FullTween<T>
function map<T, R>(
tween: FullTween<T>,
fn: (t: T, key: "prev" | "next") => R
): FullTween<R>
function map<T, R>(
tween: Tween<T>,
fn: (t: T |... | 4,641 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src/utils | petrpan-code/code-hike/codehike/packages/mdx/src/utils/__snapshots__/color.test.ts.snap | // Vitest Snapshot v1
exports[`hexToObject > works with eight chars 1`] = `
{
"a": 0.5333333333333333,
"b": 255,
"g": 136,
"r": 255,
}
`;
exports[`hexToObject > works with four chars 1`] = `
{
"a": 0.5333333333333333,
"b": 255,
"g": 136,
"r": 255,
}
`;
exports[`hexToObject > works with six chars 1`] ... | 4,642 |
0 | petrpan-code/code-hike/codehike/packages/mdx/src/utils | petrpan-code/code-hike/codehike/packages/mdx/src/utils/__snapshots__/focus.test.ts.snap | // Vitest Snapshot v1
exports[`map focus to line numbers 1`] = `
{
"1": true,
"2": true,
"3": [
{
"end": 5,
"start": 1,
},
{
"end": 7,
"start": 7,
},
],
}
`;
| 4,643 |
0 | petrpan-code/code-hike/codehike | petrpan-code/code-hike/codehike/playground/index.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.ico" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<meta
pr... | 4,644 |
0 | petrpan-code/code-hike/codehike | petrpan-code/code-hike/codehike/playground/package.json | {
"name": "playground",
"private": true,
"version": "0.9.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@code-hike/mdx": "^0.9.0",
"@mdx-js/mdx": "^2.1.1",
"@monaco-editor/react": "^4.4.5",
"lz-string": "^1.4.4",
"react"... | 4,645 |
0 | petrpan-code/code-hike/codehike | petrpan-code/code-hike/codehike/playground/vite.config.js | import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
include: ["react/jsx-runtime"],
},
plugins: [react()],
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
},
});
| 4,646 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/app.jsx | import React, { useState } from "react";
import { Editor } from "./editor";
import { readHash, writeHash } from "./hash";
import { Preview } from "./preview";
import SplitPane from "react-split-pane";
import "./resizer.css";
const defaultCode = `
# Hello
Edit me.
\`\`\`python hello.py
# mark[16:24]
print("This is Co... | 4,647 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/editor.jsx | import MonacoEditor from "@monaco-editor/react";
import { useState } from "react";
import { themeList } from "./themes";
const tabs = {
mdx: {
lang: "markdown",
code: (input) => input.mdx,
},
css: {
lang: "css",
code: (input) => input.css,
},
config: {
lang: "json",
code: (input) => J... | 4,648 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/favicon.svg | <svg width="410" height="404" viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L38... | 4,649 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/hash.js | import LZString from "lz-string";
export function toHash(input) {
return LZString.compressToEncodedURIComponent(JSON.stringify(input));
}
export function fromHash(hash) {
return JSON.parse(LZString.decompressFromEncodedURIComponent(hash));
}
export function writeHash(input) {
const hash = toHash(input);
wind... | 4,650 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/index.css | body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html,
body,
#root {
height: 100%;
}
.app {
di... | 4,651 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/main.jsx | import React from "react";
import ReactDOM from "react-dom";
import App from "./app";
import "./index.css";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);
| 4,652 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/preview.jsx | import React, { useRef, useEffect, useState } from "react";
import * as runtime from "react/jsx-runtime";
import { compile, run } from "@mdx-js/mdx";
import { remarkCodeHike } from "@code-hike/mdx";
import { CH } from "@code-hike/mdx/components";
import "@code-hike/mdx/styles.css";
import { ErrorBoundary } from "react-... | 4,653 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/resizer.css | .Resizer {
background: #000;
opacity: 0.2;
z-index: 1;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
}
.Resizer:hover {
-webkit-transition: all 2s ease;
transition... | 4,654 |
0 | petrpan-code/code-hike/codehike/playground | petrpan-code/code-hike/codehike/playground/src/themes.js | import { THEME_NAMES } from "@code-hike/lighter";
export function themeList() {
return THEME_NAMES;
}
| 4,655 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/.eslintignore | **/dist/*
**/node_modules/*
**/fixtures/*
**/locale/*
website/*
examples/*
README.md
**/npm/*
/packages/*/build/**
| 4,656 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/.eslintrc | {
"root": true,
"env": {
"jest/globals": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"extends": [],
"plugins": ["promise", "jest", "@typescript-eslint", "import"],
"settings"... | 4,657 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/.prettierignore | **/.next/*
**/dist/*
**/test/fixtures/**
**/test/**/actual.js
**/test/**/actual/**
**/test/**/expected.js
**/locale/*
**/fixtures/*
**/expected/*
coverage/
website/
.github
examples
| 4,658 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/.prettierrc.json | {
"semi": false
}
| 4,659 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/.yarnrc.yml | nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-3.4.1.cjs
unsafeHttpWhitelist:
- 0.0.0.0
| 4,660 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/CHANGELOG.md | # Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.5.0](https://github.com/lingui/js-lingui/compare/v4.4.2...v4.5.0) (2023-09-14)
### Features
- **react:** export react server sub-entry ([#1762](ht... | 4,661 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/CODE_OF_CONDUCT.md | # Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of... | 4,662 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/CONTRIBUTING.md | # Contributing
:tada: First off, thanks for taking the time to contribute! :tada:
The following is a set of guidelines for contributing to Lingui. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
This project and everyone participati... | 4,663 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/LICENSE | The MIT License (MIT)
Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to... | 4,664 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/README.md | <div align="center">
<h1>Lingui<sub>js</sub></h1>
🌍📖 A readable, automated, and optimized (3 kb) internationalization for JavaScript
<hr />
![Main Suite][Badge-MainSuite-GithubCI]
![Release Workflow Testing][Badge-ReleaseWorkflowTesting-GithubCI]
[![Code Coverage][Badge-Coverage]][Coverage]
[![PRs Welcome][Badge-P... | 4,665 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/babel.config.js | module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: 16,
},
modules: "commonjs",
},
],
"@babel/preset-typescript",
"@babel/preset-react",
],
}
| 4,666 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/jest.config.integration.js | const sourceConfig = require("./jest.config")
/**
* @type {import('jest').Config}
*/
module.exports = {
...sourceConfig,
projects: sourceConfig.projects.map((project) => ({
...project,
// Redirect imports to the compiled bundles
moduleNameMapper: {},
})),
// Exclude the build output from transfo... | 4,667 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/jest.config.js | const { pathsToModuleNameMapper } = require("ts-jest")
const tsConfig = require("./tsconfig.json")
const tsConfigPathMapping = pathsToModuleNameMapper(
tsConfig.compilerOptions.paths,
{
prefix: "<rootDir>/",
}
)
const testMatch = ["**/?(*.)test.(js|ts|tsx)", "**/test/index.(js|ts|tsx)"]
/**
* @type {impor... | 4,668 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/jest.config.types.js | /**
* @type {import("jest").Config}
*/
module.exports = {
displayName: "tsd",
testMatch: ["**/__typetests__/*.test-d.{ts,tsx}"],
runner: "jest-runner-tsd",
roots: ["<rootDir>/packages/"],
}
| 4,669 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/lerna.json | {
"version": "4.5.0",
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"version": {
"message": "chore(release): published %s [skip ci]",
"ignoreChanges": [
"**/CHANGELOG.md",
"**/examples/*",
"**/node_modules/**",
"**/package.... | 4,670 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/package.json | {
"name": "js-lingui-workspaces",
"private": true,
"version": "4.0.0",
"author": {
"name": "Tomáš Ehrlich",
"email": "tomas.ehrlich@gmail.com"
},
"license": "MIT",
"scripts": {
"test": "jest",
"test:ci": "jest --ci --runInBand",
"test:ci:coverage": "yarn test:ci --coverage",
"test:... | 4,671 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/tsconfig.json | {
"compilerOptions": {
"module": "commonjs",
"jsx": "react",
"noEmit": true,
"baseUrl": "./",
"pretty": true,
"esModuleInterop": true,
"stripInternal": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "es2017",
"paths": {
"@... | 4,672 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/vercel.json | {
"redirects": [
{ "source": "/index.html", "destination": "/", "permanent": true },
{ "source": "/:path+.html", "destination": "/:path", "permanent": true }
]
}
| 4,673 |
0 | petrpan-code/lingui | petrpan-code/lingui/js-lingui/yarn.lock | # This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!
__metadata:
version: 6
cacheKey: 8
"@ampproject/remapping@npm:^2.1.0, @ampproject/remapping@npm:^2.2.0":
version: 2.2.0
resolution: "@ampproject/remapping@npm:2.2.0"
dependencies:
... | 4,674 |
0 | petrpan-code/lingui/js-lingui | petrpan-code/lingui/js-lingui/.husky/pre-commit | #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
| 4,675 |
0 | petrpan-code/lingui/js-lingui/.yarn/plugins | petrpan-code/lingui/js-lingui/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs | /* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-workspace-tools",
factory: function (require) {
var plugin=(()=>{var yr=Object.create;var we=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Er=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,xr=Object.prototype.ha... | 4,676 |
0 | petrpan-code/lingui/js-lingui/.yarn | petrpan-code/lingui/js-lingui/.yarn/releases/yarn-3.4.1.cjs | #!/usr/bin/env node
/* eslint-disable */
//prettier-ignore
(()=>{var Mue=Object.create;var Wb=Object.defineProperty;var Kue=Object.getOwnPropertyDescriptor;var Uue=Object.getOwnPropertyNames;var Hue=Object.getPrototypeOf,Gue=Object.prototype.hasOwnProperty;var J=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy... | 4,677 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/create-react-app/.env | SKIP_PREFLIGHT_CHECK=true | 4,678 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/create-react-app/README.md | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will ... | 4,679 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/create-react-app/lingui.config.js | /** @type {import('@lingui/conf').LinguiConfig} */
module.exports = {
locales: ["en", "cs"],
sourceLocale: "en",
catalogs: [
{
path: "<rootDir>/src/locales/{locale}",
include: ["<rootDir>"],
exclude: ["**/node_modules/**"],
},
],
format: "po",
}
| 4,680 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/create-react-app/package.json | {
"name": "create-react-ts-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@lingui/core": "^4.1.2",
"@lingui/react": "^4.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"scripts": {
"start": "yarn extract && react-scripts start",
"build": "yarn extract && react-scri... | 4,681 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/create-react-app/tsconfig.json | {
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCa... | 4,682 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/create-react-app/yarn.lock | # This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!
__metadata:
version: 6
cacheKey: 8
"@adobe/css-tools@npm:^4.0.1":
version: 4.2.0
resolution: "@adobe/css-tools@npm:4.2.0"
checksum: dc5cc92ba3d562e7ffddb79d6d222c7e00b65f255fd2725b3... | 4,683 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/public/index.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>React App</titl... | 4,684 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/App.css | .App {
text-align: center;
}
.App-logo {
height: 10vmin;
pointer-events: none;
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.lang-container {
d... | 4,685 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/App.test.tsx | import React from "react"
import { getByText, render, act } from "@testing-library/react"
import { i18n } from "@lingui/core"
import { I18nProvider } from "@lingui/react"
import App from "./App"
i18n.load({
en: {
ZXBDaP: "Language switcher example:",
},
cs: {
ZXBDaP: "Příklad přepínače jazyků:",
},
})... | 4,686 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/App.tsx | import "./App.css"
import React, { useState } from "react"
import { Trans, Plural } from "@lingui/macro"
import { locales, dynamicActivate } from "./i18n"
import { useLingui } from "@lingui/react"
function App() {
const [count, setCount] = useState(0)
const { i18n } = useLingui()
return (
<div className="Ap... | 4,687 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/i18n.ts | import { i18n, Messages } from "@lingui/core"
export const locales = {
en: "English",
cs: "Česky",
}
export const defaultLocale = "en"
// CRA mark all resources which are not JS as 'asset/resource'
// Since we don't have access to the webpack config here is a dirty
// way to avoid this limitation.
// https://gith... | 4,688 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/index.css | body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Mona... | 4,689 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/index.tsx | import React, { useEffect } from "react"
import "./index.css"
import App from "./App"
import * as serviceWorker from "./serviceWorker"
import { i18n } from "@lingui/core"
import { I18nProvider } from "@lingui/react"
import { defaultLocale, dynamicActivate } from "./i18n"
import * as ReactDOMClient from "react-dom/clie... | 4,690 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/logo.svg | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-... | 4,691 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/react-app-env.d.ts | /// <reference types="react-scripts" />
| 4,692 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/serviceWorker.ts | // This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a p... | 4,693 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app | petrpan-code/lingui/js-lingui/examples/create-react-app/src/setupTests.ts | // jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
| 4,694 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app/src | petrpan-code/lingui/js-lingui/examples/create-react-app/src/locales/cs.po | msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language: \n"
"Language-Team: \n"
"Content-Type: \n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#: src/App.tsx:31
msgid "{count, plural, zero {There are no books} one {Th... | 4,695 |
0 | petrpan-code/lingui/js-lingui/examples/create-react-app/src | petrpan-code/lingui/js-lingui/examples/create-react-app/src/locales/en.po | msgid ""
msgstr ""
"POT-Creation-Date: 2020-10-20 12:51+0200\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: en\n"
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-T... | 4,696 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/js/README.md | # Using LinguiJS in VanillaJS projects
Prepare the example by installing dependencies and compiling message catalogs:
```sh
yarn install
yarn lingui compile
```
Now, either run full test suit:
```sh
yarn test
```
Or each file individually (you need to have `babel-cli` installed globally):
```sh
babel-node src/mes... | 4,697 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/js/babel.config.js | module.exports = {
presets: ["@babel/env"],
plugins: ["macros"],
}
| 4,698 |
0 | petrpan-code/lingui/js-lingui/examples | petrpan-code/lingui/js-lingui/examples/js/lingui.config.js | /** @type {import('@lingui/conf').LinguiConfig} */
module.exports = {
locales: ["en", "cs"],
format: "po",
catalogs: [
{
path: "./src/locale/{locale}/messages",
include: ["./src"],
},
],
sourceLocale: "en",
}
| 4,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.