file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
include/enet-plus/server_host.h | C/C++ Header | // Copyright (c) 2013 Andrey Konovalov
#ifndef ENET_PLUS_SERVER_HOST_HPP_
#define ENET_PLUS_SERVER_HOST_HPP_
#include "enet-plus/base/macros.h"
#include "enet-plus/base/pstdint.h"
#include "enet-plus/host.h"
#include "enet-plus/dll.h"
struct _ENetHost;
namespace enet {
class Enet;
class Event;
// A server host ... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
include/windows/stdint.h | C/C++ Header | /* ISO C9x 7.18 Integer types <stdint.h>
* Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
*
* This source code is offered for use in the public domain. You may
* use, modify or distribu... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
premake4.lua | Lua | newaction {
trigger = 'clean',
description = 'Cleans up the project.',
shortname = "clean",
execute = function()
os.rmdir("bin")
os.rmdir("build")
end
}
saved_config = {}
function save_config()
saved_config = configuration().terms
end
function restore_config()
configuration(saved_config)
end
fu... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
server.sh | Shell | #!/bin/sh
cd bin
export LD_LIBRARY_PATH=`pwd`
cd ..
./bin/sample-server
| xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/enet-plus/client_host.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include "enet-plus/client_host.h"
#include <string>
#include <enet/enet.h>
#include "enet-plus/base/pstdint.h"
#include "enet-plus/peer.h"
#include "enet-plus/host.h"
namespace enet {
ClientHost::~ClientHost() {
if (_state == STATE_INITIALIZED) {
Finalize();
}
}
b... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/enet-plus/enet.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include "enet-plus/enet.h"
#include <enet/enet.h>
// XXX: Windows sucks.
#undef CreateEvent
#include "enet-plus/base/macros.h"
#include "enet-plus/base/pstdint.h"
#include "enet-plus/host.h"
#include "enet-plus/server_host.h"
#include "enet-plus/client_host.h"
#include "enet-... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/enet-plus/event.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include "enet-plus/event.h"
#include <string>
#include <vector>
#include <enet/enet.h>
#include "enet-plus/base/pstdint.h"
#include "enet-plus/host.h"
#include "enet-plus/peer.h"
namespace enet {
Event::~Event() {
_DestroyPacket();
delete _event;
}
Event::EventType Ev... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/enet-plus/host.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include "enet-plus/host.h"
#include <map>
#include <string>
#include <enet/enet.h>
#include "enet-plus/base/pstdint.h"
#include "enet-plus/event.h"
#include "enet-plus/peer.h"
namespace enet {
Host::~Host() {
if (_state == STATE_INITIALIZED) {
Finalize();
}
};
boo... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/enet-plus/peer.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include "enet-plus/peer.h"
#include <string>
#include <enet/enet.h>
#include "enet-plus/base/macros.h"
#include "enet-plus/base/pstdint.h"
namespace enet {
bool Peer::Send(
const char* data,
size_t length,
bool reliable,
uint8_t channel_id
) {
enet_uint32 flags = ... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/enet-plus/server_host.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include "enet-plus/server_host.h"
#include <enet/enet.h>
#include "enet-plus/base/pstdint.h"
#include "enet-plus/event.h"
#include "enet-plus/host.h"
namespace enet {
ServerHost::~ServerHost() {
if (_state == STATE_INITIALIZED) {
Finalize();
}
};
bool ServerHost::I... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/sample-client/client.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include <vector>
#include "enet-plus/enet.h"
int main() {
enet::Enet enet;
bool rv = enet.Initialize();
CHECK(rv == true);
enet::ClientHost* client = enet.CreateClientHost();
CHECK(client != NULL);
enet::Peer* peer = client->Connect("127.0.0.1", 4242);
CHECK(pe... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
src/sample-server/server.cpp | C++ | // Copyright (c) 2013 Andrey Konovalov
#include <vector>
#include "enet-plus/enet.h"
int main() {
enet::Enet enet;
bool rv = enet.Initialize();
CHECK(rv == true);
enet::ServerHost* server = enet.CreateServerHost(4242);
CHECK(server != NULL);
enet::Event* event = enet.CreateEvent();
printf("Server st... | xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
valgrind-client.sh | Shell | #!/bin/sh
cd bin
export LD_LIBRARY_PATH=`pwd`
cd ..
valgrind ./bin/sample-client
| xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
valgrind-server.sh | Shell | #!/bin/sh
cd bin
export LD_LIBRARY_PATH=`pwd`
cd ..
valgrind ./bin/sample-server
| xairy/enet-plus | 4 | C++ wrapper for ENet | Python | xairy | Andrey Konovalov | |
msp/__init__.py | Python | from cell_parser import *
from schedule_parser import *
| xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
msp/cell_parser.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import fileinput
import regex
import string
import sys
import unicodedata
import xlrd
import os
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
# ['ii', 'ee'] -> ['i... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
msp/full_parser.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import sets
import sys
import xlrd
import schedule_parser
import cell_parser
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
def PrintFullSchedule(file):
schedule... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
msp/schedule_parser.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import sys
import xlrd
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
DAYS = 'Дни'
HOURS = 'Часы'
MONDAY = 'Понедельник'
TUESDAY = 'Вторник'
WEDNESDAY = 'Среда'
TH... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
msp/test/__init__.py | Python | import cell_tests
import schedule_tests
import unittest
def suite():
loader = unittest.TestLoader()
suite = unittest.TestSuite()
suite.addTest(cell_tests.suite())
suite.addTest(schedule_tests.suite())
return suite
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())
| xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
msp/test/cell_tests.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import unittest
import xlrd
import msp.cell_parser as cell_parser
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
class LocationsTest(unittest.TestCase):
def setU... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
msp/test/schedule_tests.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import os
import unittest
import xlrd
import msp.schedule_parser as schedule_parser
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
this_dir, this_filename = os.pat... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
setup.py | Python | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(name='mipt-schedule-parser',
version='0.1.0',
description='Parses standard mipt schedule xls file.',
author='Andrey Konovalov',
author_email='adech.fo@gmail.com',
url='https://github.com/xairy/mipt-sch... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
tools/extracter.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import sets
import sys
import xlrd
from cell_parser import *
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
files = [
'2014_spring/1.xls',
'2014_spring/2.xls',... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
tools/find_teacher.py | Python | #!/usr/bin/python
#coding: utf-8
from __future__ import unicode_literals
import fileinput
import regex
import sets
import sys
import urllib2
__author__ = "Andrey Konovalov"
__copyright__ = "Copyright (C) 2014 Andrey Konovalov"
__license__ = "MIT"
__version__ = "0.1"
teacher_entry_re = regex.compile(
'\<a href="(?... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
tools/scheme.sql | SQL | create table classes(
`group` text,
subgroup integer,
week_day integer,
class_number integer,
class_half integer,
subjects text,
locations text,
teachers text,
`type` integer,
raw_data text
);
| xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
tools/to_db.py | Python | #!/usr/bin/env python
#coding: utf-8
from __future__ import unicode_literals, division, print_function
import sys
import schedule_parser
import cell_parser
__author__ = "Alexander Konovalov"
__copyright__ = "Copyright (C) 2014 Alexander Konovalov"
__license__ = "MIT"
__version__ = "0.1"
def ParseCell(value):
sub... | xairy/mipt-schedule-parser | 2 | A parser for MIPT .xls schedule | Python | xairy | Andrey Konovalov | |
src/app.rs | Rust | use piston_window::*;
use field;
use settings;
struct Vec2f {
x: f64,
y: f64,
}
pub struct App {
settings: settings::Settings,
mouse_coords: Vec2f,
field: field::Field,
selected_cell: Option<field::Coords>,
conflicting_cell: Option<field::Coords>,
}
impl App {
pub fn new(settings: se... | xairy/rust-sudoku | 21 | Sudoku game written in Rust with Piston | Rust | xairy | Andrey Konovalov | |
src/field.rs | Rust | use rand;
use rand::seq::SliceRandom;
use rand::Rng;
pub struct Coords {
pub x: u8,
pub y: u8,
}
#[derive(Copy, Clone)]
pub struct Cell {
pub digit: Option<u8>,
pub fixed: bool,
}
#[derive(Copy, Clone)]
pub struct Field {
pub cells: [[Cell; 9]; 9],
}
impl Field {
pub fn new() -> Field {
... | xairy/rust-sudoku | 21 | Sudoku game written in Rust with Piston | Rust | xairy | Andrey Konovalov | |
src/main.rs | Rust | extern crate piston_window;
extern crate rand;
use piston_window::*;
use std::path::Path;
mod app;
mod field;
mod settings;
fn main() {
let settings = settings::Settings::new();
let opengl = OpenGL::V3_2;
let mut window: PistonWindow = WindowSettings::new(
"Sudoku",
[(settings.wind_size.... | xairy/rust-sudoku | 21 | Sudoku game written in Rust with Piston | Rust | xairy | Andrey Konovalov | |
src/settings.rs | Rust | pub struct Vec2f {
pub x: f64,
pub y: f64
}
pub struct Settings {
pub wind_size: Vec2f,
pub cell_size: Vec2f,
pub font_size: u32,
pub text_offset: Vec2f
}
impl Settings {
pub fn new() -> Settings {
Settings {
wind_size: Vec2f{ x: 900.0, y: 900.0 },
cell_size... | xairy/rust-sudoku | 21 | Sudoku game written in Rust with Piston | Rust | xairy | Andrey Konovalov | |
scripts/convert.js | JavaScript | const fs = require('fs');
const path = require('path');
const strings = fs.readFileSync(path.resolve(__dirname, '../data/strings.txt'), 'utf8').split('\n');
fs.writeFileSync(path.resolve(__dirname, '../src/strings.json'), JSON.stringify(strings, null, 2)); | xcatliu/beian.js | 0 | 模拟代码中字符串备案的情形 | xcatliu | xcatliu | Tencent | |
src/index.ts | TypeScript | import beian_strings from './strings.json';
/**
* 获取一个经过备案的字符串,如果此字符串未备案,将抛出错误
*/
function sb(str: string): string {
if(beian_strings.includes(str)) {
return str;
} else {
throw new Error(`字符串 "${str}" 没有经过备案,暂时无法使用`);
}
}
export default sb; | xcatliu/beian.js | 0 | 模拟代码中字符串备案的情形 | xcatliu | xcatliu | Tencent | |
test/blah.test.js | JavaScript | const sb = require('../dist/beian.js.cjs.production.min.js').default;
describe('sb', () => {
it('works', () => {
expect(sb('hello world')).toEqual('hello world');
});
it('no works', () => {
expect(() => sb('bye world')).toThrow();
});
});
| xcatliu/beian.js | 0 | 模拟代码中字符串备案的情形 | xcatliu | xcatliu | Tencent | |
.eslintrc.js | JavaScript | module.exports = {
extends: ['next/core-web-vitals', 'prettier'],
rules: {
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
pathGroups: [
{
pattern: '@/**',
group: 'parent',
},
]... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
.prettierrc.js | JavaScript | // .prettierrc.js
module.exports = {
// 一行最多 120 字符
printWidth: 120,
// 使用 2 个空格缩进
tabWidth: 2,
// 不使用缩进符,而使用空格
useTabs: false,
// 行尾需要有分号
semi: true,
// 使用单引号
singleQuote: true,
// 对象的 key 仅在必要时用引号
quoteProps: 'as-needed',
// jsx 不使用单引号,而使用双引号
jsxSingleQuote: false,
// 末尾需要有逗号
trailingC... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/api/chat/route.ts | TypeScript | import { createParser } from 'eventsource-parser';
import { cookies } from 'next/headers';
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import type { ChatResponseChunk } from '@/utils/constants';
import { HttpHeaderJson, HttpMethod, HttpStatus } from '@/utils/constants';
... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/api/models/route.ts | TypeScript | import { cookies } from 'next/headers';
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { exampleModelsResponse, HttpHeaderJson, HttpMethod, HttpStatus } from '@/utils/constants';
import { env } from '@/utils/env';
import { getApiKey } from '@/utils/getApiKey';
expor... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/AttachImage.tsx | TypeScript (TSX) | 'use client';
import { XMarkIcon } from '@heroicons/react/24/outline';
import Image from 'next/image';
import type { FC } from 'react';
import { useContext } from 'react';
import { ChatContext } from '@/context/ChatContext';
import { AttachImageButton } from './buttons/AttachImageButton';
export const AttachImage: ... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/History.tsx | TypeScript (TSX) | 'use client';
import { PlusIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import dayjs from 'dayjs';
import type { FC } from 'react';
import { useContext } from 'react';
import type { HistoryItem } from '@/context/ChatContext';
import { ChatContext } from '@/context/ChatContext';
impo... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/Menu.tsx | TypeScript (TSX) | 'use client';
import { AdjustmentsHorizontalIcon, InboxStackIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import type { FC, ReactNode } from 'react';
import { useCallback, useContext } from 'react';
import { DeviceContext } from '@/context/DeviceContext';
import { MenuContext, MenuKe... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/Message.tsx | TypeScript (TSX) | 'use client';
import { UserIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import Image from 'next/image';
import type { FC, ReactNode } from 'react';
import { useCallback, useContext, useState } from 'react';
import { MessageDetailContext } from '@/context/MessageDetailContext';
impor... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/MessageDetail.tsx | TypeScript (TSX) | 'use client';
import { XMarkIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import React, { useContext } from 'react';
import { DeviceContext } from '@/context/DeviceContext';
import { MessageDetailContext } from '@/context/MessageDetailContext';
import { formatMessage, FormatMessageMo... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/Messages.tsx | TypeScript (TSX) | 'use client';
import { useContext, useEffect } from 'react';
import { ChatContext } from '@/context/ChatContext';
import { SettingsContext } from '@/context/SettingsContext';
import { Role } from '@/utils/constants';
// import { exampleMessages } from '@/utils/exampleMessages';
import { initEventListenerScroll } from... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/Settings.tsx | TypeScript (TSX) | 'use client';
import { useContext } from 'react';
import { ChatContext } from '@/context/ChatContext';
import { SettingsContext } from '@/context/SettingsContext';
import type { Model } from '@/utils/constants';
import { AllModels, Role } from '@/utils/constants';
/**
* 聊天记录
*/
export const Settings = () => {
co... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/TextareaForm.tsx | TypeScript (TSX) | 'use client';
import classNames from 'classnames';
import type { FC, FormEvent, KeyboardEvent } from 'react';
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
import { ChatContext } from '@/context/ChatContext';
import { DeviceContext } from '@/context/DeviceContext';
import { LoginContex... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/Title.tsx | TypeScript (TSX) | import { headers } from 'next/headers';
import { isWeChat as utilIsWeChat } from '@/utils/device';
export const Title = () => {
const userAgent = headers().get('user-agent') ?? '';
const isWeChat = utilIsWeChat(userAgent);
if (isWeChat) {
return null;
}
return (
<>
<div placeholder="" classN... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/buttons/AttachImageButton.tsx | TypeScript (TSX) | import { PhotoIcon, PlusIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import type { FC } from 'react';
import { useContext } from 'react';
import { ChatContext } from '@/context/ChatContext';
import { LoginContext } from '@/context/LoginContext';
import { MAX_GPT_VISION_IMAGES } from ... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/buttons/DeleteHistoryButton.tsx | TypeScript (TSX) | import { TrashIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import type { FC } from 'react';
import { useContext } from 'react';
import { ChatContext } from '@/context/ChatContext';
/**
* 删除聊天记录
*/
export const DeleteHistoryButton: FC<{ className?: string; historyIndex: 'current' |... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/buttons/LoginButton.tsx | TypeScript (TSX) | import { KeyIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import { useCallback, useContext } from 'react';
import { LoginContext } from '@/context/LoginContext';
import { sleep } from '@/utils/sleep';
/**
* 登录按钮
*/
export const LoginButton = () => {
const { isLogged, login, logou... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/buttons/MenuEntryButton.tsx | TypeScript (TSX) | import { AdjustmentsHorizontalIcon, InboxStackIcon } from '@heroicons/react/24/outline';
import { useContext } from 'react';
import { ChatContext } from '@/context/ChatContext';
import { LoginContext } from '@/context/LoginContext';
import { MenuContext, MenuKey } from '@/context/MenuContext';
import { scrollToTop } f... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/components/icons/ChatGPTIcon.tsx | TypeScript (TSX) | import type { FC } from 'react';
import React from 'react';
export const ChatGPTIcon: FC<{
className?: string;
}> = ({ className }) => (
<svg
width="41"
height="41"
viewBox="0 0 41 41"
fill="none"
xmlns="http://www.w3.org/2000/svg"
strokeWidth="1.5"
className={className}
role="img"
... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/context/ChatContext.tsx | TypeScript (TSX) | 'use client';
import omit from 'lodash.omit';
import type { FC, ReactNode } from 'react';
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { fetchApiChat } from '@/utils/api';
import { getCache, setCache } from '@/utils/cache';
import type { ChatResponse, Message, S... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/context/DeviceContext.tsx | TypeScript (TSX) | 'use client';
import { setCookie } from 'cookies-next';
import throttle from 'lodash.throttle';
import type { FC, ReactNode } from 'react';
import { createContext, useCallback, useEffect, useState } from 'react';
/**
* 设备相关 Context
*/
export const DeviceContext = createContext<{
isWeChat: boolean;
isMobile: boo... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/context/LoginContext.tsx | TypeScript (TSX) | 'use client';
import { setCookie } from 'cookies-next';
import { useSearchParams } from 'next/navigation';
import type { FC, ReactNode } from 'react';
import { createContext, useCallback, useContext, useEffect, useState } from 'react';
import { getCache, setCache } from '@/utils/cache';
import { login as utilsLogin, ... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/context/MenuContext.tsx | TypeScript (TSX) | 'use client';
import type { FC, ReactNode } from 'react';
import { createContext, useCallback, useState } from 'react';
/**
* 菜单栏的 Key,直接用图标的名字表示
*/
export enum MenuKey {
/** 聊天记录 tab */
InboxStack = 'InboxStack',
/** 参数配置 tab */
AdjustmentsHorizontal = 'AdjustmentsHorizontal',
}
/**
* 菜单栏的 Context
*/
ex... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/context/MessageDetailContext.tsx | TypeScript (TSX) | 'use client';
import type { FC, ReactNode } from 'react';
import { createContext, useState } from 'react';
import { FormatMessageMode } from '@/utils/formatMessage';
/**
* 双击展开消息详情的 Context
*/
export const MessageDetailContext = createContext<{
messageDetail: string | undefined;
setMessageDetail: (messageDetai... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/context/SettingsContext.tsx | TypeScript (TSX) | 'use client';
import type { FC, ReactNode } from 'react';
import { createContext, useCallback, useEffect, useReducer } from 'react';
import { fetchApiModels } from '@/utils/api';
import { getCache, setCache } from '@/utils/cache';
import type { ChatRequest, SimpleStringMessage } from '@/utils/constants';
import { All... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/global-error.tsx | TypeScript (TSX) | 'use client';
// https://beta.nextjs.org/docs/routing/error-handling
export default function GlobalError({ error, reset }: { error: Error; reset: () => void }) {
return (
<html>
<body>
<h2>Something went wrong!</h2>
<p>{error.message}</p>
<button onClick={() => reset()}>Try again</b... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/globals.css | CSS | @tailwind base;
@tailwind components;
@tailwind utilities;
html {
/* 移动端全屏应用,大屏下白色背景墙 */
@apply bg-chat-bg md:bg-white text-gray-900;
@apply dark:bg-chat-bg-dark dark:md:bg-gray-800 dark:text-gray-200;
}
body {
/* 移动端菜单从右侧滑出,需要整个 body 偏移 */
@apply transition-transform;
}
/* 打开菜单后,禁用滚动 */
html.show-menu {
@... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/hooks/useDarkMode.ts | TypeScript | import { useEffect } from 'react';
export const useDarkMode = () => {
useEffect(() => {
const link = document.createElement('link');
link.rel = 'stylesheet';
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// 暗色模式
link.href = '/prism-dark.css';
} els... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/layout.tsx | TypeScript (TSX) | import './globals.css';
import npmIsMobile from 'is-mobile';
import type { Metadata } from 'next';
import { cookies, headers } from 'next/headers';
import { ChatProvider } from '@/context/ChatContext';
import { DeviceProvider } from '@/context/DeviceContext';
import { LoginProvider } from '@/context/LoginContext';
im... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/page.tsx | TypeScript (TSX) | import { Menu } from '@/components/Menu';
import { MessageDetail } from '@/components/MessageDetail';
import { Messages } from '@/components/Messages';
import { TextareaForm } from '@/components/TextareaForm';
import { Title } from '@/components/Title';
export default function Home() {
return (
<div className="m... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/api.ts | TypeScript | import type { ChatRequest, ModelsResponse } from './constants';
import { HttpHeaderJson, HttpMethod } from './constants';
import { ResError } from './error';
import { stream2string } from './stream';
/**
* 请求 /api/chat 接口
* 参数和 OpenAI 官方的接口参数一致,apiKey 在服务端自动添加
* 可以传入 onMessage 来流式的获取响应
*/
export const fetchApiChat... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/cache.ts | TypeScript | export function setCache(key: string, value: any) {
localStorage.setItem(key, JSON.stringify(value));
}
export function getCache<T = any>(key: string): T | undefined {
return JSON.parse(localStorage.getItem(key) ?? 'null') ?? undefined;
}
export function removeCache(key: string) {
localStorage.removeItem(key);
... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/constants.ts | TypeScript | export enum HttpMethod {
GET = 'GET',
POST = 'POST',
}
export enum HttpStatus {
OK = 200,
BadRequest = 400,
Unauthorized = 401,
MethodNotAllowed = 405,
}
export const HttpHeaderJson = {
'Content-Type': 'application/json',
};
/**
* 全角空格,用于 html 中的占位符
*/
export const FULL_SPACE = ' ';
/**
* 使用 gpt-4-... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/device.ts | TypeScript | /**
* 通过 ua 判断是否为微信,支持传入 ua,这样就可以在 ssr 时运行
* https://gist.github.com/GiaoGiaoCat/fff34c063cf0cf227d65
*/
export function isWeChat(userAgent?: string) {
if (userAgent) {
return /micromessenger/.test(userAgent.toLowerCase());
}
if (typeof window !== 'undefined') {
return /micromessenger/.test(window.navi... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/env.ts | TypeScript | export const env = {
NODE_ENV: process.env.NODE_ENV,
/** apiKey 別名 */
OPENAI_API_KEY_ALIAS: process.env.OPENAI_API_KEY_ALIAS ?? undefined,
/** 禁止陌生人通过他自己的 apiKey 访问 */
CHATGPT_NEXT_DISABLE_PUBLIC: process.env.CHATGPT_NEXT_DISABLE_PUBLIC ?? 'false',
/** 配置 API 请求的 host(包含端口) */
CHATGPT_NEXT_API_HOST: pr... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/error.ts | TypeScript | interface ResErrorBody {
code: string | number;
message: string;
}
export class ResError extends Error implements ResErrorBody {
public code!: string | number;
public message!: string;
public constructor(errorBody: ResErrorBody) {
super();
Object.assign(this, errorBody);
}
}
| xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/exampleMessages.ts | TypeScript | export const exampleMessages: any = [
{
role: 'user',
content: 'github actions 如何在修改某些文件时不触发',
},
{
role: 'assistant',
content:
'GitHub Actions 中可以通过配置“忽略文件”来避免在某些文件修改时触发 Workflow。\n\n具体的操作步骤为:\n\n1. 在仓库根目录创建 `.github/workflows` 文件夹\n\n2. 在该文件夹下创建一个名为 `your-workflow.yml` 的 Workflow 文件,例如:\n\... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/export.ts | TypeScript | /**
* 导出 json
*/
export function exportJSON(data: any, filename: string) {
const jsonData = JSON.stringify(data, null, 2);
const a = document.createElement('a');
const file = new Blob([jsonData], { type: 'application/json' });
a.href = URL.createObjectURL(file);
a.download = filename;
a.click();
URL.rev... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/formatMessage.ts | TypeScript | import MarkdownIt from 'markdown-it';
// @ts-ignore
import katex from 'markdown-it-katex';
import { sleep } from './sleep';
/** 多种 markdown-it 配置 */
const markdownItMap = {
zero: new MarkdownIt('zero'),
partial: new MarkdownIt('zero', {
breaks: true,
linkify: true,
// 使用 Prism 解析代码
highlight: (str... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/getApiKey.ts | TypeScript | import { env } from './env';
/**
* 传入的 apiKey 可能是 alias,这个函数会返回真正的 apiKey
*/
export function getApiKey(apiKey?: string): string | undefined {
if (!apiKey) {
return undefined;
}
// 从 getOpenaiApiKeyAliasMap 中拿取真实的 apiKey
let realApiKey = apiKey;
const openaiApiKeyAliasMap = getOpenaiApiKeyAliasMap();
... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/image.ts | TypeScript | export interface ImageProp {
src: string;
width: number;
height: number;
}
/**
* 图片按照这个方式缩放:
* Image inputs are metered and charged in tokens, just as text inputs are.
* The token cost of a given image is determined by two factors: its size, and the detail option on each image_url block.
* All images with de... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/isDomChildren.ts | TypeScript | /** 判断 child 是不是 ancestor 的子节点 */
export function isDomChildren(ancestor: HTMLElement | null, target: HTMLElement | null) {
if (!ancestor || !target) {
return false;
}
let parent: HTMLElement | null = target;
do {
parent = parent.parentElement;
if (parent === ancestor) {
return true;
}
... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/last.ts | TypeScript | export function last<T>(arr: T[]) {
return arr[arr.length - 1];
}
| xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/login.ts | TypeScript | import { getCookie, removeCookies, setCookie } from 'cookies-next';
import { removeCache, setCache } from '@/utils/cache';
import { sleep } from './sleep';
/** 开始登录 */
export function login() {
// 如果已登录,则提前结束
if (getCookie('apiKey')) {
return true;
}
return new Promise<boolean>(async (resolve) => {
... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/message.ts | TypeScript | import { MessageContentType } from './constants';
import type { ChatResponse, Message, MessageContentItemText, StructuredMessageContentItem } from './constants';
/**
* 判断传入的 message 是简单的 Message 还是完整的 ChatResponse
*/
export function isMessage(message: Message | ChatResponse): message is Message {
if ((message as M... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/scroll.ts | TypeScript | let isScrolling = false;
let isScriptScrolling = false;
let scrollTimeoutId: any = null;
export function initEventListenerScroll() {
const scrollHandler = () => {
// 如果是脚本滚动,则直接返回
if (isScriptScrolling) {
return;
}
isScrolling = true;
clearTimeout(scrollTimeoutId);
scrollTimeoutId = se... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/sleep.ts | TypeScript | export function sleep(time: number) {
return new Promise<void>((resolve) => {
setTimeout(resolve, time);
});
}
| xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
app/utils/stream.ts | TypeScript | /**
* 将 ReadableStream 转为字符串
*/
export async function stream2string(stream: ReadableStream | undefined | null, onMessage?: (content: string) => void) {
if (!stream) {
return '';
}
const reader = stream.getReader();
const decoder = new TextDecoder('utf-8');
let result = '';
while (true) {
const { ... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
bak/messageUpgrade.ts | TypeScript | /**
* 由于变更了数据格式,所以这个文件做了兼容
*/
import { Role } from './constants';
import type { Message } from './constants';
export interface MessageOld {
avatar: 'user' | 'ChatGPT';
chatMessage: {
text: string;
role: Role;
id: string;
parentMessageId: string;
detail: {
id: string;
object: stri... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
bak/object.ts | TypeScript | export function isObject(value: any) {
if (typeof value === 'object' && value !== null) {
return true;
}
return false;
}
/**
* 递归的去除对象中的所有 undefined、null 和空对象
* TODO 没有处理循环引用
*/
export function cleanObject(value: any) {
// 如果是一个普通值,则直接返回该值
if (!Array.isArray(value) && !isObject(value)) {
return va... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
bin.js | JavaScript | #!/usr/bin/env node
const { spawn } = require('child_process');
// 获取命令行参数
const args = process.argv.slice(2);
spawn('npm', ['start', ...args], {
stdio: 'inherit',
cwd: __dirname,
});
| xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
next.config.js | JavaScript | /** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
};
module.exports = nextConfig;
| xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
postcss.config.js | JavaScript | module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
| xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
public/prism-dark.css | CSS | /* PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+bash+c+csharp+cpp+css-extras+go+java+javadoclike+jsdoc+latex+markup-templating+matlab+perl+php+python+jsx+tsx+ruby+rust+sql+swift+typescript+visual-basic+yaml&plugins=autolinker */
code[class*=language-],pre[... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
public/prism-light.css | CSS | /* PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+csharp+cpp+css-extras+go+java+javadoclike+jsdoc+latex+markup-templating+matlab+perl+php+python+jsx+tsx+ruby+rust+sql+swift+typescript+visual-basic+yaml&plugins=autolinker */
code[class*=language-],pre[class*=la... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
public/prism.js | JavaScript | /* PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+csharp+cpp+css-extras+go+java+javadoclike+jsdoc+latex+markup-templating+matlab+perl+php+python+jsx+tsx+ruby+rust+sql+swift+typescript+visual-basic+yaml&plugins=autolinker */
var _self="undefined"!=typeof window... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
tailwind.config.js | JavaScript | const colors = require('tailwindcss/colors');
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./app/**/*.{js,ts,jsx,tsx}',
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
// Or if using `src` directory:
'./src/**/*.{js,ts,jsx,tsx}',
],
theme: {... | xcatliu/chatgpt-next | 781 | 微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择! | TypeScript | xcatliu | xcatliu | Tencent |
pagic.config.ts | TypeScript | // import { React } from 'https://deno.land/x/pagic/mod.ts';
export default {
srcDir: '.',
exclude: ['LICENSE'],
root: '/my_docs/',
theme: 'docs',
plugins: ['sidebar', 'prev_next', 'ga', 'gitalk'],
title: 'Pagic template docs',
description: 'Use this template to create a Pagic site with the docs theme',... | xcatliu/my_docs | 0 | TypeScript | xcatliu | xcatliu | Tencent | |
test_pages/react_hooks_test.tsx | TypeScript (TSX) | import { React } from 'https://deno.land/x/pagic/mod.ts';
const ReactHooksTest = () => {
const [count, setCount] = React.useState(0);
return (
<>
<h1>React hooks test</h1>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Count +1</button>
</>
);
};
export const frontMa... | xcatliu/my_docs | 0 | TypeScript | xcatliu | xcatliu | Tencent | |
pagic.config.ts | TypeScript | // import { React } from 'https://deno.land/x/pagic/mod.ts';
export default {
srcDir: '.',
exclude: ['LICENSE'],
root: '/pagic_template_docs/',
theme: 'docs',
plugins: ['sidebar', 'prev_next'],
title: 'Pagic template docs',
description: 'Use this template to create a Pagic site with the docs theme',
/... | xcatliu/pagic_template_docs | 14 | Use this template to create a Pagic site with the docs theme | TypeScript | xcatliu | xcatliu | Tencent |
test_pages/react_hooks_test.tsx | TypeScript (TSX) | import { React } from 'https://deno.land/x/pagic/mod.ts';
const ReactHooksTest = () => {
const [count, setCount] = React.useState(0);
return (
<>
<h1>React hooks test</h1>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Count +1</button>
</>
);
};
export const frontMa... | xcatliu/pagic_template_docs | 14 | Use this template to create a Pagic site with the docs theme | TypeScript | xcatliu | xcatliu | Tencent |
serialize.js | JavaScript | /**
* 序列化任意一个对象
*/
function serialize(obj, options = {}) {
const {
space,
useCircularPath,
removeFunction,
removeCircular,
removeNull,
removeUndefined,
removeEmpty,
removeKeyFilter,
removePathFilter,
printToConsole,
copyToClipboard,
} = {
space: 0,
useCircularPa... | xcatliu/smart-serialize | 2 | Serialize any object, stringify, print to console, and write to clipboard | JavaScript | xcatliu | xcatliu | Tencent |
make-artifacts.sh | Shell | #!/bin/bash
make_big_file() {
local f="$1"
local dest="test-$f.bin"
dd if=/dev/urandom of="$dest" bs=16k count=65536 # 1GiB
sha256sum "$dest" > "${dest}.sha256"
}
for i in $(seq 1 10); do
make_big_file "$i" &
done
wait
| xen0n/action-gh-release-testground | 0 | Shell | xen0n | WÁNG Xuěruì | gentoo | |
src/codemap.rs | Rust | use std::borrow::Cow;
use pyo3::{exceptions::PyValueError, prelude::*};
use starlark::codemap::{
CodeMap, FileSpan, Pos, ResolvedFileLine, ResolvedFileSpan, ResolvedPos, ResolvedSpan, Span,
};
#[pyclass(module = "xingque", name = "Pos")]
pub(crate) struct PyPos(Pos);
#[pymethods]
impl PyPos {
#[new]
fn p... | xen0n/xingque | 7 | ✨🐦 Typed Python binding to starlark-rust that proxies your objects | Rust | xen0n | WÁNG Xuěruì | gentoo |
src/environment.rs | Rust | use pyo3::exceptions::{PyRuntimeError, PyValueError};
use pyo3::prelude::*;
use starlark::environment::{FrozenModule, Globals, GlobalsBuilder, LibraryExtension, Module};
use starlark::values::{FrozenStringValue, FrozenValue};
use crate::py2sl::{self, sl_frozen_value_from_py};
use crate::sl2py::{self, py_from_sl_frozen... | xen0n/xingque | 7 | ✨🐦 Typed Python binding to starlark-rust that proxies your objects | Rust | xen0n | WÁNG Xuěruì | gentoo |
src/errors.rs | Rust | use pyo3::prelude::*;
use starlark::codemap::FileSpan;
use starlark::errors::Frame;
use crate::codemap::PyFileSpan;
#[pyclass(module = "xingque", name = "Frame", frozen)]
#[derive(Clone)]
pub(crate) struct PyFrame(Frame);
impl From<Frame> for PyFrame {
fn from(value: Frame) -> Self {
Self(value)
}
}
... | xen0n/xingque | 7 | ✨🐦 Typed Python binding to starlark-rust that proxies your objects | Rust | xen0n | WÁNG Xuěruì | gentoo |
src/eval.rs | Rust | use std::collections::{HashMap, HashSet};
use anyhow::anyhow;
use pyo3::exceptions::PyRuntimeError;
use pyo3::intern;
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyTuple};
use starlark::codemap::ResolvedFileSpan;
use starlark::environment::{FrozenModule, Module};
use starlark::errors::Frame;
use starlark::eval::{C... | xen0n/xingque | 7 | ✨🐦 Typed Python binding to starlark-rust that proxies your objects | Rust | xen0n | WÁNG Xuěruì | gentoo |
src/lib.rs | Rust | use pyo3::prelude::*;
mod codemap;
mod environment;
mod errors;
mod eval;
mod py2sl;
mod repr_utils;
mod sl2py;
mod syntax;
mod values;
#[pymodule]
mod xingque {
use super::*;
#[pymodule_export]
use codemap::PyCodeMap;
#[pymodule_export]
use codemap::PyFileSpan;
#[pymodule_export]
use cod... | xen0n/xingque | 7 | ✨🐦 Typed Python binding to starlark-rust that proxies your objects | Rust | xen0n | WÁNG Xuěruì | gentoo |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.