diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/architecture.png b/architecture.png new file mode 100644 index 0000000..8d3eee2 Binary files /dev/null and b/architecture.png differ diff --git a/css/custom.css b/css/custom.css new file mode 100644 index 0000000..7f799b1 --- /dev/null +++ b/css/custom.css @@ -0,0 +1,4 @@ +img { + max-width: 100%; /* 设置图片的最大宽度为屏幕宽度的百分比 */ + height: auto; /* 自动保持宽高比 */ +} diff --git a/css/theme.css b/css/theme.css new file mode 100644 index 0000000..9c3c3b7 --- /dev/null +++ b/css/theme.css @@ -0,0 +1,286 @@ +body { + font-family: pingfang SC,helvetica neue,arial,hiragino sans gb,microsoft yahei ui,microsoft yahei,simsun,sans-serif; +} +.container { + color: #333; +} +.nav { + width: 300px; + background-color: #F6F6F6; + height: 100vh; + overflow: auto; + position: fixed; +} +.nav-inner { + height: auto; +} +.nav .logo { + width: 100%; + height: 160px; + background-color: #ff6a00; + background-image: url(../img/logo-bg.jpeg); + background-repeat: no-repeat; + background-size: 100% 100%; +} +.nav .logo img { + width: 80%; + margin-top: 60px; + margin-left: 30px; +} +.nav ul { + list-style: none; + margin: 40px 0 0; + padding: 0; + width: 100%; +} +.nav ul li { + width: 100%; + height: 40px; +} +.nav ul li a { + width: 100%; + height: 100%; + padding-left: 32px; + text-decoration: none; + color: #333; +} +.nav ul li a:hover { + color: #ff6a00; +} +.nav ul li.li-h3 a { + width: 100%; + padding-left: 64px; +} + +.content { + margin-left: 300px; + padding-top: 48px; +} + +.content-inner { + max-width: 1200px; + padding: 0 48px 0; + margin: 0 auto 48px; +} + +.copyrights { + height: 56px; + line-height: 56px; + padding-left: 48px; + background-color: #EEEEEE; +} + +/* @media screen and (max-width: 768px) */ +@media screen and (max-width: 768px) { + .nav { + width: 100%; + background-color: #F6F6F6; + height: 48px; + overflow: auto; + position: relative; + } + .nav .logo { + height: 48px; + } + .nav .logo img { + margin-top: 0px; + padding-top: 8px; + margin-left: auto; + margin-right: auto; + height: 32px; + width: auto; + display: block; + } + .nav ul { + display: none; + } + .content { + margin-left: 0; + padding-top: 48px; + } + .content-inner { + max-width: 1200px; + padding: 0 24px 0; + margin: 0 auto 24px; + } +} + +/* content */ +h1 { + margin-top: 0; + border-bottom: 1px solid rgba(61,61,61,.1); + padding-bottom: 24px; +} + +h2 { + font-weight: 500; + margin: 32px 0 16px; +} + +p { + line-height: 24px; +} + +pre code { + display: block; + overflow-x: auto; + background: #f7f7f7; + color: #695d69; + padding: 1em; +} + +p img { + max-width: 100%; + height: auto; +} + +ul, ol { + padding-left: 24px; +} + +li { + line-height: 24px; +} + +table { + width: 100%; + overflow: auto; + display: block; + border: none; +} + +table thead { + color: #000; + text-align: left; + vertical-align: bottom; + white-space: nowrap; +} + +/* table tbody tr:nth-child(2n-1) td { + background-color: #f3f6f6; +} */ + +th { + background-color: #f3f6f6; +} + + +td, th { + border: 1px solid #e1e4e5; + border-collapse: collapse; + font-size: 90%; + margin: 0; + overflow: visible; + padding: 8px 16px; +} + +a { + color: #0070cc; + text-decoration: none; +} + +blockquote { + background-color: #DBEDFE; + margin: 0; + padding: 16px; +} +blockquote p { + margin: 0; +} +blockquote p + p { + margin-top: 16px; +} + +/* from https://highlightjs.org/demo */ +.theme-github { +/*! +Theme: GitHub +Description: Light theme as seen on github.com +Author: github.com +Maintainer: @Hirse +Updated: 2021-05-15 + +Outdated base version: https://github.com/primer/github-syntax-light +Current colors taken from GitHub's CSS +*/ +} + +.theme-github pre code.hljs { + display: block; + overflow-x: auto; + padding: 1em +} + +.theme-github code.hljs { + display: block; + overflow-x: auto; + padding: .5em; + color: #333; + background: #f8f8f8 +} + +.theme-github .hljs { + color: #24292e; + background: #fff +} + +.theme-github .hljs-doctag,.theme-github .hljs-keyword,.theme-github .hljs-meta .hljs-keyword,.theme-github .hljs-template-tag,.theme-github .hljs-template-variable,.theme-github .hljs-type,.theme-github .hljs-variable.language_ { + color: #d73a49 +} + +.theme-github .hljs-title,.theme-github .hljs-title.class_,.theme-github .hljs-title.class_.inherited__,.theme-github .hljs-title.function_ { + color: #6f42c1 +} + +.theme-github .hljs-attr,.theme-github .hljs-attribute,.theme-github .hljs-literal,.theme-github .hljs-meta,.theme-github .hljs-number,.theme-github .hljs-operator,.theme-github .hljs-selector-attr,.theme-github .hljs-selector-class,.theme-github .hljs-selector-id,.theme-github .hljs-variable { + color: #005cc5 +} + +.theme-github .hljs-meta .hljs-string,.theme-github .hljs-regexp,.theme-github .hljs-string { + color: #032f62 +} + +.theme-github .hljs-built_in,.theme-github .hljs-symbol { + color: #e36209 +} + +.theme-github .hljs-code,.theme-github .hljs-comment,.theme-github .hljs-formula { + color: #6a737d +} + +.theme-github .hljs-name,.theme-github .hljs-quote,.theme-github .hljs-selector-pseudo,.theme-github .hljs-selector-tag { + color: #22863a +} + +.theme-github .hljs-subst { + color: #24292e +} + +.theme-github .hljs-section { + color: #005cc5; + font-weight: 700 +} + +.theme-github .hljs-bullet { + color: #735c0f +} + +.theme-github .hljs-emphasis { + color: #24292e; + font-style: italic +} + +.theme-github .hljs-strong { + color: #24292e; + font-weight: 700 +} + +.theme-github .hljs-addition { + color: #22863a; + background-color: #f0fff4 +} + +.theme-github .hljs-deletion { + color: #b31d28; + background-color: #ffeef0 +} \ No newline at end of file diff --git a/img/favicon.ico b/img/favicon.ico new file mode 100644 index 0000000..a566910 Binary files /dev/null and b/img/favicon.ico differ diff --git a/img/logo-2x.png b/img/logo-2x.png new file mode 100644 index 0000000..a7bdaea Binary files /dev/null and b/img/logo-2x.png differ diff --git a/img/logo-bg.jpeg b/img/logo-bg.jpeg new file mode 100644 index 0000000..7b3e9fb Binary files /dev/null and b/img/logo-bg.jpeg differ diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 0000000..3856bb8 Binary files /dev/null and b/img/logo.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..698dbf2 --- /dev/null +++ b/index.html @@ -0,0 +1,807 @@ + + + + + + + 服务模板说明文档 - Aliyun 计算巢 x mysql-managed-demo + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +

服务模板说明文档

+

服务说明

+

本文介绍基于MySQL软件包快速构建托管版单租户计算巢服务,关于计算巢托管版可以参考帮助文档, +本示例采用ECS+SLB的架构,默认支持私网打通、网络变配与磁盘扩容功能。用户部署服务实例后,可以直接通过内网访问部署在服务商的MySQL,除此之外还配置了三种套餐,分别为:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
套餐名SLB规格ECS规格族vCPU与内存系统盘公网带宽
低配版slb.s1.smallecs.c6.large内存型c6,2vCPU 4GiBESSD云盘 200GiB PL0固定带宽1Mbps
基础版slb.s1.smallecs.c6.xlarge内存型c6,4vCPU 8GiBESSD云盘 200GiB PL0固定带宽1Mbps
高配版slb.s3.smallecs.c6.2xlarge内存型c6,4vCPU 8GiBESSD云盘 200GiB PL0固定带宽1Mbps
+

本示例对应的Git仓库地址:mysql-managed-demo

+

本示例会自动的构建计算巢服务,具体的服务构建流程为:

+
    +
  1. 将MySQL安装包(提前存放到该github repo中)构建为计算巢文件部署物
  2. +
  3. 创建计算巢服务并关联文件部署物
  4. +
+

创建过程大约持续3分钟,当服务变成待提交后构建成功。

+

部署架构

+

本部署架构为SLB+ECS,安全组开放3306端口,并配置了终端节点。 +image.png

+

服务构建计费说明

+

测试本服务构建无需任何费用,创建服务实例涉及的费用参考服务实例计费说明。

+

RAM账号所需权限

+

本服务需要对ECS、VPC等资源进行访问和创建操作,若您使用RAM用户创建服务实例,需要在创建服务实例前,对使用的RAM用户的账号添加相应资源的权限。添加RAM权限的详细操作,请参见为RAM用户授权 +。所需权限如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
权限策略名称备注
AliyunECSFullAccess管理云服务器服务(ECS)的权限
AliyunVPCFullAccess管理专有网络(VPC)的权限
AliyunROSFullAccess管理资源编排服务(ROS)的权限
AliyunComputeNestUserFullAccess管理计算巢服务(ComputeNest)的用户侧权限
AliyunComputeNestSupplierFullAccess管理计算巢服务(ComputeNest)的服务商侧权限
AliyunPrivateLinkFullAccess管理私网连接(PrivateLink)的权限
+

服务实例计费说明

+

测试本服务在计算巢上的费用主要涉及:

+
    +
  • 所选vCPU与内存规格
  • +
  • 系统盘类型及容量
  • +
  • 公网带宽
  • +
  • 私网连接费用
  • +
+

计费方式包括:

+
    +
  • 按量付费(小时)
  • +
  • 包年包月
  • +
+

目前提供如下套餐:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
套餐名SLB规格ECS规格族vCPU与内存系统盘公网带宽
低配版slb.s1.smallecs.c6.large内存型c6,2vCPU 4GiBESSD云盘 200GiB PL0固定带宽1Mbps
基础版slb.s1.smallecs.c6.xlarge内存型c6,4vCPU 8GiBESSD云盘 200GiB PL0固定带宽1Mbps
高配版slb.s3.smallecs.c6.2xlarge内存型c6,4vCPU 8GiBESSD云盘 200GiB PL0固定带宽1Mbps
+

预估费用在创建实例时可实时看到。私网连接只有在创建服务时候并建立连接后才会计费,具体的计费方式可以参考:https://help.aliyun.com/document_detail/198081.html?spm=a2c4g.120462.0.0.5f104bffA7i9WJ

+

部署流程

+

部署参数说明

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数族参数项说明
基础配置数据库root和admin账户密码数据库root和admin账户密码,长度8-32个字符,可包含大小字母、数字及特殊符号(包含:!@#$%^&*-+=_)。
网络配置可用区选择可用区,资源将在服务商的该可用区创建。
网络设置专有网络选择建立私网连接的VPC。
网络设置安全组选择建立私网连接的安全组。
网络设置交换机和可用区选择建立私网连接的可用区与交换机。
+

部署步骤

+
    +
  1. 部署链接 + image.png
  2. +
  3. 单击部署链接,进入服务实例部署界面,根据界面提示,填写参数完成部署。 + image.png + 网络设置部分如果填写网络信息,私网连接的终端节点将在该可用区创建。
  4. +
+

注:由于本服务开启了网络变配功能,若此处不开启私网连接,也可通过变配功能开启。详情见变配流程-变配私网连接。 + 网络配置.png +2. 参数填写完成后点击下一步:确认订单确认参数。 + image.png +3. 确认订单完成后同意服务协议并点击立即创建,随后进入部署阶段。 + image.png

+

image.png +4. 等待部署完成后就可以开始使用服务。 + image.png +5. 使用服务 + 1. 本服务支持私网访问,租户可以通过PrivateLink实现私网访问(私网访问帮助文档), + 租户私网访问流程: + 1. 在服务实例的虚拟互联网页签中查看详细信息,连接时可以通过自定义域名(如果在创建服务实例时勾选了的话)、IP地址或者可用区域名进行访问。 + 虚拟互联网.png + 2. 在对应的vsw中创建ECS,创建好后安装mysql客户端。 + yum install mysql + or + apt install mysql-client + 3. 在该ECS中连接MySQL,下面展示分别用自定义域名、IP与可用区域名进行连接:

+
       1. 自定义域名方式访问:
+          ![自定义域名访问.png](自定义域名访问.png)
+       2. 通过IP访问:
+          ![通过ip访问.png](通过ip访问.png)
+       3. 通过可用区域名访问:
+          ![通过可用区域名访问.png](通过可用区域名访问.png)
+
+
    +
  1. 本服务支持修改服务配置参数。请注意,修改参数会引起服务重启。修改服务参数的流程:
      +
    1. 进入服务实例详情: + 配置参数详情.png
    2. +
    3. 点击修改参数,编辑修改值,完成后点击保存。 + 修改配置参数.png
    4. +
    5. 点击保存后,服务实例会进入参数更新流程,大致需要1~2分钟,请耐心等待。 + 修改中.png
    6. +
    7. 参数更新流程完成后,参数生效。 + 参数修改完成.png
    8. +
    +
  2. +
+

变配流程

+

说明

+

本服务默认开启支持变配私网连接、支持数据盘扩容。

+

私网连接变配:用户可以通过变配开启/关闭/新增/删除私网连接;

+

数据盘扩容:用户可通过变配扩容数据盘容量。

+

变配私网连接步骤

+
    +
  1. 前提说明:本变配示例为用户在创建服务实例时未开启私网连接,在服务实例创建完成后需要开启。 +创建服务实例未开启私网连接.jpg + 用户已有服务实例未开启私网连接。 +服务实例未开启私网连接.jpg
  2. +
  3. 点击右上角 修改配置 进入变配服务实例页面,选择网络变配。 +修改配置-网络变配.jpg
  4. +
  5. 点击下一步进入设置修改参数,添加私网连接参数。 +设置修改参数-网络变配.jpg +设置修改参数-添加网络变配信息.jpg + 注意:请确保填入的安全组入方向开启3306端口,否则私网访问将无法连接。
  6. +
  7. 点击下一步预览变配内容。 +预览参数-网络变配.jpg
  8. +
  9. 点击确定开始执行变配,等待变配完成。 +服务实例变配中.jpg
  10. +
  11. 变配完成,服务实例状态变为已部署,进入网络配置可见新增的私网连接信息。之后便可通过部署流程步骤5所述完成连接。 +服务实例变配完成-网络变配.jpg +后续若需要关闭/新增/删除私网访问等其他操作,同样可以通过修改配置-网络变配完成。
  12. +
+

磁盘容量扩容步骤

+
    +
  1. 前提说明
  2. +
  3. 本变配示例为用户扩容磁盘容量,服务模板中将"扩容磁盘容量"变配类型设置为升配,即仅能扩容;
  4. +
  5. 为使磁盘可变配与脚本可执行,服务模板中资源EcsInstanceGroup参数UpdatePolicy需设置为ForAllInstances,资源RunCommand参数Sync需设置为true。 + 以上参数模板中均已配置好,此处仅告知。
  6. +
  7. 点击右上角 修改配置 进入变配服务实例页面,选择磁盘容量扩容。 +修改配置-磁盘扩容.jpg
  8. +
  9. 点击下一步进入设置修改参数,将原有磁盘容量从200GB修改为400GB。 +设置修改参数-磁盘扩容.jpg
  10. +
  11. 点击下一步预览变配参数。 +预览参数-磁盘扩容.jpg
  12. +
  13. 点击确定开始执行变配,等待变配完成。 +服务实例变配中.jpg
  14. +
  15. 变配完成,服务实例状态变为已部署。
  16. +
  17. +

    查看结果:进入服务端ECS 通过命令 df -h 查看,磁盘容量已修改:

    +

    变配前: +变配前数据盘容量.jpg +变配后: +变配后数据盘容量.jpg

    +
  18. +
+

服务详细说明

+

本文提前将MySQL社区版安装包存放到该Github Repo中,构建服务过程中会将该安装包发布为计算巢部署物,并在ROS模板写入安装指令,ROS模板引擎在执行时便会自动执行安装了。

+
wget '{{ computenest::file::MySQL }}' -O mysql-community-release-el6-5.noarch.rpm
+rpm -ivh mysql-community-release-el6-5.noarch.rpm
+yum repolist all | grep mysql
+yum install mysql-community-server -y
+
+

{{ computenest::file::MySQL }} 为占位符,会由计算巢服务替换成文件部署物MySQL的http下载地址。

+

文件说明

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
文件路径说明
config.yaml构建服务的配置文件,服务构建过程中会使用计算巢命令行工具computenest-cli,computenest-cli会基于该配置文件构建服务。
parameters.yaml本服务为托管版单租,使用该文件渲染服务商需要配置的网络参数,包括VpcId,VSwitch等。
artifact/mysql-community-release-el6-5.noarch.rpmMySQL社区版安装包,构建过程会将该包发布为计算巢部署物。
icons/service_logo.jpg构建服务默认的图标。
templates/parameters.yaml本服务为托管版单租服务,所以只需要用户填写一部分参数,通过该文件指定用户所填参数。
templates/template.yamlROS模板文件,ROS模板引擎根据该模板能够自动创建出所有的资源。
+

templates/template.yaml主要由三部分组成

+
    +
  1. Parameters定义需要用户填写的参数,包括付费类型,实例规格和实例密码可用区参数。
  2. +
+
ZoneId:
+ Type: String
+ AssociationProperty: ALIYUN::ECS::Instance:ZoneId
+ Label:
+   en: VSwitch Available Zone
+   zh-cn: 可用区
+# 数据库root账户密码
+Password:
+ # 查询该参数时只输出星号(*)
+ NoEcho: true
+ Type: String
+ Description:
+   en: 'Database root account passwor, 8-32 characters, including uppercase and lowercase letters, numbers and special symbols (including: !@#$%^&*-+=_).'
+   zh-cn: 数据库root账户密码,长度8-32个字符,可包含大小字母、数字及特殊符号(包含:!@#$%^&*-+=_)。
+ Label:
+   en: Root Account Password
+   zh-cn: 数据库root账户密码
+ ConstraintDescription:
+   en: '8-32 characters, including uppercase and lowercase letters, numbers and special symbols (including: !@#$%^&*-+=_).'
+   zh-cn: 8-32个字符,可包含大小字母、数字及特殊符号(包含:!@#$%^&*-+=_)。
+ MinLength: '8'
+ MaxLength: '32'
+ AssociationProperty: ALIYUN::ECS::Instance::Password
+# 专有网络VPC实例ID
+VpcId:
+ AssociationProperty: ALIYUN::ECS::VPC::VPCId
+ Type: String
+ Label:
+   en: VPC ID
+   zh-cn: 专有网络VPC实例ID
+# 交换机实例ID
+VSwitchId:
+ AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
+ AssociationPropertyMetadata:
+   VpcId: ${VpcId}
+   ZoneId: ${ZoneId}
+ Type: String
+ Label:
+   en: VSwitch ID
+   zh-cn: 交换机实例ID
+# 数据盘大小
+DataDiskSize:
+ Description:
+   zh-cn: ECS实例数据盘大小,单位为GiB。取值范围:100~32768
+   en: 'ECS Instance disk size, range of values: 100-32768, units: GB'
+ Default: 200
+ MaxValue: 32768
+ MinValue: 100
+ Label:
+   zh-cn: 数据盘空间
+   en: Data Disk Space
+ Type: Number
+# Ecs实例类型
+EcsInstanceType:
+ Type: String
+ Label:
+   en: Instance Type
+   zh-cn: Ecs实例类型
+ AssociationProperty: ALIYUN::ECS::Instance::InstanceType
+ AllowedValues:
+   - ecs.c6.large
+   - ecs.c6.xlarge
+   - ecs.c6.2xlarge
+   - ecs.c6.4xlarge
+SlbInstanceType:
+ Type: String
+ Label:
+   en: Instance Type
+   zh-cn: Slb实例类型
+ AssociationProperty: ALIYUN::Slb::LoadBalance::LoadBalancerSpec
+ AllowedValues:
+   - slb.s1.small
+   - slb.s3.small
+
+
    +
  1. Resources定义需要开的资源,包括新开的Vpc,、VSwitch、ECS、Slb实例、私网连接。
  2. +
+
EcsSecurityGroup:
+ Type: 'ALIYUN::ECS::SecurityGroup'
+ Properties:
+   VpcId:
+     Ref: VpcId
+   SecurityGroupIngress:
+     - Priority: 1
+       PortRange: 3306/3306
+       NicType: internet
+       SourceCidrIp: 0.0.0.0/0
+       IpProtocol: tcp
+# Ecs实例
+EcsInstanceGroup:
+ Type: ALIYUN::ECS::InstanceGroup
+ Properties:
+   # I/O优化实例
+   IoOptimized: optimized
+   ZoneId:
+     Ref: ZoneId
+   DiskMappings:
+     - Category: cloud_essd
+       Device: /dev/xvdb
+       Size: 
+         Ref: DataDiskSize
+   SystemDiskSize: 40
+   # 付费方式:按量付费
+   InstanceChargeType: PostPaid
+   MaxAmount: 1
+   # 系统盘类型:cloud_essd
+   SystemDiskCategory: cloud_essd
+   # 实例名称
+   InstanceName:
+     Ref: ALIYUN::StackName
+   VpcId:
+     Ref: VpcId
+   SecurityGroupId:
+     Ref: EcsSecurityGroup
+   VSwitchId:
+     Ref: VSwitchId
+   # 指定CentOS 7.9镜像,如果修改镜像,UserData脚本需要进行适配
+   ImageId: "centos_7_9_x64_20G_alibase_20220727.vhd"
+   InstanceType:
+     Ref: EcsInstanceType
+   # 主机名
+   HostName:
+     Ref: ALIYUN::StackName
+   # Ecs登录密码
+   Password:
+     Ref: Password
+   # 是否为实例分配公网IP
+   AllocatePublicIP: true
+   InternetMaxBandwidthOut: 1
+# ECS执行脚本
+RunCommand:
+ Type: ALIYUN::ECS::RunCommand
+ Properties:
+  CommandContent:
+    Fn::Sub:
+      - |
+        #!/bin/sh
+        FLAG_FILE="/root/.disk_initialized"
+        PARTITION=/dev/vdb1
+        MOUNT_POINT=/data1
+
+        initialize_disk() {
+          # 初始化数据盘,对数据盘分区            
+          cat >> /root/InitDataDisk.sh << EOF
+          #!/bin/bash
+          echo "p
+          n
+          p
+
+
+
+          w
+          " |  fdisk -u /dev/vdb
+        EOF
+          /bin/bash /root/InitDataDisk.sh
+          rm -f /root/InitDataDisk.sh
+          rm -f InitDataDisk.sh
+
+          # 在新分区上创建文件系统
+          mkfs.ext4 /dev/vdb1
+
+          # 创建目录,MySQL将安装在该目录下
+          mkdir /data1
+
+          # 挂载文件系统
+          mount /dev/vdb1 /data1
+
+          # 向 /etc/fstab 写入新分区信息
+          echo /dev/vdb1 /data1 ext4 defaults,nodelalloc,noatime 0 2 >> /etc/fstab
+        }
+
+        install_mysql() {
+          # 安装社区版MySQL
+          cd /data1/
+          wget '{{ computenest::file::MySQL }}' -O mysql-community-release-el6-5.noarch.rpm
+          rpm -ivh mysql-community-release-el6-5.noarch.rpm
+          yum repolist all | grep mysql
+          yum install mysql-community-server -y
+
+          # 启动MySQL服务
+          service mysqld start
+        }
+
+        configure_mysql() {
+          # 以超级用户身份登入,创建admin用户,并允许admin用户以Password为密码远程登录
+          mysqladmin -u root password '${Password}'
+          echo "create database test character set utf8 collate utf8_bin;" > ./test.sql
+          echo "CREATE USER 'admin'@'%' IDENTIFIED BY '${Password}';" >> ./test.sql
+          echo "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;" >> ./test.sql
+          mysql -u root -p'${Password}' < ./test.sql
+        }
+
+        move_mysql_data() {
+          # 将MySQL的配置和数据路径移动到数据盘上
+          systemctl stop mysqld
+          rsync -av /var/lib/mysql /data1
+
+          # 修改配置文件
+          sed -i 's/\/var\/lib/\/data1/g' /etc/my.cnf
+          echo -e '\n' >> /etc/my.cnf
+          echo '[client]' >> /etc/my.cnf
+          echo 'port=3306' >> /etc/my.cnf
+          echo 'socket=/data1/mysql/mysql.sock' >> /etc/my.cnf
+
+          # 重启MySQL
+          systemctl start mysqld
+        }
+
+        expand_partition() {
+          # 使用 growpart 扩展分区
+          echo "Expanding partition..."
+          if ! growpart /dev/vdb 1; then
+            echo "Failed to expand partition"
+            exit 1
+          fi
+
+          # 通知系统分区的更改
+          partprobe $PARTITION
+
+          # 使用 e2fsck 检查文件系统
+          echo "Checking filesystem..."
+          e2fsck -f -y $PARTITION
+
+          # 扩展文件系统
+          echo "Resizing filesystem..."
+          resize2fs $PARTITION
+        }
+
+        if [ ! -f "$FLAG_FILE" ]; then
+          # 首次创建ECS时执行
+
+          # 确保网络就绪
+          sleep 15
+
+          initialize_disk
+          install_mysql
+          configure_mysql
+          move_mysql_data
+
+          # 当初始化完成后,创建一个标志文件
+          touch "$FLAG_FILE"
+          echo "Initialization complete. Flag file created."
+
+          # 执行成功回调WaitCondition结束WaitCondition的等待
+          ${CurlCli} -d "{\"Data\" : \"SUCCESS\", \"Status\" : \"SUCCESS\"}"
+
+        else
+          # 扩容数据盘时执行
+
+          # 停止MySQL服务
+          systemctl stop mysqld
+
+          # 检查并确保分区未被挂载
+          if mountpoint -q $MOUNT_POINT; then
+            umount $MOUNT_POINT
+          fi
+
+          expand_partition
+
+          # 重新挂载分区
+          echo "Remounting partition..."
+          mount $PARTITION $MOUNT_POINT
+
+          # 启动MySQL服务
+          systemctl start mysqld
+        fi
+    # 获取到WaitConditionHandle的地址放到 ${CurlCli}变量里
+      - CurlCli:
+          Fn::GetAtt:
+            - WaitConditionHandle
+            - CurlCli
+        # 数据库root账户密码
+        Password:
+          Ref: Password
+  Type: RunShellScript
+  Timeout: 900
+  Sync: true
+  InstanceIds:
+    - Ref: EcsInstanceGroup
+Slb:
+ Type: ALIYUN::SLB::LoadBalancer
+ Properties:
+   LoadBalancerName:
+     Fn::Join:
+       - '-'
+       - - mysql
+         - Ref: ALIYUN::StackName
+   VpcId:
+     Ref: VpcId
+   VSwitchId:
+     Ref: VSwitchId
+   PayType: PayOnDemand
+   AddressType: intranet
+   LoadBalancerSpec:
+     Ref: SlbInstanceType
+   SupportPrivateLink: true
+SlbBackendServerAttachment:
+ DependsOn:
+   - EcsInstanceGroup
+ Type: ALIYUN::SLB::BackendServerAttachment
+ Properties:
+   BackendServerList:
+     Fn::GetAtt:
+       - EcsInstanceGroup
+       - InstanceIds
+   LoadBalancerId:
+     Ref: Slb
+   BackendServerWeightList:
+     - 100
+     - 0
+SlbListener:
+ DependsOn: Slb
+ Type: ALIYUN::SLB::Listener
+ Properties:
+   Persistence:
+     CookieTimeout: 60
+     StickySession: 'on'
+     PersistenceTimeout: 180
+     XForwardedFor: 'off'
+     StickySessionType: insert
+   ListenerPort: 3306
+   Bandwidth: -1
+   HealthCheck:
+     HttpCode: http_2xx,http_3xx,http_4xx,http_5xx
+     HealthCheckType: tcp
+     UnhealthyThreshold: 3
+     Timeout: 5
+     HealthyThreshold: 3
+     Port: 3306
+     URI: /
+     Interval: 2
+   LoadBalancerId:
+     Ref: Slb
+   BackendServerPort: 3306
+   Protocol: tcp
+VpcEndpointService:
+ DependsOn: Slb
+ Type: ALIYUN::PrivateLink::VpcEndpointService
+ Properties:
+   ServiceDescription: isv service
+   Resource:
+     - ZoneId:
+         Ref: ZoneId
+       ResourceId:
+         Ref: Slb
+       ResourceType: slb
+   AutoAcceptEnabled: true
+
+
    +
  1. Outputs定义需要最终在计算巢概览页中对用户展示的输出
  2. +
+
Outputs:
+  EndpointServiceId:
+    Description:
+      en: EndpointService Id
+      zh-cn: 终端节点服务Id
+    Value:
+      Fn::GetAtt:
+        - VpcEndpointService
+        - ServiceId
+  Endpoint:
+    Value:
+      Fn::Join:
+        - ''
+        - - Ref: ALIYUN::StackName
+          - .mysql.com
+  MysqlUserName:
+    Description:
+      en: MySQL User Name
+      zh-cn: MySQL登录用户名
+    Value: admin
+
+

服务配置

+

创建代运维服务完成实例运维

+

创建包含变配功能的服务

+

创建包含服务升级功能的服务

+

服务交付

+

自定义服务架构图

+

服务文档上线流程

+

将服务上架云市场并上到云市场售卖

+ +
+ +
© 2009-2022 Aliyun.com 版权所有
+
+
+ + + + \ No newline at end of file diff --git a/js/highlight.min.js b/js/highlight.min.js new file mode 100644 index 0000000..cf57240 --- /dev/null +++ b/js/highlight.min.js @@ -0,0 +1,1207 @@ +/*! + Highlight.js v11.8.0 (git: 65687a907b) + (c) 2006-2023 undefined and other contributors + License: BSD-3-Clause + */ +var hljs=function(){"use strict";function e(n){ +return n instanceof Map?n.clear=n.delete=n.set=()=>{ +throw Error("map is read-only")}:n instanceof Set&&(n.add=n.clear=n.delete=()=>{ +throw Error("set is read-only") +}),Object.freeze(n),Object.getOwnPropertyNames(n).forEach((t=>{ +const a=n[t],i=typeof a;"object"!==i&&"function"!==i||Object.isFrozen(a)||e(a) +})),n}class n{constructor(e){ +void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1} +ignoreMatch(){this.isMatchIgnored=!0}}function t(e){ +return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'") +}function a(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n] +;return n.forEach((e=>{for(const n in e)t[n]=e[n]})),t}const i=e=>!!e.scope +;class r{constructor(e,n){ +this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){ +this.buffer+=t(e)}openNode(e){if(!i(e))return;const n=((e,{prefix:n})=>{ +if(e.startsWith("language:"))return e.replace("language:","language-") +;if(e.includes(".")){const t=e.split(".") +;return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${"_".repeat(n+1)}`))].join(" ") +}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)} +closeNode(e){i(e)&&(this.buffer+="")}value(){return this.buffer}span(e){ +this.buffer+=``}}const s=(e={})=>{const n={children:[]} +;return Object.assign(n,e),n};class o{constructor(){ +this.rootNode=s(),this.stack=[this.rootNode]}get top(){ +return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){ +this.top.children.push(e)}openNode(e){const n=s({scope:e}) +;this.add(n),this.stack.push(n)}closeNode(){ +if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){ +for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)} +walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){ +return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n), +n.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){ +"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{ +o._collapse(e)})))}}class l extends o{constructor(e){super(),this.options=e} +addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){ +this.closeNode()}__addSublanguage(e,n){const t=e.root +;n&&(t.scope="language:"+n),this.add(t)}toHTML(){ +return new r(this,this.options).value()}finalize(){ +return this.closeAllNodes(),!0}}function c(e){ +return e?"string"==typeof e?e:e.source:null}function d(e){return b("(?=",e,")")} +function g(e){return b("(?:",e,")*")}function u(e){return b("(?:",e,")?")} +function b(...e){return e.map((e=>c(e))).join("")}function m(...e){const n=(e=>{ +const n=e[e.length-1] +;return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{} +})(e);return"("+(n.capture?"":"?:")+e.map((e=>c(e))).join("|")+")"} +function p(e){return RegExp(e.toString()+"|").exec("").length-1} +const _=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./ +;function h(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t +;let a=c(e),i="";for(;a.length>0;){const e=_.exec(a);if(!e){i+=a;break} +i+=a.substring(0,e.index), +a=a.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+(Number(e[1])+n):(i+=e[0], +"("===e[0]&&t++)}return i})).map((e=>`(${e})`)).join(n)} +const f="[a-zA-Z]\\w*",E="[a-zA-Z_]\\w*",y="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",w="\\b(0b[01]+)",v={ +begin:"\\\\[\\s\\S]",relevance:0},O={scope:"string",begin:"'",end:"'", +illegal:"\\n",contains:[v]},k={scope:"string",begin:'"',end:'"',illegal:"\\n", +contains:[v]},x=(e,n,t={})=>{const i=a({scope:"comment",begin:e,end:n, +contains:[]},t);i.contains.push({scope:"doctag", +begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)", +end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0}) +;const r=m("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/) +;return i.contains.push({begin:b(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i +},M=x("//","$"),S=x("/\\*","\\*/"),A=x("#","$");var C=Object.freeze({ +__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:f,UNDERSCORE_IDENT_RE:E, +NUMBER_RE:y,C_NUMBER_RE:N,BINARY_NUMBER_RE:w, +RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", +SHEBANG:(e={})=>{const n=/^#![ ]*\// +;return e.binary&&(e.begin=b(n,/.*\b/,e.binary,/\b.*/)),a({scope:"meta",begin:n, +end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)}, +BACKSLASH_ESCAPE:v,APOS_STRING_MODE:O,QUOTE_STRING_MODE:k,PHRASAL_WORDS_MODE:{ +begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ +},COMMENT:x,C_LINE_COMMENT_MODE:M,C_BLOCK_COMMENT_MODE:S,HASH_COMMENT_MODE:A, +NUMBER_MODE:{scope:"number",begin:y,relevance:0},C_NUMBER_MODE:{scope:"number", +begin:N,relevance:0},BINARY_NUMBER_MODE:{scope:"number",begin:w,relevance:0}, +REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//, +end:/\/[gimuy]*/,illegal:/\n/,contains:[v,{begin:/\[/,end:/\]/,relevance:0, +contains:[v]}]}]},TITLE_MODE:{scope:"title",begin:f,relevance:0}, +UNDERSCORE_TITLE_MODE:{scope:"title",begin:E,relevance:0},METHOD_GUARD:{ +begin:"\\.\\s*"+E,relevance:0},END_SAME_AS_BEGIN:e=>Object.assign(e,{ +"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{ +n.data._beginMatch!==e[1]&&n.ignoreMatch()}})});function T(e,n){ +"."===e.input[e.index-1]&&n.ignoreMatch()}function R(e,n){ +void 0!==e.className&&(e.scope=e.className,delete e.className)}function D(e,n){ +n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)", +e.__beforeBegin=T,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords, +void 0===e.relevance&&(e.relevance=0))}function I(e,n){ +Array.isArray(e.illegal)&&(e.illegal=m(...e.illegal))}function L(e,n){ +if(e.match){ +if(e.begin||e.end)throw Error("begin & end are not supported with match") +;e.begin=e.match,delete e.match}}function B(e,n){ +void 0===e.relevance&&(e.relevance=1)}const $=(e,n)=>{if(!e.beforeMatch)return +;if(e.starts)throw Error("beforeMatch cannot be used with starts") +;const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n] +})),e.keywords=t.keywords,e.begin=b(t.beforeMatch,d(t.begin)),e.starts={ +relevance:0,contains:[Object.assign(t,{endsParent:!0})] +},e.relevance=0,delete t.beforeMatch +},z=["of","and","for","in","not","or","if","then","parent","list","value"],F="keyword" +;function U(e,n,t=F){const a=Object.create(null) +;return"string"==typeof e?i(t,e.split(" ")):Array.isArray(e)?i(t,e):Object.keys(e).forEach((t=>{ +Object.assign(a,U(e[t],n,t))})),a;function i(e,t){ +n&&(t=t.map((e=>e.toLowerCase()))),t.forEach((n=>{const t=n.split("|") +;a[t[0]]=[e,j(t[0],t[1])]}))}}function j(e,n){ +return n?Number(n):(e=>z.includes(e.toLowerCase()))(e)?0:1}const P={},K=e=>{ +console.error(e)},q=(e,...n)=>{console.log("WARN: "+e,...n)},H=(e,n)=>{ +P[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),P[`${e}/${n}`]=!0) +},G=Error();function Z(e,n,{key:t}){let a=0;const i=e[t],r={},s={} +;for(let e=1;e<=n.length;e++)s[e+a]=i[e],r[e+a]=!0,a+=p(n[e-1]) +;e[t]=s,e[t]._emit=r,e[t]._multi=!0}function W(e){(e=>{ +e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope, +delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={ +_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope +}),(e=>{if(Array.isArray(e.begin)){ +if(e.skip||e.excludeBegin||e.returnBegin)throw K("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), +G +;if("object"!=typeof e.beginScope||null===e.beginScope)throw K("beginScope must be object"), +G;Z(e,e.begin,{key:"beginScope"}),e.begin=h(e.begin,{joinWith:""})}})(e),(e=>{ +if(Array.isArray(e.end)){ +if(e.skip||e.excludeEnd||e.returnEnd)throw K("skip, excludeEnd, returnEnd not compatible with endScope: {}"), +G +;if("object"!=typeof e.endScope||null===e.endScope)throw K("endScope must be object"), +G;Z(e,e.end,{key:"endScope"}),e.end=h(e.end,{joinWith:""})}})(e)}function Q(e){ +function n(n,t){ +return RegExp(c(n),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(t?"g":"")) +}class t{constructor(){ +this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0} +addRule(e,n){ +n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]), +this.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null) +;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(h(e,{joinWith:"|" +}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex +;const n=this.matcherRe.exec(e);if(!n)return null +;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),a=this.matchIndexes[t] +;return n.splice(0,t),Object.assign(n,a)}}class i{constructor(){ +this.rules=[],this.multiRegexes=[], +this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){ +if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t +;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))), +n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){ +return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){ +this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){ +const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex +;let t=n.exec(e) +;if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{ +const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)} +return t&&(this.regexIndex+=t.position+1, +this.regexIndex===this.count&&this.considerAll()),t}} +if(e.compilerExtensions||(e.compilerExtensions=[]), +e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.") +;return e.classNameAliases=a(e.classNameAliases||{}),function t(r,s){const o=r +;if(r.isCompiled)return o +;[R,L,W,$].forEach((e=>e(r,s))),e.compilerExtensions.forEach((e=>e(r,s))), +r.__beforeBegin=null,[D,I,B].forEach((e=>e(r,s))),r.isCompiled=!0;let l=null +;return"object"==typeof r.keywords&&r.keywords.$pattern&&(r.keywords=Object.assign({},r.keywords), +l=r.keywords.$pattern, +delete r.keywords.$pattern),l=l||/\w+/,r.keywords&&(r.keywords=U(r.keywords,e.case_insensitive)), +o.keywordPatternRe=n(l,!0), +s&&(r.begin||(r.begin=/\B|\b/),o.beginRe=n(o.begin),r.end||r.endsWithParent||(r.end=/\B|\b/), +r.end&&(o.endRe=n(o.end)), +o.terminatorEnd=c(o.end)||"",r.endsWithParent&&s.terminatorEnd&&(o.terminatorEnd+=(r.end?"|":"")+s.terminatorEnd)), +r.illegal&&(o.illegalRe=n(r.illegal)), +r.contains||(r.contains=[]),r.contains=[].concat(...r.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((n=>a(e,{ +variants:null},n)))),e.cachedVariants?e.cachedVariants:X(e)?a(e,{ +starts:e.starts?a(e.starts):null +}):Object.isFrozen(e)?a(e):e))("self"===e?r:e)))),r.contains.forEach((e=>{t(e,o) +})),r.starts&&t(r.starts,s),o.matcher=(e=>{const n=new i +;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:"begin" +}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:"end" +}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n})(o),o}(e)}function X(e){ +return!!e&&(e.endsWithParent||X(e.starts))}class V extends Error{ +constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}} +const J=t,Y=a,ee=Symbol("nomatch"),ne=t=>{ +const a=Object.create(null),i=Object.create(null),r=[];let s=!0 +;const o="Could not find the language '{}', did you forget to load/include a language module?",c={ +disableAutodetect:!0,name:"Plain text",contains:[]};let p={ +ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i, +languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-", +cssSelector:"pre code",languages:null,__emitter:l};function _(e){ +return p.noHighlightRe.test(e)}function h(e,n,t){let a="",i="" +;"object"==typeof n?(a=e, +t=n.ignoreIllegals,i=n.language):(H("10.7.0","highlight(lang, code, ...args) has been deprecated."), +H("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"), +i=e,a=n),void 0===t&&(t=!0);const r={code:a,language:i};x("before:highlight",r) +;const s=r.result?r.result:f(r.language,r.code,t) +;return s.code=r.code,x("after:highlight",s),s}function f(e,t,i,r){ +const l=Object.create(null);function c(){if(!x.keywords)return void S.addText(A) +;let e=0;x.keywordPatternRe.lastIndex=0;let n=x.keywordPatternRe.exec(A),t="" +;for(;n;){t+=A.substring(e,n.index) +;const i=w.case_insensitive?n[0].toLowerCase():n[0],r=(a=i,x.keywords[a]);if(r){ +const[e,a]=r +;if(S.addText(t),t="",l[i]=(l[i]||0)+1,l[i]<=7&&(C+=a),e.startsWith("_"))t+=n[0];else{ +const t=w.classNameAliases[e]||e;g(n[0],t)}}else t+=n[0] +;e=x.keywordPatternRe.lastIndex,n=x.keywordPatternRe.exec(A)}var a +;t+=A.substring(e),S.addText(t)}function d(){null!=x.subLanguage?(()=>{ +if(""===A)return;let e=null;if("string"==typeof x.subLanguage){ +if(!a[x.subLanguage])return void S.addText(A) +;e=f(x.subLanguage,A,!0,M[x.subLanguage]),M[x.subLanguage]=e._top +}else e=E(A,x.subLanguage.length?x.subLanguage:null) +;x.relevance>0&&(C+=e.relevance),S.__addSublanguage(e._emitter,e.language) +})():c(),A=""}function g(e,n){ +""!==e&&(S.startScope(n),S.addText(e),S.endScope())}function u(e,n){let t=1 +;const a=n.length-1;for(;t<=a;){if(!e._emit[t]){t++;continue} +const a=w.classNameAliases[e[t]]||e[t],i=n[t];a?g(i,a):(A=i,c(),A=""),t++}} +function b(e,n){ +return e.scope&&"string"==typeof e.scope&&S.openNode(w.classNameAliases[e.scope]||e.scope), +e.beginScope&&(e.beginScope._wrap?(g(A,w.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap), +A=""):e.beginScope._multi&&(u(e.beginScope,n),A="")),x=Object.create(e,{parent:{ +value:x}}),x}function m(e,t,a){let i=((e,n)=>{const t=e&&e.exec(n) +;return t&&0===t.index})(e.endRe,a);if(i){if(e["on:end"]){const a=new n(e) +;e["on:end"](t,a),a.isMatchIgnored&&(i=!1)}if(i){ +for(;e.endsParent&&e.parent;)e=e.parent;return e}} +if(e.endsWithParent)return m(e.parent,t,a)}function _(e){ +return 0===x.matcher.regexIndex?(A+=e[0],1):(D=!0,0)}function h(e){ +const n=e[0],a=t.substring(e.index),i=m(x,e,a);if(!i)return ee;const r=x +;x.endScope&&x.endScope._wrap?(d(), +g(n,x.endScope._wrap)):x.endScope&&x.endScope._multi?(d(), +u(x.endScope,e)):r.skip?A+=n:(r.returnEnd||r.excludeEnd||(A+=n), +d(),r.excludeEnd&&(A=n));do{ +x.scope&&S.closeNode(),x.skip||x.subLanguage||(C+=x.relevance),x=x.parent +}while(x!==i.parent);return i.starts&&b(i.starts,e),r.returnEnd?0:n.length} +let y={};function N(a,r){const o=r&&r[0];if(A+=a,null==o)return d(),0 +;if("begin"===y.type&&"end"===r.type&&y.index===r.index&&""===o){ +if(A+=t.slice(r.index,r.index+1),!s){const n=Error(`0 width match regex (${e})`) +;throw n.languageName=e,n.badRule=y.rule,n}return 1} +if(y=r,"begin"===r.type)return(e=>{ +const t=e[0],a=e.rule,i=new n(a),r=[a.__beforeBegin,a["on:begin"]] +;for(const n of r)if(n&&(n(e,i),i.isMatchIgnored))return _(t) +;return a.skip?A+=t:(a.excludeBegin&&(A+=t), +d(),a.returnBegin||a.excludeBegin||(A=t)),b(a,e),a.returnBegin?0:t.length})(r) +;if("illegal"===r.type&&!i){ +const e=Error('Illegal lexeme "'+o+'" for mode "'+(x.scope||"")+'"') +;throw e.mode=x,e}if("end"===r.type){const e=h(r);if(e!==ee)return e} +if("illegal"===r.type&&""===o)return 1 +;if(R>1e5&&R>3*r.index)throw Error("potential infinite loop, way more iterations than matches") +;return A+=o,o.length}const w=v(e) +;if(!w)throw K(o.replace("{}",e)),Error('Unknown language: "'+e+'"') +;const O=Q(w);let k="",x=r||O;const M={},S=new p.__emitter(p);(()=>{const e=[] +;for(let n=x;n!==w;n=n.parent)n.scope&&e.unshift(n.scope) +;e.forEach((e=>S.openNode(e)))})();let A="",C=0,T=0,R=0,D=!1;try{ +if(w.__emitTokens)w.__emitTokens(t,S);else{for(x.matcher.considerAll();;){ +R++,D?D=!1:x.matcher.considerAll(),x.matcher.lastIndex=T +;const e=x.matcher.exec(t);if(!e)break;const n=N(t.substring(T,e.index),e) +;T=e.index+n}N(t.substring(T))}return S.finalize(),k=S.toHTML(),{language:e, +value:k,relevance:C,illegal:!1,_emitter:S,_top:x}}catch(n){ +if(n.message&&n.message.includes("Illegal"))return{language:e,value:J(t), +illegal:!0,relevance:0,_illegalBy:{message:n.message,index:T, +context:t.slice(T-100,T+100),mode:n.mode,resultSoFar:k},_emitter:S};if(s)return{ +language:e,value:J(t),illegal:!1,relevance:0,errorRaised:n,_emitter:S,_top:x} +;throw n}}function E(e,n){n=n||p.languages||Object.keys(a);const t=(e=>{ +const n={value:J(e),illegal:!1,relevance:0,_top:c,_emitter:new p.__emitter(p)} +;return n._emitter.addText(e),n})(e),i=n.filter(v).filter(k).map((n=>f(n,e,!1))) +;i.unshift(t);const r=i.sort(((e,n)=>{ +if(e.relevance!==n.relevance)return n.relevance-e.relevance +;if(e.language&&n.language){if(v(e.language).supersetOf===n.language)return 1 +;if(v(n.language).supersetOf===e.language)return-1}return 0})),[s,o]=r,l=s +;return l.secondBest=o,l}function y(e){let n=null;const t=(e=>{ +let n=e.className+" ";n+=e.parentNode?e.parentNode.className:"" +;const t=p.languageDetectRe.exec(n);if(t){const n=v(t[1]) +;return n||(q(o.replace("{}",t[1])), +q("Falling back to no-highlight mode for this block.",e)),n?t[1]:"no-highlight"} +return n.split(/\s+/).find((e=>_(e)||v(e)))})(e);if(_(t))return +;if(x("before:highlightElement",{el:e,language:t +}),e.children.length>0&&(p.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), +console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), +console.warn("The element with unescaped HTML:"), +console.warn(e)),p.throwUnescapedHTML))throw new V("One of your code blocks includes unescaped HTML.",e.innerHTML) +;n=e;const a=n.textContent,r=t?h(a,{language:t,ignoreIllegals:!0}):E(a) +;e.innerHTML=r.value,((e,n,t)=>{const a=n&&i[n]||t +;e.classList.add("hljs"),e.classList.add("language-"+a) +})(e,t,r.language),e.result={language:r.language,re:r.relevance, +relevance:r.relevance},r.secondBest&&(e.secondBest={ +language:r.secondBest.language,relevance:r.secondBest.relevance +}),x("after:highlightElement",{el:e,result:r,text:a})}let N=!1;function w(){ +"loading"!==document.readyState?document.querySelectorAll(p.cssSelector).forEach(y):N=!0 +}function v(e){return e=(e||"").toLowerCase(),a[e]||a[i[e]]} +function O(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach((e=>{ +i[e.toLowerCase()]=n}))}function k(e){const n=v(e) +;return n&&!n.disableAutodetect}function x(e,n){const t=e;r.forEach((e=>{ +e[t]&&e[t](n)}))} +"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(()=>{ +N&&w()}),!1),Object.assign(t,{highlight:h,highlightAuto:E,highlightAll:w, +highlightElement:y, +highlightBlock:e=>(H("10.7.0","highlightBlock will be removed entirely in v12.0"), +H("10.7.0","Please use highlightElement now."),y(e)),configure:e=>{p=Y(p,e)}, +initHighlighting:()=>{ +w(),H("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")}, +initHighlightingOnLoad:()=>{ +w(),H("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.") +},registerLanguage:(e,n)=>{let i=null;try{i=n(t)}catch(n){ +if(K("Language definition for '{}' could not be registered.".replace("{}",e)), +!s)throw n;K(n),i=c} +i.name||(i.name=e),a[e]=i,i.rawDefinition=n.bind(null,t),i.aliases&&O(i.aliases,{ +languageName:e})},unregisterLanguage:e=>{delete a[e] +;for(const n of Object.keys(i))i[n]===e&&delete i[n]}, +listLanguages:()=>Object.keys(a),getLanguage:v,registerAliases:O, +autoDetection:k,inherit:Y,addPlugin:e=>{(e=>{ +e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=n=>{ +e["before:highlightBlock"](Object.assign({block:n.el},n)) +}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=n=>{ +e["after:highlightBlock"](Object.assign({block:n.el},n))})})(e),r.push(e)}, +removePlugin:e=>{const n=r.indexOf(e);-1!==n&&r.splice(n,1)}}),t.debugMode=()=>{ +s=!1},t.safeMode=()=>{s=!0},t.versionString="11.8.0",t.regex={concat:b, +lookahead:d,either:m,optional:u,anyNumberOfTimes:g} +;for(const n in C)"object"==typeof C[n]&&e(C[n]);return Object.assign(t,C),t +},te=ne({});te.newInstance=()=>ne({});var ae=te;const ie=e=>({IMPORTANT:{ +scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{ +scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/}, +FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/}, +ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$", +contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{ +scope:"number", +begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?", +relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z][A-Za-z0-9_-]*/} +}),re=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],se=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],oe=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],le=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],ce=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse(),de=oe.concat(le) +;var ge="[0-9](_*[0-9])*",ue=`\\.(${ge})`,be="[0-9a-fA-F](_*[0-9a-fA-F])*",me={ +className:"number",variants:[{ +begin:`(\\b(${ge})((${ue})|\\.)?|(${ue}))[eE][+-]?(${ge})[fFdD]?\\b`},{ +begin:`\\b(${ge})((${ue})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{ +begin:`(${ue})[fFdD]?\\b`},{begin:`\\b(${ge})[fFdD]\\b`},{ +begin:`\\b0[xX]((${be})\\.?|(${be})?\\.(${be}))[pP][+-]?(${ge})[fFdD]?\\b`},{ +begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${be})[lL]?\\b`},{ +begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}], +relevance:0};function pe(e,n,t){return-1===t?"":e.replace(n,(a=>pe(e,n,t-1)))} +const _e="[A-Za-z$_][0-9A-Za-z$_]*",he=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],fe=["true","false","null","undefined","NaN","Infinity"],Ee=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],ye=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Ne=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],we=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],ve=[].concat(Ne,Ee,ye) +;function Oe(e){const n=e.regex,t=_e,a={begin:/<[A-Za-z0-9\\._:-]+/, +end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,n)=>{ +const t=e[0].length+e.index,a=e.input[t] +;if("<"===a||","===a)return void n.ignoreMatch();let i +;">"===a&&(((e,{after:n})=>{const t="",M={ +match:[/const|var|let/,/\s+/,t,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(x)], +keywords:"async",className:{1:"keyword",3:"title.function"},contains:[f]} +;return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:i,exports:{ +PARAMS_CONTAINS:h,CLASS_REFERENCE:y},illegal:/#(?![$_A-z])/, +contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{ +label:"use_strict",className:"meta",relevance:10, +begin:/^\s*['"]use (strict|asm)['"]/ +},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,d,g,u,b,m,{match:/\$\d+/},l,y,{ +className:"attr",begin:t+n.lookahead(":"),relevance:0},M,{ +begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*", +keywords:"return throw case",relevance:0,contains:[m,e.REGEXP_MODE,{ +className:"function",begin:x,returnBegin:!0,end:"\\s*=>",contains:[{ +className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{ +className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0, +excludeEnd:!0,keywords:i,contains:h}]}]},{begin:/,/,relevance:0},{match:/\s+/, +relevance:0},{variants:[{begin:"<>",end:""},{ +match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:a.begin, +"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{ +begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},N,{ +beginKeywords:"while if switch catch for"},{ +begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{", +returnBegin:!0,label:"func.def",contains:[f,e.inherit(e.TITLE_MODE,{begin:t, +className:"title.function"})]},{match:/\.\.\./,relevance:0},O,{match:"\\$"+t, +relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"}, +contains:[f]},w,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/, +className:"variable.constant"},E,k,{match:/\$[(.]/}]}} +const ke=e=>b(/\b/,e,/\w$/.test(e)?/\b/:/\B/),xe=["Protocol","Type"].map(ke),Me=["init","self"].map(ke),Se=["Any","Self"],Ae=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","break","case","catch","class","continue","convenience","default","defer","deinit","didSet","distributed","do","dynamic","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Ce=["false","nil","true"],Te=["assignment","associativity","higherThan","left","lowerThan","none","right"],Re=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warn_unqualified_access","#warning"],De=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Ie=m(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Le=m(Ie,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Be=b(Ie,Le,"*"),$e=m(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),ze=m($e,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Fe=b($e,ze,"*"),Ue=b(/[A-Z]/,ze,"*"),je=["autoclosure",b(/convention\(/,m("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",b(/objc\(/,Fe,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","testable","UIApplicationMain","unknown","usableFromInline"],Pe=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"] +;var Ke=Object.freeze({__proto__:null,grmr_bash:e=>{const n=e.regex,t={},a={ +begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[t]}]} +;Object.assign(t,{className:"variable",variants:[{ +begin:n.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},a]});const i={ +className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},r={ +begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/, +end:/(\w+)/,className:"string"})]}},s={className:"string",begin:/"/,end:/"/, +contains:[e.BACKSLASH_ESCAPE,t,i]};i.contains.push(s);const o={begin:/\$?\(\(/, +end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,t] +},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10 +}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0, +contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{ +name:"Bash",aliases:["sh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/, +keyword:["if","then","else","elif","fi","for","while","until","in","do","done","case","esac","function","select"], +literal:["true","false"], +built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"] +},contains:[l,e.SHEBANG(),c,o,e.HASH_COMMENT_MODE,r,{match:/(\/[a-z._-]+)+/},s,{ +className:"",begin:/\\"/},{className:"string",begin:/'/,end:/'/},t]}}, +grmr_c:e=>{const n=e.regex,t=e.COMMENT("//","$",{contains:[{begin:/\\\n/}] +}),a="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",r="("+a+"|"+n.optional(i)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",s={ +className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{ +match:/\batomic_[a-z]{3,6}\b/}]},o={className:"string",variants:[{ +begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{ +begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)", +end:"'",illegal:"."},e.END_SAME_AS_BEGIN({ +begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={ +className:"number",variants:[{begin:"\\b(0b[01']+)"},{ +begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)" +},{ +begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)" +}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{ +keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include" +},contains:[{begin:/\\\n/,relevance:0},e.inherit(o,{className:"string"}),{ +className:"string",begin:/<.*?>/},t,e.C_BLOCK_COMMENT_MODE]},d={ +className:"title",begin:n.optional(i)+e.IDENT_RE,relevance:0 +},g=n.optional(i)+e.IDENT_RE+"\\s*\\(",u={ +keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"], +type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal128","const","static","complex","bool","imaginary"], +literal:"true false NULL", +built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr" +},b=[c,s,t,e.C_BLOCK_COMMENT_MODE,l,o],m={variants:[{begin:/=/,end:/;/},{ +begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}], +keywords:u,contains:b.concat([{begin:/\(/,end:/\)/,keywords:u, +contains:b.concat(["self"]),relevance:0}]),relevance:0},p={ +begin:"("+r+"[\\*&\\s]+)+"+g,returnBegin:!0,end:/[{;=]/,excludeEnd:!0, +keywords:u,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:u,relevance:0},{ +begin:g,returnBegin:!0,contains:[e.inherit(d,{className:"title.function"})], +relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/, +keywords:u,relevance:0,contains:[t,e.C_BLOCK_COMMENT_MODE,o,l,s,{begin:/\(/, +end:/\)/,keywords:u,relevance:0,contains:["self",t,e.C_BLOCK_COMMENT_MODE,o,l,s] +}]},s,t,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:u, +disableAutodetect:!0,illegal:"=]/,contains:[{ +beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:c, +strings:o,keywords:u}}},grmr_cpp:e=>{const n=e.regex,t=e.COMMENT("//","$",{ +contains:[{begin:/\\\n/}] +}),a="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",r="(?!struct)("+a+"|"+n.optional(i)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",s={ +className:"type",begin:"\\b[a-z\\d_]*_t\\b"},o={className:"string",variants:[{ +begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{ +begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)", +end:"'",illegal:"."},e.END_SAME_AS_BEGIN({ +begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={ +className:"number",variants:[{begin:"\\b(0b[01']+)"},{ +begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)" +},{ +begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)" +}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{ +keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include" +},contains:[{begin:/\\\n/,relevance:0},e.inherit(o,{className:"string"}),{ +className:"string",begin:/<.*?>/},t,e.C_BLOCK_COMMENT_MODE]},d={ +className:"title",begin:n.optional(i)+e.IDENT_RE,relevance:0 +},g=n.optional(i)+e.IDENT_RE+"\\s*\\(",u={ +type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"], +keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"], +literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"], +_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"] +},b={className:"function.dispatch",relevance:0,keywords:{ +_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"] +}, +begin:n.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,n.lookahead(/(<[^<>]+>|)\s*\(/)) +},m=[b,c,s,t,e.C_BLOCK_COMMENT_MODE,l,o],p={variants:[{begin:/=/,end:/;/},{ +begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}], +keywords:u,contains:m.concat([{begin:/\(/,end:/\)/,keywords:u, +contains:m.concat(["self"]),relevance:0}]),relevance:0},_={className:"function", +begin:"("+r+"[\\*&\\s]+)+"+g,returnBegin:!0,end:/[{;=]/,excludeEnd:!0, +keywords:u,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:u,relevance:0},{ +begin:g,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{ +begin:/:/,endsWithParent:!0,contains:[o,l]},{relevance:0,match:/,/},{ +className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0, +contains:[t,e.C_BLOCK_COMMENT_MODE,o,l,s,{begin:/\(/,end:/\)/,keywords:u, +relevance:0,contains:["self",t,e.C_BLOCK_COMMENT_MODE,o,l,s]}] +},s,t,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C++", +aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:u,illegal:"",keywords:u,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:u},{ +match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/], +className:{1:"keyword",3:"title.class"}}])}},grmr_csharp:e=>{const n={ +keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","async","await","by","descending","equals","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","remove","select","set","unmanaged","value|0","var","when","where","with","yield"]), +built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"], +literal:["default","false","null","true"]},t=e.inherit(e.TITLE_MODE,{ +begin:"[a-zA-Z](\\.?\\w)*"}),a={className:"number",variants:[{ +begin:"\\b(0b[01']+)"},{ +begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{ +begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)" +}],relevance:0},i={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}] +},r=e.inherit(i,{illegal:/\n/}),s={className:"subst",begin:/\{/,end:/\}/, +keywords:n},o=e.inherit(s,{illegal:/\n/}),l={className:"string",begin:/\$"/, +end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/ +},e.BACKSLASH_ESCAPE,o]},c={className:"string",begin:/\$@"/,end:'"',contains:[{ +begin:/\{\{/},{begin:/\}\}/},{begin:'""'},s]},d=e.inherit(c,{illegal:/\n/, +contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},o]}) +;s.contains=[c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE], +o.contains=[d,l,r,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{ +illegal:/\n/})];const g={variants:[c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE] +},u={begin:"<",end:">",contains:[{beginKeywords:"in out"},t] +},b=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",m={ +begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"], +keywords:n,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0, +contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{ +begin:"\x3c!--|--\x3e"},{begin:""}]}] +}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#", +end:"$",keywords:{ +keyword:"if else elif endif define undef warning error line region endregion pragma checksum" +}},g,a,{beginKeywords:"class interface",relevance:0,end:/[{;=]/, +illegal:/[^\s:,]/,contains:[{beginKeywords:"where class" +},t,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace", +relevance:0,end:/[{;=]/,illegal:/[^\s:]/, +contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{ +beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/, +contains:[t,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta", +begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{ +className:"string",begin:/"/,end:/"/}]},{ +beginKeywords:"new return throw await else",relevance:0},{className:"function", +begin:"("+b+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0, +end:/\s*[{;=]/,excludeEnd:!0,keywords:n,contains:[{ +beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial", +relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0, +contains:[e.TITLE_MODE,u],relevance:0},{match:/\(\)/},{className:"params", +begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:n,relevance:0, +contains:[g,a,e.C_BLOCK_COMMENT_MODE] +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},m]}},grmr_css:e=>{ +const n=e.regex,t=ie(e),a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{ +name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{ +keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"}, +contains:[t.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/ +},t.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0 +},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0 +},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{ +begin:":("+oe.join("|")+")"},{begin:":(:)?("+le.join("|")+")"}] +},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+ce.join("|")+")\\b"},{ +begin:/:/,end:/[;}{]/, +contains:[t.BLOCK_COMMENT,t.HEXCOLOR,t.IMPORTANT,t.CSS_NUMBER_MODE,...a,{ +begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri" +},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0, +excludeEnd:!0}]},t.FUNCTION_DISPATCH]},{begin:n.lookahead(/@/),end:"[{;]", +relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/ +},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{ +$pattern:/[a-z-]+/,keyword:"and or not only",attribute:se.join(" ")},contains:[{ +begin:/[a-z-]+(?=:)/,className:"attribute"},...a,t.CSS_NUMBER_MODE]}]},{ +className:"selector-tag",begin:"\\b("+re.join("|")+")\\b"}]}},grmr_diff:e=>{ +const n=e.regex;return{name:"Diff",aliases:["patch"],contains:[{ +className:"meta",relevance:10, +match:n.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/) +},{className:"comment",variants:[{ +begin:n.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/), +end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{ +className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/, +end:/$/}]}},grmr_go:e=>{const n={ +keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"], +type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"], +literal:["true","false","iota","nil"], +built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"] +};return{name:"Go",aliases:["golang"],keywords:n,illegal:"{const n=e.regex;return{name:"GraphQL",aliases:["gql"], +case_insensitive:!0,disableAutodetect:!1,keywords:{ +keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"], +literal:["true","false","null"]}, +contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{ +scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation", +begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/, +end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{ +scope:"symbol",begin:n.concat(/[_A-Za-z][_0-9A-Za-z]*/,n.lookahead(/\s*:/)), +relevance:0}],illegal:[/[;<']/,/BEGIN/]}},grmr_ini:e=>{const n=e.regex,t={ +className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{ +begin:e.NUMBER_RE}]},a=e.COMMENT();a.variants=[{begin:/;/,end:/$/},{begin:/#/, +end:/$/}];const i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{ +begin:/\$\{(.*?)\}/}]},r={className:"literal", +begin:/\bon|off|true|false|yes|no\b/},s={className:"string", +contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{ +begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}] +},o={begin:/\[/,end:/\]/,contains:[a,r,i,s,t,"self"],relevance:0 +},l=n.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{ +name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/, +contains:[a,{className:"section",begin:/\[+/,end:/\]+/},{ +begin:n.concat(l,"(\\s*\\.\\s*",l,")*",n.lookahead(/\s*=\s*[^#\s]/)), +className:"attr",starts:{end:/$/,contains:[a,o,r,i,s,t]}}]}},grmr_java:e=>{ +const n=e.regex,t="[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*",a=t+pe("(?:<"+t+"~~~(?:\\s*,\\s*"+t+"~~~)*>)?",/~~~/g,2),i={ +keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits"], +literal:["false","true","null"], +type:["char","boolean","long","float","int","byte","short","double"], +built_in:["super","this"]},r={className:"meta",begin:"@"+t,contains:[{ +begin:/\(/,end:/\)/,contains:["self"]}]},s={className:"params",begin:/\(/, +end:/\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0} +;return{name:"Java",aliases:["jsp"],keywords:i,illegal:/<\/|#/, +contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/, +relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{ +begin:/import java\.[a-z]+\./,keywords:"import",relevance:2 +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/, +className:"string",contains:[e.BACKSLASH_ESCAPE] +},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{ +match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,t],className:{ +1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{ +begin:[n.concat(/(?!else)/,t),/\s+/,t,/\s+/,/=(?!=)/],className:{1:"type", +3:"variable",5:"operator"}},{begin:[/record/,/\s+/,t],className:{1:"keyword", +3:"title.class"},contains:[s,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{ +beginKeywords:"new throw return else",relevance:0},{ +begin:["(?:"+a+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{ +2:"title.function"},keywords:i,contains:[{className:"params",begin:/\(/, +end:/\)/,keywords:i,relevance:0, +contains:[r,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,me,e.C_BLOCK_COMMENT_MODE] +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},me,r]}},grmr_javascript:Oe, +grmr_json:e=>{const n=["true","false","null"],t={scope:"literal", +beginKeywords:n.join(" ")};return{name:"JSON",keywords:{literal:n},contains:[{ +className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{ +match:/[{}[\],:]/,className:"punctuation",relevance:0 +},e.QUOTE_STRING_MODE,t,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE], +illegal:"\\S"}},grmr_kotlin:e=>{const n={ +keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual", +built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing", +literal:"true false null"},t={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@" +},a={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},i={ +className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},r={className:"string", +variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,a]},{begin:"'",end:"'", +illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/, +contains:[e.BACKSLASH_ESCAPE,i,a]}]};a.contains.push(r);const s={ +className:"meta", +begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?" +},o={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/, +end:/\)/,contains:[e.inherit(r,{className:"string"}),"self"]}] +},l=me,c=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),d={ +variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/, +contains:[]}]},g=d;return g.variants[1].contains=[d],d.variants[1].contains=[g], +{name:"Kotlin",aliases:["kt","kts"],keywords:n, +contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag", +begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,c,{className:"keyword", +begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol", +begin:/@\w+/}]}},t,s,o,{className:"function",beginKeywords:"fun",end:"[(]|$", +returnBegin:!0,excludeEnd:!0,keywords:n,relevance:5,contains:[{ +begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0, +contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin://, +keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/, +endsParent:!0,keywords:n,relevance:0,contains:[{begin:/:/,end:/[=,\/]/, +endsWithParent:!0,contains:[d,e.C_LINE_COMMENT_MODE,c],relevance:0 +},e.C_LINE_COMMENT_MODE,c,s,o,r,e.C_NUMBER_MODE]},c]},{ +begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{ +3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0, +illegal:"extends implements",contains:[{ +beginKeywords:"public protected internal private constructor" +},e.UNDERSCORE_TITLE_MODE,{className:"type",begin://,excludeBegin:!0, +excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/, +excludeBegin:!0,returnEnd:!0},s,o]},r,{className:"meta",begin:"^#!/usr/bin/env", +end:"$",illegal:"\n"},l]}},grmr_less:e=>{ +const n=ie(e),t=de,a="[\\w-]+",i="("+a+"|@\\{"+a+"\\})",r=[],s=[],o=e=>({ +className:"string",begin:"~?"+e+".*?"+e}),l=(e,n,t)=>({className:e,begin:n, +relevance:t}),c={$pattern:/[a-z-]+/,keyword:"and or not only", +attribute:se.join(" ")},d={begin:"\\(",end:"\\)",contains:s,keywords:c, +relevance:0} +;s.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,o("'"),o('"'),n.CSS_NUMBER_MODE,{ +begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]", +excludeEnd:!0} +},n.HEXCOLOR,d,l("variable","@@?"+a,10),l("variable","@\\{"+a+"\\}"),l("built_in","~?`[^`]*?`"),{ +className:"attribute",begin:a+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0 +},n.IMPORTANT,{beginKeywords:"and not"},n.FUNCTION_DISPATCH);const g=s.concat({ +begin:/\{/,end:/\}/,contains:r}),u={beginKeywords:"when",endsWithParent:!0, +contains:[{beginKeywords:"and not"}].concat(s)},b={begin:i+"\\s*:", +returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/ +},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+ce.join("|")+")\\b", +end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:s}}] +},m={className:"keyword", +begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b", +starts:{end:"[;{}]",keywords:c,returnEnd:!0,contains:s,relevance:0}},p={ +className:"variable",variants:[{begin:"@"+a+"\\s*:",relevance:15},{begin:"@"+a +}],starts:{end:"[;}]",returnEnd:!0,contains:g}},_={variants:[{ +begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0, +returnEnd:!0,illegal:"[<='$\"]",relevance:0, +contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,u,l("keyword","all\\b"),l("variable","@\\{"+a+"\\}"),{ +begin:"\\b("+re.join("|")+")\\b",className:"selector-tag" +},n.CSS_NUMBER_MODE,l("selector-tag",i,0),l("selector-id","#"+i),l("selector-class","\\."+i,0),l("selector-tag","&",0),n.ATTRIBUTE_SELECTOR_MODE,{ +className:"selector-pseudo",begin:":("+oe.join("|")+")"},{ +className:"selector-pseudo",begin:":(:)?("+le.join("|")+")"},{begin:/\(/, +end:/\)/,relevance:0,contains:g},{begin:"!important"},n.FUNCTION_DISPATCH]},h={ +begin:a+":(:)?"+`(${t.join("|")})`,returnBegin:!0,contains:[_]} +;return r.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m,p,h,b,_,u,n.FUNCTION_DISPATCH), +{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:r}}, +grmr_lua:e=>{const n="\\[=*\\[",t="\\]=*\\]",a={begin:n,end:t,contains:["self"] +},i=[e.COMMENT("--(?!"+n+")","$"),e.COMMENT("--"+n,t,{contains:[a],relevance:10 +})];return{name:"Lua",keywords:{$pattern:e.UNDERSCORE_IDENT_RE, +literal:"true false nil", +keyword:"and break do else elseif end for goto if in local not or repeat return then until while", +built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove" +},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)", +contains:[e.inherit(e.TITLE_MODE,{ +begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params", +begin:"\\(",endsWithParent:!0,contains:i}].concat(i) +},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string", +begin:n,end:t,contains:[a],relevance:5}])}},grmr_makefile:e=>{const n={ +className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)", +contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%{ +const n=e.regex,t=n.concat(/[\p{L}_]/u,n.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),a={ +className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/, +contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}] +},r=e.inherit(i,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{ +className:"string"}),o=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),l={ +endsWithParent:!0,illegal:/`]+/}]}]}]};return{ +name:"HTML, XML", +aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"], +case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin://,relevance:10,contains:[i,o,s,r,{begin:/\[/,end:/\]/,contains:[{ +className:"meta",begin://,contains:[i,r,o,s]}]}] +},e.COMMENT(//,{relevance:10}),{begin://, +relevance:10},a,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/, +relevance:10,contains:[o]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag", +begin:/)/,end:/>/,keywords:{name:"style"},contains:[l],starts:{ +end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag", +begin:/)/,end:/>/,keywords:{name:"script"},contains:[l],starts:{ +end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{ +className:"tag",begin:/<>|<\/>/},{className:"tag", +begin:n.concat(//,/>/,/\s/)))), +end:/\/?>/,contains:[{className:"name",begin:t,relevance:0,starts:l}]},{ +className:"tag",begin:n.concat(/<\//,n.lookahead(n.concat(t,/>/))),contains:[{ +className:"name",begin:t,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]} +},grmr_markdown:e=>{const n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml", +relevance:0},t={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{ +begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/, +relevance:2},{ +begin:e.regex.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/), +relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{ +begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/ +},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0, +returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)", +excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[", +end:"\\]",excludeBegin:!0,excludeEnd:!0}]},a={className:"strong",contains:[], +variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}] +},i={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{ +begin:/_(?![_\s])/,end:/_/,relevance:0}]},r=e.inherit(a,{contains:[] +}),s=e.inherit(i,{contains:[]});a.contains.push(s),i.contains.push(r) +;let o=[n,t];return[a,i,r,s].forEach((e=>{e.contains=e.contains.concat(o) +})),o=o.concat(a,i),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{ +className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:o},{ +begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n", +contains:o}]}]},n,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)", +end:"\\s+",excludeEnd:!0},a,i,{className:"quote",begin:"^>\\s+",contains:o, +end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{ +begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{ +begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))", +contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{ +begin:"^[-\\*]{3,}",end:"$"},t,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{ +className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{ +className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}},grmr_objectivec:e=>{ +const n=/[a-zA-Z@][a-zA-Z0-9_]*/,t={$pattern:n, +keyword:["@interface","@class","@protocol","@implementation"]};return{ +name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"], +keywords:{"variable.language":["this","super"],$pattern:n, +keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"], +literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"], +built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"], +type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"] +},illegal:"/,end:/$/,illegal:"\\n" +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class", +begin:"("+t.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:t, +contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE, +relevance:0}]}},grmr_perl:e=>{const n=e.regex,t=/[dualxmsipngr]{0,12}/,a={ +$pattern:/[\w.]+/, +keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0" +},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:a},r={begin:/->\{/, +end:/\}/},s={variants:[{begin:/\$\d/},{ +begin:n.concat(/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])") +},{begin:/[$%@][^\s\w{]/,relevance:0}] +},o=[e.BACKSLASH_ESCAPE,i,s],l=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],c=(e,a,i="\\1")=>{ +const r="\\1"===i?i:n.concat(i,a) +;return n.concat(n.concat("(?:",e,")"),a,/(?:\\.|[^\\\/])*?/,r,/(?:\\.|[^\\\/])*?/,i,t) +},d=(e,a,i)=>n.concat(n.concat("(?:",e,")"),a,/(?:\\.|[^\\\/])*?/,i,t),g=[s,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{ +endsWithParent:!0}),r,{className:"string",contains:o,variants:[{ +begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[", +end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{ +begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">", +relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'", +contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`", +contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{ +begin:"-?\\w+\\s*=>",relevance:0}]},{className:"number", +begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b", +relevance:0},{ +begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*", +keywords:"split return print reverse grep",relevance:0, +contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{ +begin:c("s|tr|y",n.either(...l,{capture:!0}))},{begin:c("s|tr|y","\\(","\\)")},{ +begin:c("s|tr|y","\\[","\\]")},{begin:c("s|tr|y","\\{","\\}")}],relevance:2},{ +className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{ +begin:d("(?:m|qr)?",/\//,/\//)},{begin:d("m|qr",n.either(...l,{capture:!0 +}),/\1/)},{begin:d("m|qr",/\(/,/\)/)},{begin:d("m|qr",/\[/,/\]/)},{ +begin:d("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub", +end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE]},{ +begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$", +subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}] +}];return i.contains=g,r.contains=g,{name:"Perl",aliases:["pl","pm"],keywords:a, +contains:g}},grmr_php:e=>{ +const n=e.regex,t=/(?![A-Za-z0-9])(?![$])/,a=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,t),i=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,t),r={ +scope:"variable",match:"\\$+"+a},s={scope:"subst",variants:[{begin:/\$\w+/},{ +begin:/\{\$/,end:/\}/}]},o=e.inherit(e.APOS_STRING_MODE,{illegal:null +}),l="[ \t\n]",c={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{ +illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(s)}),o,{ +begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/, +contains:e.QUOTE_STRING_MODE.contains.concat(s),"on:begin":(e,n)=>{ +n.data._beginMatch=e[1]||e[2]},"on:end":(e,n)=>{ +n.data._beginMatch!==e[1]&&n.ignoreMatch()}},e.END_SAME_AS_BEGIN({ +begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/})]},d={scope:"number",variants:[{ +begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{ +begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{ +begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?" +}],relevance:0 +},g=["false","null","true"],u=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],b=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],m={ +keyword:u,literal:(e=>{const n=[];return e.forEach((e=>{ +n.push(e),e.toLowerCase()===e?n.push(e.toUpperCase()):n.push(e.toLowerCase()) +})),n})(g),built_in:b},p=e=>e.map((e=>e.replace(/\|\d+$/,""))),_={variants:[{ +match:[/new/,n.concat(l,"+"),n.concat("(?!",p(b).join("\\b|"),"\\b)"),i],scope:{ +1:"keyword",4:"title.class"}}]},h=n.concat(a,"\\b(?!\\()"),f={variants:[{ +match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),h],scope:{2:"variable.constant" +}},{match:[/::/,/class/],scope:{2:"variable.language"}},{ +match:[i,n.concat(/::/,n.lookahead(/(?!class\b)/)),h],scope:{1:"title.class", +3:"variable.constant"}},{match:[i,n.concat("::",n.lookahead(/(?!class\b)/))], +scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class", +3:"variable.language"}}]},E={scope:"attr", +match:n.concat(a,n.lookahead(":"),n.lookahead(/(?!::)/))},y={relevance:0, +begin:/\(/,end:/\)/,keywords:m,contains:[E,r,f,e.C_BLOCK_COMMENT_MODE,c,d,_] +},N={relevance:0, +match:[/\b/,n.concat("(?!fn\\b|function\\b|",p(u).join("\\b|"),"|",p(b).join("\\b|"),"\\b)"),a,n.concat(l,"*"),n.lookahead(/(?=\()/)], +scope:{3:"title.function.invoke"},contains:[y]};y.contains.push(N) +;const w=[E,f,e.C_BLOCK_COMMENT_MODE,c,d,_];return{case_insensitive:!1, +keywords:m,contains:[{begin:n.concat(/#\[\s*/,i),beginScope:"meta",end:/]/, +endScope:"meta",keywords:{literal:g,keyword:["new","array"]},contains:[{ +begin:/\[/,end:/]/,keywords:{literal:g,keyword:["new","array"]}, +contains:["self",...w]},...w,{scope:"meta",match:i}] +},e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{ +scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/, +keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE, +contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{ +begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{ +begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},r,N,f,{ +match:[/const/,/\s/,a],scope:{1:"keyword",3:"variable.constant"}},_,{ +scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/, +excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use" +},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params", +begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:m, +contains:["self",r,f,e.C_BLOCK_COMMENT_MODE,c,d]}]},{scope:"class",variants:[{ +beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait", +illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{ +beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{ +beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/, +contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{ +beginKeywords:"use",relevance:0,end:";",contains:[{ +match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},c,d]} +},grmr_php_template:e=>({name:"PHP template",subLanguage:"xml",contains:[{ +begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*", +end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0 +},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null, +skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null, +contains:null,skip:!0})]}]}),grmr_plaintext:e=>({name:"Plain text", +aliases:["text","txt"],disableAutodetect:!0}),grmr_python:e=>{ +const n=e.regex,t=/[\p{XID_Start}_]\p{XID_Continue}*/u,a=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],i={ +$pattern:/[A-Za-z]\w+|__\w+__/,keyword:a, +built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"], +literal:["__debug__","Ellipsis","False","None","NotImplemented","True"], +type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"] +},r={className:"meta",begin:/^(>>>|\.\.\.) /},s={className:"subst",begin:/\{/, +end:/\}/,keywords:i,illegal:/#/},o={begin:/\{\{/,relevance:0},l={ +className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{ +begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/, +contains:[e.BACKSLASH_ESCAPE,r],relevance:10},{ +begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/, +contains:[e.BACKSLASH_ESCAPE,r],relevance:10},{ +begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/, +contains:[e.BACKSLASH_ESCAPE,r,o,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/, +end:/"""/,contains:[e.BACKSLASH_ESCAPE,r,o,s]},{begin:/([uU]|[rR])'/,end:/'/, +relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{ +begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/, +end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/, +contains:[e.BACKSLASH_ESCAPE,o,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/, +contains:[e.BACKSLASH_ESCAPE,o,s]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE] +},c="[0-9](_?[0-9])*",d=`(\\b(${c}))?\\.(${c})|\\b(${c})\\.`,g="\\b|"+a.join("|"),u={ +className:"number",relevance:0,variants:[{ +begin:`(\\b(${c})|(${d}))[eE][+-]?(${c})[jJ]?(?=${g})`},{begin:`(${d})[jJ]?`},{ +begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{ +begin:`\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${g})` +},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\b(${c})[jJ](?=${g})` +}]},b={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:i, +contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={ +className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/, +end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i, +contains:["self",r,u,l,e.HASH_COMMENT_MODE]}]};return s.contains=[l,u,r],{ +name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:i, +illegal:/(<\/|\?)|=>/,contains:[r,u,{begin:/\bself\b/},{beginKeywords:"if", +relevance:0},l,b,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,t],scope:{ +1:"keyword",3:"title.function"},contains:[m]},{variants:[{ +match:[/\bclass/,/\s+/,t,/\s*/,/\(\s*/,t,/\s*\)/]},{match:[/\bclass/,/\s+/,t]}], +scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{ +className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[u,m,l]}]}}, +grmr_python_repl:e=>({aliases:["pycon"],contains:[{className:"meta.prompt", +starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{ +begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}),grmr_r:e=>{ +const n=e.regex,t=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,a=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,r=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/) +;return{name:"R",keywords:{$pattern:t, +keyword:"function if in break next repeat else for while", +literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10", +built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm" +},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/, +starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)), +endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{ +scope:"variable",variants:[{match:t},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0 +}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}] +}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE], +variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/ +}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/ +}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/ +}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/ +}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/ +}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"', +relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{ +1:"operator",2:"number"},match:[i,a]},{scope:{1:"operator",2:"number"}, +match:[/%[^%]*%/,a]},{scope:{1:"punctuation",2:"number"},match:[r,a]},{scope:{ +2:"number"},match:[/[^a-zA-Z0-9._]|^/,a]}]},{scope:{3:"operator"}, +match:[t,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{ +match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:r},{begin:"`",end:"`", +contains:[{begin:/\\./}]}]}},grmr_ruby:e=>{ +const n=e.regex,t="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",a=n.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=n.concat(a,/(::\w+)*/),r={ +"variable.constant":["__FILE__","__LINE__","__ENCODING__"], +"variable.language":["self","super"], +keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepend","public","private","protected","raise","throw"], +built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"], +literal:["true","false","nil"]},s={className:"doctag",begin:"@[A-Za-z]+"},o={ +begin:"#<",end:">"},l=[e.COMMENT("#","$",{contains:[s] +}),e.COMMENT("^=begin","^=end",{contains:[s],relevance:10 +}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],c={className:"subst",begin:/#\{/, +end:/\}/,keywords:r},d={className:"string",contains:[e.BACKSLASH_ESCAPE,c], +variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{ +begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{ +begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?/},{begin:/%[qQwWx]?\//, +end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{ +begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{ +begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{ +begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{ +begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{ +begin:n.concat(/<<[-~]?'?/,n.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)), +contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/, +contains:[e.BACKSLASH_ESCAPE,c]})]}]},g="[0-9](_?[0-9])*",u={className:"number", +relevance:0,variants:[{ +begin:`\\b([1-9](_?[0-9])*|0)(\\.(${g}))?([eE][+-]?(${g})|r)?i?\\b`},{ +begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b" +},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{ +begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{ +begin:"\\b0(_?[0-7])+r?i?\\b"}]},b={variants:[{match:/\(\)/},{ +className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0, +keywords:r}]},m=[d,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{ +match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class", +4:"title.class.inherited"},keywords:r},{match:[/(include|extend)\s+/,i],scope:{ +2:"title.class"},keywords:r},{relevance:0,match:[i,/\.new[. (]/],scope:{ +1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/, +className:"variable.constant"},{relevance:0,match:a,scope:"title.class"},{ +match:[/def/,/\s+/,t],scope:{1:"keyword",3:"title.function"},contains:[b]},{ +begin:e.IDENT_RE+"::"},{className:"symbol", +begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol", +begin:":(?!\\s)",contains:[d,{begin:t}],relevance:0},u,{className:"variable", +begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{ +className:"params",begin:/\|/,end:/\|/,excludeBegin:!0,excludeEnd:!0, +relevance:0,keywords:r},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*", +keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c], +illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{ +begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[", +end:"\\][a-z]*"}]}].concat(o,l),relevance:0}].concat(o,l) +;c.contains=m,b.contains=m;const p=[{begin:/^\s*=>/,starts:{end:"$",contains:m} +},{className:"meta.prompt", +begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])", +starts:{end:"$",keywords:r,contains:m}}];return l.unshift(o),{name:"Ruby", +aliases:["rb","gemspec","podspec","thor","irb"],keywords:r,illegal:/\/\*/, +contains:[e.SHEBANG({binary:"ruby"})].concat(p).concat(l).concat(m)}}, +grmr_rust:e=>{const n=e.regex,t={className:"title.function.invoke",relevance:0, +begin:n.concat(/\b/,/(?!let\b)/,e.IDENT_RE,n.lookahead(/\s*\(/)) +},a="([ui](8|16|32|64|128|size)|f(32|64))?",i=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],r=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"] +;return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:r, +keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","unsafe","unsized","use","virtual","where","while","yield"], +literal:["true","false","Some","None","Ok","Err"],built_in:i},illegal:""},t]}}, +grmr_scss:e=>{const n=ie(e),t=le,a=oe,i="@[a-z-]+",r={className:"variable", +begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS", +case_insensitive:!0,illegal:"[=/|']", +contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,n.CSS_NUMBER_MODE,{ +className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{ +className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0 +},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag", +begin:"\\b("+re.join("|")+")\\b",relevance:0},{className:"selector-pseudo", +begin:":("+a.join("|")+")"},{className:"selector-pseudo", +begin:":(:)?("+t.join("|")+")"},r,{begin:/\(/,end:/\)/, +contains:[n.CSS_NUMBER_MODE]},n.CSS_VARIABLE,{className:"attribute", +begin:"\\b("+ce.join("|")+")\\b"},{ +begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b" +},{begin:/:/,end:/[;}{]/,relevance:0, +contains:[n.BLOCK_COMMENT,r,n.HEXCOLOR,n.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.IMPORTANT,n.FUNCTION_DISPATCH] +},{begin:"@(page|font-face)",keywords:{$pattern:i,keyword:"@page @font-face"}},{ +begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/, +keyword:"and or not only",attribute:se.join(" ")},contains:[{begin:i, +className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute" +},r,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.HEXCOLOR,n.CSS_NUMBER_MODE] +},n.FUNCTION_DISPATCH]}},grmr_shell:e=>({name:"Shell Session", +aliases:["console","shellsession"],contains:[{className:"meta.prompt", +begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/, +subLanguage:"bash"}}]}),grmr_sql:e=>{ +const n=e.regex,t=e.COMMENT("--","$"),a=["true","false","unknown"],i=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],r=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],s=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],o=r,l=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter((e=>!r.includes(e))),c={ +begin:n.concat(/\b/,n.either(...o),/\s*\(/),relevance:0,keywords:{built_in:o}} +;return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{ +$pattern:/\b[\w\.]+/,keyword:((e,{exceptions:n,when:t}={})=>{const a=t +;return n=n||[],e.map((e=>e.match(/\|\d+$/)||n.includes(e)?e:a(e)?e+"|0":e)) +})(l,{when:e=>e.length<3}),literal:a,type:i, +built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"] +},contains:[{begin:n.either(...s),relevance:0,keywords:{$pattern:/[\w\.]+/, +keyword:l.concat(s),literal:a,type:i}},{className:"type", +begin:n.either("double precision","large object","with timezone","without timezone") +},c,{className:"variable",begin:/@[a-z0-9][a-z0-9_]*/},{className:"string", +variants:[{begin:/'/,end:/'/,contains:[{begin:/''/}]}]},{begin:/"/,end:/"/, +contains:[{begin:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,t,{ +className:"operator",begin:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/, +relevance:0}]}},grmr_swift:e=>{const n={match:/\s+/,relevance:0 +},t=e.COMMENT("/\\*","\\*/",{contains:["self"]}),a=[e.C_LINE_COMMENT_MODE,t],i={ +match:[/\./,m(...xe,...Me)],className:{2:"keyword"}},r={match:b(/\./,m(...Ae)), +relevance:0},s=Ae.filter((e=>"string"==typeof e)).concat(["_|0"]),o={variants:[{ +className:"keyword", +match:m(...Ae.filter((e=>"string"!=typeof e)).concat(Se).map(ke),...Me)}]},l={ +$pattern:m(/\b\w+/,/#\w+/),keyword:s.concat(Re),literal:Ce},c=[i,r,o],g=[{ +match:b(/\./,m(...De)),relevance:0},{className:"built_in", +match:b(/\b/,m(...De),/(?=\()/)}],u={match:/->/,relevance:0},p=[u,{ +className:"operator",relevance:0,variants:[{match:Be},{match:`\\.(\\.|${Le})+`}] +}],_="([0-9]_*)+",h="([0-9a-fA-F]_*)+",f={className:"number",relevance:0, +variants:[{match:`\\b(${_})(\\.(${_}))?([eE][+-]?(${_}))?\\b`},{ +match:`\\b0x(${h})(\\.(${h}))?([pP][+-]?(${_}))?\\b`},{match:/\b0o([0-7]_*)+\b/ +},{match:/\b0b([01]_*)+\b/}]},E=(e="")=>({className:"subst",variants:[{ +match:b(/\\/,e,/[0\\tnr"']/)},{match:b(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}] +}),y=(e="")=>({className:"subst",match:b(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/) +}),N=(e="")=>({className:"subst",label:"interpol",begin:b(/\\/,e,/\(/),end:/\)/ +}),w=(e="")=>({begin:b(e,/"""/),end:b(/"""/,e),contains:[E(e),y(e),N(e)] +}),v=(e="")=>({begin:b(e,/"/),end:b(/"/,e),contains:[E(e),N(e)]}),O={ +className:"string", +variants:[w(),w("#"),w("##"),w("###"),v(),v("#"),v("##"),v("###")]},k={ +match:b(/`/,Fe,/`/)},x=[k,{className:"variable",match:/\$\d+/},{ +className:"variable",match:`\\$${ze}+`}],M=[{match:/(@|#(un)?)available/, +className:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:Pe, +contains:[...p,f,O]}]}},{className:"keyword",match:b(/@/,m(...je))},{ +className:"meta",match:b(/@/,Fe)}],S={match:d(/\b[A-Z]/),relevance:0,contains:[{ +className:"type", +match:b(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,ze,"+") +},{className:"type",match:Ue,relevance:0},{match:/[?!]+/,relevance:0},{ +match:/\.\.\./,relevance:0},{match:b(/\s+&\s+/,d(Ue)),relevance:0}]},A={ +begin://,keywords:l,contains:[...a,...c,...M,u,S]};S.contains.push(A) +;const C={begin:/\(/,end:/\)/,relevance:0,keywords:l,contains:["self",{ +match:b(Fe,/\s*:/),keywords:"_|0",relevance:0 +},...a,...c,...g,...p,f,O,...x,...M,S]},T={begin://,contains:[...a,S] +},R={begin:/\(/,end:/\)/,keywords:l,contains:[{ +begin:m(d(b(Fe,/\s*:/)),d(b(Fe,/\s+/,Fe,/\s*:/))),end:/:/,relevance:0, +contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Fe}] +},...a,...c,...p,f,O,...M,S,C],endsParent:!0,illegal:/["']/},D={ +match:[/func/,/\s+/,m(k.match,Fe,Be)],className:{1:"keyword",3:"title.function" +},contains:[T,R,n],illegal:[/\[/,/%/]},I={ +match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"}, +contains:[T,R,n],illegal:/\[|%/},L={match:[/operator/,/\s+/,Be],className:{ +1:"keyword",3:"title"}},B={begin:[/precedencegroup/,/\s+/,Ue],className:{ +1:"keyword",3:"title"},contains:[S],keywords:[...Te,...Ce],end:/}/} +;for(const e of O.variants){const n=e.contains.find((e=>"interpol"===e.label)) +;n.keywords=l;const t=[...c,...g,...p,f,O,...x];n.contains=[...t,{begin:/\(/, +end:/\)/,contains:["self",...t]}]}return{name:"Swift",keywords:l, +contains:[...a,D,I,{beginKeywords:"struct protocol class extension enum actor", +end:"\\{",excludeEnd:!0,keywords:l,contains:[e.inherit(e.TITLE_MODE,{ +className:"title.class",begin:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/}),...c] +},L,B,{beginKeywords:"import",end:/$/,contains:[...a],relevance:0 +},...c,...g,...p,f,O,...x,...M,S,C]}},grmr_typescript:e=>{ +const n=Oe(e),t=_e,a=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={ +beginKeywords:"namespace",end:/\{/,excludeEnd:!0, +contains:[n.exports.CLASS_REFERENCE]},r={beginKeywords:"interface",end:/\{/, +excludeEnd:!0,keywords:{keyword:"interface extends",built_in:a}, +contains:[n.exports.CLASS_REFERENCE]},s={$pattern:_e, +keyword:he.concat(["type","namespace","interface","public","private","protected","implements","declare","abstract","readonly","enum","override"]), +literal:fe,built_in:ve.concat(a),"variable.language":we},o={className:"meta", +begin:"@"+t},l=(e,n,t)=>{const a=e.contains.findIndex((e=>e.label===n)) +;if(-1===a)throw Error("can not find mode to replace");e.contains.splice(a,1,t)} +;return Object.assign(n.keywords,s), +n.exports.PARAMS_CONTAINS.push(o),n.contains=n.contains.concat([o,i,r]), +l(n,"shebang",e.SHEBANG()),l(n,"use_strict",{className:"meta",relevance:10, +begin:/^\s*['"]use strict['"]/ +}),n.contains.find((e=>"func.def"===e.label)).relevance=0,Object.assign(n,{ +name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n},grmr_vbnet:e=>{ +const n=e.regex,t=/\d{1,2}\/\d{1,2}\/\d{4}/,a=/\d{4}-\d{1,2}-\d{1,2}/,i=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,r=/\d{1,2}(:\d{1,2}){1,2}/,s={ +className:"literal",variants:[{begin:n.concat(/# */,n.either(a,t),/ *#/)},{ +begin:n.concat(/# */,r,/ *#/)},{begin:n.concat(/# */,i,/ *#/)},{ +begin:n.concat(/# */,n.either(a,t),/ +/,n.either(i,r),/ *#/)}] +},o=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}] +}),l=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]}) +;return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0, +classNameAliases:{label:"symbol"},keywords:{ +keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield", +built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort", +type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort", +literal:"true false nothing"}, +illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{ +className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/, +end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s,{className:"number",relevance:0, +variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/ +},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{ +begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{ +className:"label",begin:/^\w+:/},o,l,{className:"meta", +begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/, +end:/$/,keywords:{ +keyword:"const disable else elseif enable end externalsource if region then"}, +contains:[l]}]}},grmr_wasm:e=>{e.regex;const n=e.COMMENT(/\(;/,/;\)/) +;return n.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/, +keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"] +},contains:[e.COMMENT(/;;/,/$/),n,{match:[/(?:offset|align)/,/\s*/,/=/], +className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{ +match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{ +begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword", +3:"title.function"}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/, +className:"type"},{className:"keyword", +match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/ +},{className:"number",relevance:0, +match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/ +}]}},grmr_yaml:e=>{ +const n="true false yes no null",t="[\\w#;/?:@&=+$,.~*'()[\\]]+",a={ +className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/ +},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable", +variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},i=e.inherit(a,{ +variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),r={ +end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},s={begin:/\{/, +end:/\}/,contains:[r],illegal:"\\n",relevance:0},o={begin:"\\[",end:"\\]", +contains:[r],illegal:"\\n",relevance:0},l=[{className:"attr",variants:[{ +begin:"\\w[\\w :\\/.-]*:(?=[ \t]|$)"},{begin:'"\\w[\\w :\\/.-]*":(?=[ \t]|$)'},{ +begin:"'\\w[\\w :\\/.-]*':(?=[ \t]|$)"}]},{className:"meta",begin:"^---\\s*$", +relevance:10},{className:"string", +begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{ +begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0, +relevance:0},{className:"type",begin:"!\\w+!"+t},{className:"type", +begin:"!<"+t+">"},{className:"type",begin:"!"+t},{className:"type",begin:"!!"+t +},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta", +begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)", +relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},{ +className:"number", +begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b" +},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},s,o,a],c=[...l] +;return c.pop(),c.push(i),r.contains=c,{name:"YAML",case_insensitive:!0, +aliases:["yml"],contains:l}}});const qe=ae;for(const e of Object.keys(Ke)){ +const n=e.replace("grmr_","").replace("_","-");qe.registerLanguage(n,Ke[e])} +return qe}() +;"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs); \ No newline at end of file diff --git a/js/theme.js b/js/theme.js new file mode 100644 index 0000000..e69de29 diff --git "a/privateLink\350\256\277\351\227\256\345\234\260\345\235\200.jpg" "b/privateLink\350\256\277\351\227\256\345\234\260\345\235\200.jpg" new file mode 100644 index 0000000..ad264d6 Binary files /dev/null and "b/privateLink\350\256\277\351\227\256\345\234\260\345\235\200.jpg" differ diff --git a/search/lunr.js b/search/lunr.js new file mode 100644 index 0000000..aca0a16 --- /dev/null +++ b/search/lunr.js @@ -0,0 +1,3475 @@ +/** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9 + * Copyright (C) 2020 Oliver Nightingale + * @license MIT + */ + +;(function(){ + +/** + * A convenience function for configuring and constructing + * a new lunr Index. + * + * A lunr.Builder instance is created and the pipeline setup + * with a trimmer, stop word filter and stemmer. + * + * This builder object is yielded to the configuration function + * that is passed as a parameter, allowing the list of fields + * and other builder parameters to be customised. + * + * All documents _must_ be added within the passed config function. + * + * @example + * var idx = lunr(function () { + * this.field('title') + * this.field('body') + * this.ref('id') + * + * documents.forEach(function (doc) { + * this.add(doc) + * }, this) + * }) + * + * @see {@link lunr.Builder} + * @see {@link lunr.Pipeline} + * @see {@link lunr.trimmer} + * @see {@link lunr.stopWordFilter} + * @see {@link lunr.stemmer} + * @namespace {function} lunr + */ +var lunr = function (config) { + var builder = new lunr.Builder + + builder.pipeline.add( + lunr.trimmer, + lunr.stopWordFilter, + lunr.stemmer + ) + + builder.searchPipeline.add( + lunr.stemmer + ) + + config.call(builder, builder) + return builder.build() +} + +lunr.version = "2.3.9" +/*! + * lunr.utils + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * A namespace containing utils for the rest of the lunr library + * @namespace lunr.utils + */ +lunr.utils = {} + +/** + * Print a warning message to the console. + * + * @param {String} message The message to be printed. + * @memberOf lunr.utils + * @function + */ +lunr.utils.warn = (function (global) { + /* eslint-disable no-console */ + return function (message) { + if (global.console && console.warn) { + console.warn(message) + } + } + /* eslint-enable no-console */ +})(this) + +/** + * Convert an object to a string. + * + * In the case of `null` and `undefined` the function returns + * the empty string, in all other cases the result of calling + * `toString` on the passed object is returned. + * + * @param {Any} obj The object to convert to a string. + * @return {String} string representation of the passed object. + * @memberOf lunr.utils + */ +lunr.utils.asString = function (obj) { + if (obj === void 0 || obj === null) { + return "" + } else { + return obj.toString() + } +} + +/** + * Clones an object. + * + * Will create a copy of an existing object such that any mutations + * on the copy cannot affect the original. + * + * Only shallow objects are supported, passing a nested object to this + * function will cause a TypeError. + * + * Objects with primitives, and arrays of primitives are supported. + * + * @param {Object} obj The object to clone. + * @return {Object} a clone of the passed object. + * @throws {TypeError} when a nested object is passed. + * @memberOf Utils + */ +lunr.utils.clone = function (obj) { + if (obj === null || obj === undefined) { + return obj + } + + var clone = Object.create(null), + keys = Object.keys(obj) + + for (var i = 0; i < keys.length; i++) { + var key = keys[i], + val = obj[key] + + if (Array.isArray(val)) { + clone[key] = val.slice() + continue + } + + if (typeof val === 'string' || + typeof val === 'number' || + typeof val === 'boolean') { + clone[key] = val + continue + } + + throw new TypeError("clone is not deep and does not support nested objects") + } + + return clone +} +lunr.FieldRef = function (docRef, fieldName, stringValue) { + this.docRef = docRef + this.fieldName = fieldName + this._stringValue = stringValue +} + +lunr.FieldRef.joiner = "/" + +lunr.FieldRef.fromString = function (s) { + var n = s.indexOf(lunr.FieldRef.joiner) + + if (n === -1) { + throw "malformed field ref string" + } + + var fieldRef = s.slice(0, n), + docRef = s.slice(n + 1) + + return new lunr.FieldRef (docRef, fieldRef, s) +} + +lunr.FieldRef.prototype.toString = function () { + if (this._stringValue == undefined) { + this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef + } + + return this._stringValue +} +/*! + * lunr.Set + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * A lunr set. + * + * @constructor + */ +lunr.Set = function (elements) { + this.elements = Object.create(null) + + if (elements) { + this.length = elements.length + + for (var i = 0; i < this.length; i++) { + this.elements[elements[i]] = true + } + } else { + this.length = 0 + } +} + +/** + * A complete set that contains all elements. + * + * @static + * @readonly + * @type {lunr.Set} + */ +lunr.Set.complete = { + intersect: function (other) { + return other + }, + + union: function () { + return this + }, + + contains: function () { + return true + } +} + +/** + * An empty set that contains no elements. + * + * @static + * @readonly + * @type {lunr.Set} + */ +lunr.Set.empty = { + intersect: function () { + return this + }, + + union: function (other) { + return other + }, + + contains: function () { + return false + } +} + +/** + * Returns true if this set contains the specified object. + * + * @param {object} object - Object whose presence in this set is to be tested. + * @returns {boolean} - True if this set contains the specified object. + */ +lunr.Set.prototype.contains = function (object) { + return !!this.elements[object] +} + +/** + * Returns a new set containing only the elements that are present in both + * this set and the specified set. + * + * @param {lunr.Set} other - set to intersect with this set. + * @returns {lunr.Set} a new set that is the intersection of this and the specified set. + */ + +lunr.Set.prototype.intersect = function (other) { + var a, b, elements, intersection = [] + + if (other === lunr.Set.complete) { + return this + } + + if (other === lunr.Set.empty) { + return other + } + + if (this.length < other.length) { + a = this + b = other + } else { + a = other + b = this + } + + elements = Object.keys(a.elements) + + for (var i = 0; i < elements.length; i++) { + var element = elements[i] + if (element in b.elements) { + intersection.push(element) + } + } + + return new lunr.Set (intersection) +} + +/** + * Returns a new set combining the elements of this and the specified set. + * + * @param {lunr.Set} other - set to union with this set. + * @return {lunr.Set} a new set that is the union of this and the specified set. + */ + +lunr.Set.prototype.union = function (other) { + if (other === lunr.Set.complete) { + return lunr.Set.complete + } + + if (other === lunr.Set.empty) { + return this + } + + return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements))) +} +/** + * A function to calculate the inverse document frequency for + * a posting. This is shared between the builder and the index + * + * @private + * @param {object} posting - The posting for a given term + * @param {number} documentCount - The total number of documents. + */ +lunr.idf = function (posting, documentCount) { + var documentsWithTerm = 0 + + for (var fieldName in posting) { + if (fieldName == '_index') continue // Ignore the term index, its not a field + documentsWithTerm += Object.keys(posting[fieldName]).length + } + + var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5) + + return Math.log(1 + Math.abs(x)) +} + +/** + * A token wraps a string representation of a token + * as it is passed through the text processing pipeline. + * + * @constructor + * @param {string} [str=''] - The string token being wrapped. + * @param {object} [metadata={}] - Metadata associated with this token. + */ +lunr.Token = function (str, metadata) { + this.str = str || "" + this.metadata = metadata || {} +} + +/** + * Returns the token string that is being wrapped by this object. + * + * @returns {string} + */ +lunr.Token.prototype.toString = function () { + return this.str +} + +/** + * A token update function is used when updating or optionally + * when cloning a token. + * + * @callback lunr.Token~updateFunction + * @param {string} str - The string representation of the token. + * @param {Object} metadata - All metadata associated with this token. + */ + +/** + * Applies the given function to the wrapped string token. + * + * @example + * token.update(function (str, metadata) { + * return str.toUpperCase() + * }) + * + * @param {lunr.Token~updateFunction} fn - A function to apply to the token string. + * @returns {lunr.Token} + */ +lunr.Token.prototype.update = function (fn) { + this.str = fn(this.str, this.metadata) + return this +} + +/** + * Creates a clone of this token. Optionally a function can be + * applied to the cloned token. + * + * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token. + * @returns {lunr.Token} + */ +lunr.Token.prototype.clone = function (fn) { + fn = fn || function (s) { return s } + return new lunr.Token (fn(this.str, this.metadata), this.metadata) +} +/*! + * lunr.tokenizer + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * A function for splitting a string into tokens ready to be inserted into + * the search index. Uses `lunr.tokenizer.separator` to split strings, change + * the value of this property to change how strings are split into tokens. + * + * This tokenizer will convert its parameter to a string by calling `toString` and + * then will split this string on the character in `lunr.tokenizer.separator`. + * Arrays will have their elements converted to strings and wrapped in a lunr.Token. + * + * Optional metadata can be passed to the tokenizer, this metadata will be cloned and + * added as metadata to every token that is created from the object to be tokenized. + * + * @static + * @param {?(string|object|object[])} obj - The object to convert into tokens + * @param {?object} metadata - Optional metadata to associate with every token + * @returns {lunr.Token[]} + * @see {@link lunr.Pipeline} + */ +lunr.tokenizer = function (obj, metadata) { + if (obj == null || obj == undefined) { + return [] + } + + if (Array.isArray(obj)) { + return obj.map(function (t) { + return new lunr.Token( + lunr.utils.asString(t).toLowerCase(), + lunr.utils.clone(metadata) + ) + }) + } + + var str = obj.toString().toLowerCase(), + len = str.length, + tokens = [] + + for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) { + var char = str.charAt(sliceEnd), + sliceLength = sliceEnd - sliceStart + + if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) { + + if (sliceLength > 0) { + var tokenMetadata = lunr.utils.clone(metadata) || {} + tokenMetadata["position"] = [sliceStart, sliceLength] + tokenMetadata["index"] = tokens.length + + tokens.push( + new lunr.Token ( + str.slice(sliceStart, sliceEnd), + tokenMetadata + ) + ) + } + + sliceStart = sliceEnd + 1 + } + + } + + return tokens +} + +/** + * The separator used to split a string into tokens. Override this property to change the behaviour of + * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens. + * + * @static + * @see lunr.tokenizer + */ +lunr.tokenizer.separator = /[\s\-]+/ +/*! + * lunr.Pipeline + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * lunr.Pipelines maintain an ordered list of functions to be applied to all + * tokens in documents entering the search index and queries being ran against + * the index. + * + * An instance of lunr.Index created with the lunr shortcut will contain a + * pipeline with a stop word filter and an English language stemmer. Extra + * functions can be added before or after either of these functions or these + * default functions can be removed. + * + * When run the pipeline will call each function in turn, passing a token, the + * index of that token in the original list of all tokens and finally a list of + * all the original tokens. + * + * The output of functions in the pipeline will be passed to the next function + * in the pipeline. To exclude a token from entering the index the function + * should return undefined, the rest of the pipeline will not be called with + * this token. + * + * For serialisation of pipelines to work, all functions used in an instance of + * a pipeline should be registered with lunr.Pipeline. Registered functions can + * then be loaded. If trying to load a serialised pipeline that uses functions + * that are not registered an error will be thrown. + * + * If not planning on serialising the pipeline then registering pipeline functions + * is not necessary. + * + * @constructor + */ +lunr.Pipeline = function () { + this._stack = [] +} + +lunr.Pipeline.registeredFunctions = Object.create(null) + +/** + * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token + * string as well as all known metadata. A pipeline function can mutate the token string + * or mutate (or add) metadata for a given token. + * + * A pipeline function can indicate that the passed token should be discarded by returning + * null, undefined or an empty string. This token will not be passed to any downstream pipeline + * functions and will not be added to the index. + * + * Multiple tokens can be returned by returning an array of tokens. Each token will be passed + * to any downstream pipeline functions and all will returned tokens will be added to the index. + * + * Any number of pipeline functions may be chained together using a lunr.Pipeline. + * + * @interface lunr.PipelineFunction + * @param {lunr.Token} token - A token from the document being processed. + * @param {number} i - The index of this token in the complete list of tokens for this document/field. + * @param {lunr.Token[]} tokens - All tokens for this document/field. + * @returns {(?lunr.Token|lunr.Token[])} + */ + +/** + * Register a function with the pipeline. + * + * Functions that are used in the pipeline should be registered if the pipeline + * needs to be serialised, or a serialised pipeline needs to be loaded. + * + * Registering a function does not add it to a pipeline, functions must still be + * added to instances of the pipeline for them to be used when running a pipeline. + * + * @param {lunr.PipelineFunction} fn - The function to check for. + * @param {String} label - The label to register this function with + */ +lunr.Pipeline.registerFunction = function (fn, label) { + if (label in this.registeredFunctions) { + lunr.utils.warn('Overwriting existing registered function: ' + label) + } + + fn.label = label + lunr.Pipeline.registeredFunctions[fn.label] = fn +} + +/** + * Warns if the function is not registered as a Pipeline function. + * + * @param {lunr.PipelineFunction} fn - The function to check for. + * @private + */ +lunr.Pipeline.warnIfFunctionNotRegistered = function (fn) { + var isRegistered = fn.label && (fn.label in this.registeredFunctions) + + if (!isRegistered) { + lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\n', fn) + } +} + +/** + * Loads a previously serialised pipeline. + * + * All functions to be loaded must already be registered with lunr.Pipeline. + * If any function from the serialised data has not been registered then an + * error will be thrown. + * + * @param {Object} serialised - The serialised pipeline to load. + * @returns {lunr.Pipeline} + */ +lunr.Pipeline.load = function (serialised) { + var pipeline = new lunr.Pipeline + + serialised.forEach(function (fnName) { + var fn = lunr.Pipeline.registeredFunctions[fnName] + + if (fn) { + pipeline.add(fn) + } else { + throw new Error('Cannot load unregistered function: ' + fnName) + } + }) + + return pipeline +} + +/** + * Adds new functions to the end of the pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline. + */ +lunr.Pipeline.prototype.add = function () { + var fns = Array.prototype.slice.call(arguments) + + fns.forEach(function (fn) { + lunr.Pipeline.warnIfFunctionNotRegistered(fn) + this._stack.push(fn) + }, this) +} + +/** + * Adds a single function after a function that already exists in the + * pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline. + * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline. + */ +lunr.Pipeline.prototype.after = function (existingFn, newFn) { + lunr.Pipeline.warnIfFunctionNotRegistered(newFn) + + var pos = this._stack.indexOf(existingFn) + if (pos == -1) { + throw new Error('Cannot find existingFn') + } + + pos = pos + 1 + this._stack.splice(pos, 0, newFn) +} + +/** + * Adds a single function before a function that already exists in the + * pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline. + * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline. + */ +lunr.Pipeline.prototype.before = function (existingFn, newFn) { + lunr.Pipeline.warnIfFunctionNotRegistered(newFn) + + var pos = this._stack.indexOf(existingFn) + if (pos == -1) { + throw new Error('Cannot find existingFn') + } + + this._stack.splice(pos, 0, newFn) +} + +/** + * Removes a function from the pipeline. + * + * @param {lunr.PipelineFunction} fn The function to remove from the pipeline. + */ +lunr.Pipeline.prototype.remove = function (fn) { + var pos = this._stack.indexOf(fn) + if (pos == -1) { + return + } + + this._stack.splice(pos, 1) +} + +/** + * Runs the current list of functions that make up the pipeline against the + * passed tokens. + * + * @param {Array} tokens The tokens to run through the pipeline. + * @returns {Array} + */ +lunr.Pipeline.prototype.run = function (tokens) { + var stackLength = this._stack.length + + for (var i = 0; i < stackLength; i++) { + var fn = this._stack[i] + var memo = [] + + for (var j = 0; j < tokens.length; j++) { + var result = fn(tokens[j], j, tokens) + + if (result === null || result === void 0 || result === '') continue + + if (Array.isArray(result)) { + for (var k = 0; k < result.length; k++) { + memo.push(result[k]) + } + } else { + memo.push(result) + } + } + + tokens = memo + } + + return tokens +} + +/** + * Convenience method for passing a string through a pipeline and getting + * strings out. This method takes care of wrapping the passed string in a + * token and mapping the resulting tokens back to strings. + * + * @param {string} str - The string to pass through the pipeline. + * @param {?object} metadata - Optional metadata to associate with the token + * passed to the pipeline. + * @returns {string[]} + */ +lunr.Pipeline.prototype.runString = function (str, metadata) { + var token = new lunr.Token (str, metadata) + + return this.run([token]).map(function (t) { + return t.toString() + }) +} + +/** + * Resets the pipeline by removing any existing processors. + * + */ +lunr.Pipeline.prototype.reset = function () { + this._stack = [] +} + +/** + * Returns a representation of the pipeline ready for serialisation. + * + * Logs a warning if the function has not been registered. + * + * @returns {Array} + */ +lunr.Pipeline.prototype.toJSON = function () { + return this._stack.map(function (fn) { + lunr.Pipeline.warnIfFunctionNotRegistered(fn) + + return fn.label + }) +} +/*! + * lunr.Vector + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * A vector is used to construct the vector space of documents and queries. These + * vectors support operations to determine the similarity between two documents or + * a document and a query. + * + * Normally no parameters are required for initializing a vector, but in the case of + * loading a previously dumped vector the raw elements can be provided to the constructor. + * + * For performance reasons vectors are implemented with a flat array, where an elements + * index is immediately followed by its value. E.g. [index, value, index, value]. This + * allows the underlying array to be as sparse as possible and still offer decent + * performance when being used for vector calculations. + * + * @constructor + * @param {Number[]} [elements] - The flat list of element index and element value pairs. + */ +lunr.Vector = function (elements) { + this._magnitude = 0 + this.elements = elements || [] +} + + +/** + * Calculates the position within the vector to insert a given index. + * + * This is used internally by insert and upsert. If there are duplicate indexes then + * the position is returned as if the value for that index were to be updated, but it + * is the callers responsibility to check whether there is a duplicate at that index + * + * @param {Number} insertIdx - The index at which the element should be inserted. + * @returns {Number} + */ +lunr.Vector.prototype.positionForIndex = function (index) { + // For an empty vector the tuple can be inserted at the beginning + if (this.elements.length == 0) { + return 0 + } + + var start = 0, + end = this.elements.length / 2, + sliceLength = end - start, + pivotPoint = Math.floor(sliceLength / 2), + pivotIndex = this.elements[pivotPoint * 2] + + while (sliceLength > 1) { + if (pivotIndex < index) { + start = pivotPoint + } + + if (pivotIndex > index) { + end = pivotPoint + } + + if (pivotIndex == index) { + break + } + + sliceLength = end - start + pivotPoint = start + Math.floor(sliceLength / 2) + pivotIndex = this.elements[pivotPoint * 2] + } + + if (pivotIndex == index) { + return pivotPoint * 2 + } + + if (pivotIndex > index) { + return pivotPoint * 2 + } + + if (pivotIndex < index) { + return (pivotPoint + 1) * 2 + } +} + +/** + * Inserts an element at an index within the vector. + * + * Does not allow duplicates, will throw an error if there is already an entry + * for this index. + * + * @param {Number} insertIdx - The index at which the element should be inserted. + * @param {Number} val - The value to be inserted into the vector. + */ +lunr.Vector.prototype.insert = function (insertIdx, val) { + this.upsert(insertIdx, val, function () { + throw "duplicate index" + }) +} + +/** + * Inserts or updates an existing index within the vector. + * + * @param {Number} insertIdx - The index at which the element should be inserted. + * @param {Number} val - The value to be inserted into the vector. + * @param {function} fn - A function that is called for updates, the existing value and the + * requested value are passed as arguments + */ +lunr.Vector.prototype.upsert = function (insertIdx, val, fn) { + this._magnitude = 0 + var position = this.positionForIndex(insertIdx) + + if (this.elements[position] == insertIdx) { + this.elements[position + 1] = fn(this.elements[position + 1], val) + } else { + this.elements.splice(position, 0, insertIdx, val) + } +} + +/** + * Calculates the magnitude of this vector. + * + * @returns {Number} + */ +lunr.Vector.prototype.magnitude = function () { + if (this._magnitude) return this._magnitude + + var sumOfSquares = 0, + elementsLength = this.elements.length + + for (var i = 1; i < elementsLength; i += 2) { + var val = this.elements[i] + sumOfSquares += val * val + } + + return this._magnitude = Math.sqrt(sumOfSquares) +} + +/** + * Calculates the dot product of this vector and another vector. + * + * @param {lunr.Vector} otherVector - The vector to compute the dot product with. + * @returns {Number} + */ +lunr.Vector.prototype.dot = function (otherVector) { + var dotProduct = 0, + a = this.elements, b = otherVector.elements, + aLen = a.length, bLen = b.length, + aVal = 0, bVal = 0, + i = 0, j = 0 + + while (i < aLen && j < bLen) { + aVal = a[i], bVal = b[j] + if (aVal < bVal) { + i += 2 + } else if (aVal > bVal) { + j += 2 + } else if (aVal == bVal) { + dotProduct += a[i + 1] * b[j + 1] + i += 2 + j += 2 + } + } + + return dotProduct +} + +/** + * Calculates the similarity between this vector and another vector. + * + * @param {lunr.Vector} otherVector - The other vector to calculate the + * similarity with. + * @returns {Number} + */ +lunr.Vector.prototype.similarity = function (otherVector) { + return this.dot(otherVector) / this.magnitude() || 0 +} + +/** + * Converts the vector to an array of the elements within the vector. + * + * @returns {Number[]} + */ +lunr.Vector.prototype.toArray = function () { + var output = new Array (this.elements.length / 2) + + for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) { + output[j] = this.elements[i] + } + + return output +} + +/** + * A JSON serializable representation of the vector. + * + * @returns {Number[]} + */ +lunr.Vector.prototype.toJSON = function () { + return this.elements +} +/* eslint-disable */ +/*! + * lunr.stemmer + * Copyright (C) 2020 Oliver Nightingale + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + */ + +/** + * lunr.stemmer is an english language stemmer, this is a JavaScript + * implementation of the PorterStemmer taken from http://tartarus.org/~martin + * + * @static + * @implements {lunr.PipelineFunction} + * @param {lunr.Token} token - The string to stem + * @returns {lunr.Token} + * @see {@link lunr.Pipeline} + * @function + */ +lunr.stemmer = (function(){ + var step2list = { + "ational" : "ate", + "tional" : "tion", + "enci" : "ence", + "anci" : "ance", + "izer" : "ize", + "bli" : "ble", + "alli" : "al", + "entli" : "ent", + "eli" : "e", + "ousli" : "ous", + "ization" : "ize", + "ation" : "ate", + "ator" : "ate", + "alism" : "al", + "iveness" : "ive", + "fulness" : "ful", + "ousness" : "ous", + "aliti" : "al", + "iviti" : "ive", + "biliti" : "ble", + "logi" : "log" + }, + + step3list = { + "icate" : "ic", + "ative" : "", + "alize" : "al", + "iciti" : "ic", + "ical" : "ic", + "ful" : "", + "ness" : "" + }, + + c = "[^aeiou]", // consonant + v = "[aeiouy]", // vowel + C = c + "[^aeiouy]*", // consonant sequence + V = v + "[aeiou]*", // vowel sequence + + mgr0 = "^(" + C + ")?" + V + C, // [C]VC... is m>0 + meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$", // [C]VC[V] is m=1 + mgr1 = "^(" + C + ")?" + V + C + V + C, // [C]VCVC... is m>1 + s_v = "^(" + C + ")?" + v; // vowel in stem + + var re_mgr0 = new RegExp(mgr0); + var re_mgr1 = new RegExp(mgr1); + var re_meq1 = new RegExp(meq1); + var re_s_v = new RegExp(s_v); + + var re_1a = /^(.+?)(ss|i)es$/; + var re2_1a = /^(.+?)([^s])s$/; + var re_1b = /^(.+?)eed$/; + var re2_1b = /^(.+?)(ed|ing)$/; + var re_1b_2 = /.$/; + var re2_1b_2 = /(at|bl|iz)$/; + var re3_1b_2 = new RegExp("([^aeiouylsz])\\1$"); + var re4_1b_2 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + + var re_1c = /^(.+?[^aeiou])y$/; + var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + + var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + + var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + var re2_4 = /^(.+?)(s|t)(ion)$/; + + var re_5 = /^(.+?)e$/; + var re_5_1 = /ll$/; + var re3_5 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + + var porterStemmer = function porterStemmer(w) { + var stem, + suffix, + firstch, + re, + re2, + re3, + re4; + + if (w.length < 3) { return w; } + + firstch = w.substr(0,1); + if (firstch == "y") { + w = firstch.toUpperCase() + w.substr(1); + } + + // Step 1a + re = re_1a + re2 = re2_1a; + + if (re.test(w)) { w = w.replace(re,"$1$2"); } + else if (re2.test(w)) { w = w.replace(re2,"$1$2"); } + + // Step 1b + re = re_1b; + re2 = re2_1b; + if (re.test(w)) { + var fp = re.exec(w); + re = re_mgr0; + if (re.test(fp[1])) { + re = re_1b_2; + w = w.replace(re,""); + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = re_s_v; + if (re2.test(stem)) { + w = stem; + re2 = re2_1b_2; + re3 = re3_1b_2; + re4 = re4_1b_2; + if (re2.test(w)) { w = w + "e"; } + else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,""); } + else if (re4.test(w)) { w = w + "e"; } + } + } + + // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say) + re = re_1c; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + w = stem + "i"; + } + + // Step 2 + re = re_2; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = re_mgr0; + if (re.test(stem)) { + w = stem + step2list[suffix]; + } + } + + // Step 3 + re = re_3; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = re_mgr0; + if (re.test(stem)) { + w = stem + step3list[suffix]; + } + } + + // Step 4 + re = re_4; + re2 = re2_4; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = re_mgr1; + if (re.test(stem)) { + w = stem; + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = re_mgr1; + if (re2.test(stem)) { + w = stem; + } + } + + // Step 5 + re = re_5; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = re_mgr1; + re2 = re_meq1; + re3 = re3_5; + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) { + w = stem; + } + } + + re = re_5_1; + re2 = re_mgr1; + if (re.test(w) && re2.test(w)) { + re = re_1b_2; + w = w.replace(re,""); + } + + // and turn initial Y back to y + + if (firstch == "y") { + w = firstch.toLowerCase() + w.substr(1); + } + + return w; + }; + + return function (token) { + return token.update(porterStemmer); + } +})(); + +lunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer') +/*! + * lunr.stopWordFilter + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * lunr.generateStopWordFilter builds a stopWordFilter function from the provided + * list of stop words. + * + * The built in lunr.stopWordFilter is built using this generator and can be used + * to generate custom stopWordFilters for applications or non English languages. + * + * @function + * @param {Array} token The token to pass through the filter + * @returns {lunr.PipelineFunction} + * @see lunr.Pipeline + * @see lunr.stopWordFilter + */ +lunr.generateStopWordFilter = function (stopWords) { + var words = stopWords.reduce(function (memo, stopWord) { + memo[stopWord] = stopWord + return memo + }, {}) + + return function (token) { + if (token && words[token.toString()] !== token.toString()) return token + } +} + +/** + * lunr.stopWordFilter is an English language stop word list filter, any words + * contained in the list will not be passed through the filter. + * + * This is intended to be used in the Pipeline. If the token does not pass the + * filter then undefined will be returned. + * + * @function + * @implements {lunr.PipelineFunction} + * @params {lunr.Token} token - A token to check for being a stop word. + * @returns {lunr.Token} + * @see {@link lunr.Pipeline} + */ +lunr.stopWordFilter = lunr.generateStopWordFilter([ + 'a', + 'able', + 'about', + 'across', + 'after', + 'all', + 'almost', + 'also', + 'am', + 'among', + 'an', + 'and', + 'any', + 'are', + 'as', + 'at', + 'be', + 'because', + 'been', + 'but', + 'by', + 'can', + 'cannot', + 'could', + 'dear', + 'did', + 'do', + 'does', + 'either', + 'else', + 'ever', + 'every', + 'for', + 'from', + 'get', + 'got', + 'had', + 'has', + 'have', + 'he', + 'her', + 'hers', + 'him', + 'his', + 'how', + 'however', + 'i', + 'if', + 'in', + 'into', + 'is', + 'it', + 'its', + 'just', + 'least', + 'let', + 'like', + 'likely', + 'may', + 'me', + 'might', + 'most', + 'must', + 'my', + 'neither', + 'no', + 'nor', + 'not', + 'of', + 'off', + 'often', + 'on', + 'only', + 'or', + 'other', + 'our', + 'own', + 'rather', + 'said', + 'say', + 'says', + 'she', + 'should', + 'since', + 'so', + 'some', + 'than', + 'that', + 'the', + 'their', + 'them', + 'then', + 'there', + 'these', + 'they', + 'this', + 'tis', + 'to', + 'too', + 'twas', + 'us', + 'wants', + 'was', + 'we', + 'were', + 'what', + 'when', + 'where', + 'which', + 'while', + 'who', + 'whom', + 'why', + 'will', + 'with', + 'would', + 'yet', + 'you', + 'your' +]) + +lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter') +/*! + * lunr.trimmer + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * lunr.trimmer is a pipeline function for trimming non word + * characters from the beginning and end of tokens before they + * enter the index. + * + * This implementation may not work correctly for non latin + * characters and should either be removed or adapted for use + * with languages with non-latin characters. + * + * @static + * @implements {lunr.PipelineFunction} + * @param {lunr.Token} token The token to pass through the filter + * @returns {lunr.Token} + * @see lunr.Pipeline + */ +lunr.trimmer = function (token) { + return token.update(function (s) { + return s.replace(/^\W+/, '').replace(/\W+$/, '') + }) +} + +lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer') +/*! + * lunr.TokenSet + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * A token set is used to store the unique list of all tokens + * within an index. Token sets are also used to represent an + * incoming query to the index, this query token set and index + * token set are then intersected to find which tokens to look + * up in the inverted index. + * + * A token set can hold multiple tokens, as in the case of the + * index token set, or it can hold a single token as in the + * case of a simple query token set. + * + * Additionally token sets are used to perform wildcard matching. + * Leading, contained and trailing wildcards are supported, and + * from this edit distance matching can also be provided. + * + * Token sets are implemented as a minimal finite state automata, + * where both common prefixes and suffixes are shared between tokens. + * This helps to reduce the space used for storing the token set. + * + * @constructor + */ +lunr.TokenSet = function () { + this.final = false + this.edges = {} + this.id = lunr.TokenSet._nextId + lunr.TokenSet._nextId += 1 +} + +/** + * Keeps track of the next, auto increment, identifier to assign + * to a new tokenSet. + * + * TokenSets require a unique identifier to be correctly minimised. + * + * @private + */ +lunr.TokenSet._nextId = 1 + +/** + * Creates a TokenSet instance from the given sorted array of words. + * + * @param {String[]} arr - A sorted array of strings to create the set from. + * @returns {lunr.TokenSet} + * @throws Will throw an error if the input array is not sorted. + */ +lunr.TokenSet.fromArray = function (arr) { + var builder = new lunr.TokenSet.Builder + + for (var i = 0, len = arr.length; i < len; i++) { + builder.insert(arr[i]) + } + + builder.finish() + return builder.root +} + +/** + * Creates a token set from a query clause. + * + * @private + * @param {Object} clause - A single clause from lunr.Query. + * @param {string} clause.term - The query clause term. + * @param {number} [clause.editDistance] - The optional edit distance for the term. + * @returns {lunr.TokenSet} + */ +lunr.TokenSet.fromClause = function (clause) { + if ('editDistance' in clause) { + return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance) + } else { + return lunr.TokenSet.fromString(clause.term) + } +} + +/** + * Creates a token set representing a single string with a specified + * edit distance. + * + * Insertions, deletions, substitutions and transpositions are each + * treated as an edit distance of 1. + * + * Increasing the allowed edit distance will have a dramatic impact + * on the performance of both creating and intersecting these TokenSets. + * It is advised to keep the edit distance less than 3. + * + * @param {string} str - The string to create the token set from. + * @param {number} editDistance - The allowed edit distance to match. + * @returns {lunr.Vector} + */ +lunr.TokenSet.fromFuzzyString = function (str, editDistance) { + var root = new lunr.TokenSet + + var stack = [{ + node: root, + editsRemaining: editDistance, + str: str + }] + + while (stack.length) { + var frame = stack.pop() + + // no edit + if (frame.str.length > 0) { + var char = frame.str.charAt(0), + noEditNode + + if (char in frame.node.edges) { + noEditNode = frame.node.edges[char] + } else { + noEditNode = new lunr.TokenSet + frame.node.edges[char] = noEditNode + } + + if (frame.str.length == 1) { + noEditNode.final = true + } + + stack.push({ + node: noEditNode, + editsRemaining: frame.editsRemaining, + str: frame.str.slice(1) + }) + } + + if (frame.editsRemaining == 0) { + continue + } + + // insertion + if ("*" in frame.node.edges) { + var insertionNode = frame.node.edges["*"] + } else { + var insertionNode = new lunr.TokenSet + frame.node.edges["*"] = insertionNode + } + + if (frame.str.length == 0) { + insertionNode.final = true + } + + stack.push({ + node: insertionNode, + editsRemaining: frame.editsRemaining - 1, + str: frame.str + }) + + // deletion + // can only do a deletion if we have enough edits remaining + // and if there are characters left to delete in the string + if (frame.str.length > 1) { + stack.push({ + node: frame.node, + editsRemaining: frame.editsRemaining - 1, + str: frame.str.slice(1) + }) + } + + // deletion + // just removing the last character from the str + if (frame.str.length == 1) { + frame.node.final = true + } + + // substitution + // can only do a substitution if we have enough edits remaining + // and if there are characters left to substitute + if (frame.str.length >= 1) { + if ("*" in frame.node.edges) { + var substitutionNode = frame.node.edges["*"] + } else { + var substitutionNode = new lunr.TokenSet + frame.node.edges["*"] = substitutionNode + } + + if (frame.str.length == 1) { + substitutionNode.final = true + } + + stack.push({ + node: substitutionNode, + editsRemaining: frame.editsRemaining - 1, + str: frame.str.slice(1) + }) + } + + // transposition + // can only do a transposition if there are edits remaining + // and there are enough characters to transpose + if (frame.str.length > 1) { + var charA = frame.str.charAt(0), + charB = frame.str.charAt(1), + transposeNode + + if (charB in frame.node.edges) { + transposeNode = frame.node.edges[charB] + } else { + transposeNode = new lunr.TokenSet + frame.node.edges[charB] = transposeNode + } + + if (frame.str.length == 1) { + transposeNode.final = true + } + + stack.push({ + node: transposeNode, + editsRemaining: frame.editsRemaining - 1, + str: charA + frame.str.slice(2) + }) + } + } + + return root +} + +/** + * Creates a TokenSet from a string. + * + * The string may contain one or more wildcard characters (*) + * that will allow wildcard matching when intersecting with + * another TokenSet. + * + * @param {string} str - The string to create a TokenSet from. + * @returns {lunr.TokenSet} + */ +lunr.TokenSet.fromString = function (str) { + var node = new lunr.TokenSet, + root = node + + /* + * Iterates through all characters within the passed string + * appending a node for each character. + * + * When a wildcard character is found then a self + * referencing edge is introduced to continually match + * any number of any characters. + */ + for (var i = 0, len = str.length; i < len; i++) { + var char = str[i], + final = (i == len - 1) + + if (char == "*") { + node.edges[char] = node + node.final = final + + } else { + var next = new lunr.TokenSet + next.final = final + + node.edges[char] = next + node = next + } + } + + return root +} + +/** + * Converts this TokenSet into an array of strings + * contained within the TokenSet. + * + * This is not intended to be used on a TokenSet that + * contains wildcards, in these cases the results are + * undefined and are likely to cause an infinite loop. + * + * @returns {string[]} + */ +lunr.TokenSet.prototype.toArray = function () { + var words = [] + + var stack = [{ + prefix: "", + node: this + }] + + while (stack.length) { + var frame = stack.pop(), + edges = Object.keys(frame.node.edges), + len = edges.length + + if (frame.node.final) { + /* In Safari, at this point the prefix is sometimes corrupted, see: + * https://github.com/olivernn/lunr.js/issues/279 Calling any + * String.prototype method forces Safari to "cast" this string to what + * it's supposed to be, fixing the bug. */ + frame.prefix.charAt(0) + words.push(frame.prefix) + } + + for (var i = 0; i < len; i++) { + var edge = edges[i] + + stack.push({ + prefix: frame.prefix.concat(edge), + node: frame.node.edges[edge] + }) + } + } + + return words +} + +/** + * Generates a string representation of a TokenSet. + * + * This is intended to allow TokenSets to be used as keys + * in objects, largely to aid the construction and minimisation + * of a TokenSet. As such it is not designed to be a human + * friendly representation of the TokenSet. + * + * @returns {string} + */ +lunr.TokenSet.prototype.toString = function () { + // NOTE: Using Object.keys here as this.edges is very likely + // to enter 'hash-mode' with many keys being added + // + // avoiding a for-in loop here as it leads to the function + // being de-optimised (at least in V8). From some simple + // benchmarks the performance is comparable, but allowing + // V8 to optimize may mean easy performance wins in the future. + + if (this._str) { + return this._str + } + + var str = this.final ? '1' : '0', + labels = Object.keys(this.edges).sort(), + len = labels.length + + for (var i = 0; i < len; i++) { + var label = labels[i], + node = this.edges[label] + + str = str + label + node.id + } + + return str +} + +/** + * Returns a new TokenSet that is the intersection of + * this TokenSet and the passed TokenSet. + * + * This intersection will take into account any wildcards + * contained within the TokenSet. + * + * @param {lunr.TokenSet} b - An other TokenSet to intersect with. + * @returns {lunr.TokenSet} + */ +lunr.TokenSet.prototype.intersect = function (b) { + var output = new lunr.TokenSet, + frame = undefined + + var stack = [{ + qNode: b, + output: output, + node: this + }] + + while (stack.length) { + frame = stack.pop() + + // NOTE: As with the #toString method, we are using + // Object.keys and a for loop instead of a for-in loop + // as both of these objects enter 'hash' mode, causing + // the function to be de-optimised in V8 + var qEdges = Object.keys(frame.qNode.edges), + qLen = qEdges.length, + nEdges = Object.keys(frame.node.edges), + nLen = nEdges.length + + for (var q = 0; q < qLen; q++) { + var qEdge = qEdges[q] + + for (var n = 0; n < nLen; n++) { + var nEdge = nEdges[n] + + if (nEdge == qEdge || qEdge == '*') { + var node = frame.node.edges[nEdge], + qNode = frame.qNode.edges[qEdge], + final = node.final && qNode.final, + next = undefined + + if (nEdge in frame.output.edges) { + // an edge already exists for this character + // no need to create a new node, just set the finality + // bit unless this node is already final + next = frame.output.edges[nEdge] + next.final = next.final || final + + } else { + // no edge exists yet, must create one + // set the finality bit and insert it + // into the output + next = new lunr.TokenSet + next.final = final + frame.output.edges[nEdge] = next + } + + stack.push({ + qNode: qNode, + output: next, + node: node + }) + } + } + } + } + + return output +} +lunr.TokenSet.Builder = function () { + this.previousWord = "" + this.root = new lunr.TokenSet + this.uncheckedNodes = [] + this.minimizedNodes = {} +} + +lunr.TokenSet.Builder.prototype.insert = function (word) { + var node, + commonPrefix = 0 + + if (word < this.previousWord) { + throw new Error ("Out of order word insertion") + } + + for (var i = 0; i < word.length && i < this.previousWord.length; i++) { + if (word[i] != this.previousWord[i]) break + commonPrefix++ + } + + this.minimize(commonPrefix) + + if (this.uncheckedNodes.length == 0) { + node = this.root + } else { + node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child + } + + for (var i = commonPrefix; i < word.length; i++) { + var nextNode = new lunr.TokenSet, + char = word[i] + + node.edges[char] = nextNode + + this.uncheckedNodes.push({ + parent: node, + char: char, + child: nextNode + }) + + node = nextNode + } + + node.final = true + this.previousWord = word +} + +lunr.TokenSet.Builder.prototype.finish = function () { + this.minimize(0) +} + +lunr.TokenSet.Builder.prototype.minimize = function (downTo) { + for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) { + var node = this.uncheckedNodes[i], + childKey = node.child.toString() + + if (childKey in this.minimizedNodes) { + node.parent.edges[node.char] = this.minimizedNodes[childKey] + } else { + // Cache the key for this node since + // we know it can't change anymore + node.child._str = childKey + + this.minimizedNodes[childKey] = node.child + } + + this.uncheckedNodes.pop() + } +} +/*! + * lunr.Index + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * An index contains the built index of all documents and provides a query interface + * to the index. + * + * Usually instances of lunr.Index will not be created using this constructor, instead + * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be + * used to load previously built and serialized indexes. + * + * @constructor + * @param {Object} attrs - The attributes of the built search index. + * @param {Object} attrs.invertedIndex - An index of term/field to document reference. + * @param {Object} attrs.fieldVectors - Field vectors + * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens. + * @param {string[]} attrs.fields - The names of indexed document fields. + * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms. + */ +lunr.Index = function (attrs) { + this.invertedIndex = attrs.invertedIndex + this.fieldVectors = attrs.fieldVectors + this.tokenSet = attrs.tokenSet + this.fields = attrs.fields + this.pipeline = attrs.pipeline +} + +/** + * A result contains details of a document matching a search query. + * @typedef {Object} lunr.Index~Result + * @property {string} ref - The reference of the document this result represents. + * @property {number} score - A number between 0 and 1 representing how similar this document is to the query. + * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match. + */ + +/** + * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple + * query language which itself is parsed into an instance of lunr.Query. + * + * For programmatically building queries it is advised to directly use lunr.Query, the query language + * is best used for human entered text rather than program generated text. + * + * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported + * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello' + * or 'world', though those that contain both will rank higher in the results. + * + * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can + * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding + * wildcards will increase the number of documents that will be found but can also have a negative + * impact on query performance, especially with wildcards at the beginning of a term. + * + * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term + * hello in the title field will match this query. Using a field not present in the index will lead + * to an error being thrown. + * + * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term + * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported + * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2. + * Avoid large values for edit distance to improve query performance. + * + * Each term also supports a presence modifier. By default a term's presence in document is optional, however + * this can be changed to either required or prohibited. For a term's presence to be required in a document the + * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and + * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not + * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'. + * + * To escape special characters the backslash character '\' can be used, this allows searches to include + * characters that would normally be considered modifiers, e.g. `foo\~2` will search for a term "foo~2" instead + * of attempting to apply a boost of 2 to the search term "foo". + * + * @typedef {string} lunr.Index~QueryString + * @example Simple single term query + * hello + * @example Multiple term query + * hello world + * @example term scoped to a field + * title:hello + * @example term with a boost of 10 + * hello^10 + * @example term with an edit distance of 2 + * hello~2 + * @example terms with presence modifiers + * -foo +bar baz + */ + +/** + * Performs a search against the index using lunr query syntax. + * + * Results will be returned sorted by their score, the most relevant results + * will be returned first. For details on how the score is calculated, please see + * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}. + * + * For more programmatic querying use lunr.Index#query. + * + * @param {lunr.Index~QueryString} queryString - A string containing a lunr query. + * @throws {lunr.QueryParseError} If the passed query string cannot be parsed. + * @returns {lunr.Index~Result[]} + */ +lunr.Index.prototype.search = function (queryString) { + return this.query(function (query) { + var parser = new lunr.QueryParser(queryString, query) + parser.parse() + }) +} + +/** + * A query builder callback provides a query object to be used to express + * the query to perform on the index. + * + * @callback lunr.Index~queryBuilder + * @param {lunr.Query} query - The query object to build up. + * @this lunr.Query + */ + +/** + * Performs a query against the index using the yielded lunr.Query object. + * + * If performing programmatic queries against the index, this method is preferred + * over lunr.Index#search so as to avoid the additional query parsing overhead. + * + * A query object is yielded to the supplied function which should be used to + * express the query to be run against the index. + * + * Note that although this function takes a callback parameter it is _not_ an + * asynchronous operation, the callback is just yielded a query object to be + * customized. + * + * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query. + * @returns {lunr.Index~Result[]} + */ +lunr.Index.prototype.query = function (fn) { + // for each query clause + // * process terms + // * expand terms from token set + // * find matching documents and metadata + // * get document vectors + // * score documents + + var query = new lunr.Query(this.fields), + matchingFields = Object.create(null), + queryVectors = Object.create(null), + termFieldCache = Object.create(null), + requiredMatches = Object.create(null), + prohibitedMatches = Object.create(null) + + /* + * To support field level boosts a query vector is created per + * field. An empty vector is eagerly created to support negated + * queries. + */ + for (var i = 0; i < this.fields.length; i++) { + queryVectors[this.fields[i]] = new lunr.Vector + } + + fn.call(query, query) + + for (var i = 0; i < query.clauses.length; i++) { + /* + * Unless the pipeline has been disabled for this term, which is + * the case for terms with wildcards, we need to pass the clause + * term through the search pipeline. A pipeline returns an array + * of processed terms. Pipeline functions may expand the passed + * term, which means we may end up performing multiple index lookups + * for a single query term. + */ + var clause = query.clauses[i], + terms = null, + clauseMatches = lunr.Set.empty + + if (clause.usePipeline) { + terms = this.pipeline.runString(clause.term, { + fields: clause.fields + }) + } else { + terms = [clause.term] + } + + for (var m = 0; m < terms.length; m++) { + var term = terms[m] + + /* + * Each term returned from the pipeline needs to use the same query + * clause object, e.g. the same boost and or edit distance. The + * simplest way to do this is to re-use the clause object but mutate + * its term property. + */ + clause.term = term + + /* + * From the term in the clause we create a token set which will then + * be used to intersect the indexes token set to get a list of terms + * to lookup in the inverted index + */ + var termTokenSet = lunr.TokenSet.fromClause(clause), + expandedTerms = this.tokenSet.intersect(termTokenSet).toArray() + + /* + * If a term marked as required does not exist in the tokenSet it is + * impossible for the search to return any matches. We set all the field + * scoped required matches set to empty and stop examining any further + * clauses. + */ + if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) { + for (var k = 0; k < clause.fields.length; k++) { + var field = clause.fields[k] + requiredMatches[field] = lunr.Set.empty + } + + break + } + + for (var j = 0; j < expandedTerms.length; j++) { + /* + * For each term get the posting and termIndex, this is required for + * building the query vector. + */ + var expandedTerm = expandedTerms[j], + posting = this.invertedIndex[expandedTerm], + termIndex = posting._index + + for (var k = 0; k < clause.fields.length; k++) { + /* + * For each field that this query term is scoped by (by default + * all fields are in scope) we need to get all the document refs + * that have this term in that field. + * + * The posting is the entry in the invertedIndex for the matching + * term from above. + */ + var field = clause.fields[k], + fieldPosting = posting[field], + matchingDocumentRefs = Object.keys(fieldPosting), + termField = expandedTerm + "/" + field, + matchingDocumentsSet = new lunr.Set(matchingDocumentRefs) + + /* + * if the presence of this term is required ensure that the matching + * documents are added to the set of required matches for this clause. + * + */ + if (clause.presence == lunr.Query.presence.REQUIRED) { + clauseMatches = clauseMatches.union(matchingDocumentsSet) + + if (requiredMatches[field] === undefined) { + requiredMatches[field] = lunr.Set.complete + } + } + + /* + * if the presence of this term is prohibited ensure that the matching + * documents are added to the set of prohibited matches for this field, + * creating that set if it does not yet exist. + */ + if (clause.presence == lunr.Query.presence.PROHIBITED) { + if (prohibitedMatches[field] === undefined) { + prohibitedMatches[field] = lunr.Set.empty + } + + prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet) + + /* + * Prohibited matches should not be part of the query vector used for + * similarity scoring and no metadata should be extracted so we continue + * to the next field + */ + continue + } + + /* + * The query field vector is populated using the termIndex found for + * the term and a unit value with the appropriate boost applied. + * Using upsert because there could already be an entry in the vector + * for the term we are working with. In that case we just add the scores + * together. + */ + queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b }) + + /** + * If we've already seen this term, field combo then we've already collected + * the matching documents and metadata, no need to go through all that again + */ + if (termFieldCache[termField]) { + continue + } + + for (var l = 0; l < matchingDocumentRefs.length; l++) { + /* + * All metadata for this term/field/document triple + * are then extracted and collected into an instance + * of lunr.MatchData ready to be returned in the query + * results + */ + var matchingDocumentRef = matchingDocumentRefs[l], + matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field), + metadata = fieldPosting[matchingDocumentRef], + fieldMatch + + if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) { + matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata) + } else { + fieldMatch.add(expandedTerm, field, metadata) + } + + } + + termFieldCache[termField] = true + } + } + } + + /** + * If the presence was required we need to update the requiredMatches field sets. + * We do this after all fields for the term have collected their matches because + * the clause terms presence is required in _any_ of the fields not _all_ of the + * fields. + */ + if (clause.presence === lunr.Query.presence.REQUIRED) { + for (var k = 0; k < clause.fields.length; k++) { + var field = clause.fields[k] + requiredMatches[field] = requiredMatches[field].intersect(clauseMatches) + } + } + } + + /** + * Need to combine the field scoped required and prohibited + * matching documents into a global set of required and prohibited + * matches + */ + var allRequiredMatches = lunr.Set.complete, + allProhibitedMatches = lunr.Set.empty + + for (var i = 0; i < this.fields.length; i++) { + var field = this.fields[i] + + if (requiredMatches[field]) { + allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field]) + } + + if (prohibitedMatches[field]) { + allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field]) + } + } + + var matchingFieldRefs = Object.keys(matchingFields), + results = [], + matches = Object.create(null) + + /* + * If the query is negated (contains only prohibited terms) + * we need to get _all_ fieldRefs currently existing in the + * index. This is only done when we know that the query is + * entirely prohibited terms to avoid any cost of getting all + * fieldRefs unnecessarily. + * + * Additionally, blank MatchData must be created to correctly + * populate the results. + */ + if (query.isNegated()) { + matchingFieldRefs = Object.keys(this.fieldVectors) + + for (var i = 0; i < matchingFieldRefs.length; i++) { + var matchingFieldRef = matchingFieldRefs[i] + var fieldRef = lunr.FieldRef.fromString(matchingFieldRef) + matchingFields[matchingFieldRef] = new lunr.MatchData + } + } + + for (var i = 0; i < matchingFieldRefs.length; i++) { + /* + * Currently we have document fields that match the query, but we + * need to return documents. The matchData and scores are combined + * from multiple fields belonging to the same document. + * + * Scores are calculated by field, using the query vectors created + * above, and combined into a final document score using addition. + */ + var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]), + docRef = fieldRef.docRef + + if (!allRequiredMatches.contains(docRef)) { + continue + } + + if (allProhibitedMatches.contains(docRef)) { + continue + } + + var fieldVector = this.fieldVectors[fieldRef], + score = queryVectors[fieldRef.fieldName].similarity(fieldVector), + docMatch + + if ((docMatch = matches[docRef]) !== undefined) { + docMatch.score += score + docMatch.matchData.combine(matchingFields[fieldRef]) + } else { + var match = { + ref: docRef, + score: score, + matchData: matchingFields[fieldRef] + } + matches[docRef] = match + results.push(match) + } + } + + /* + * Sort the results objects by score, highest first. + */ + return results.sort(function (a, b) { + return b.score - a.score + }) +} + +/** + * Prepares the index for JSON serialization. + * + * The schema for this JSON blob will be described in a + * separate JSON schema file. + * + * @returns {Object} + */ +lunr.Index.prototype.toJSON = function () { + var invertedIndex = Object.keys(this.invertedIndex) + .sort() + .map(function (term) { + return [term, this.invertedIndex[term]] + }, this) + + var fieldVectors = Object.keys(this.fieldVectors) + .map(function (ref) { + return [ref, this.fieldVectors[ref].toJSON()] + }, this) + + return { + version: lunr.version, + fields: this.fields, + fieldVectors: fieldVectors, + invertedIndex: invertedIndex, + pipeline: this.pipeline.toJSON() + } +} + +/** + * Loads a previously serialized lunr.Index + * + * @param {Object} serializedIndex - A previously serialized lunr.Index + * @returns {lunr.Index} + */ +lunr.Index.load = function (serializedIndex) { + var attrs = {}, + fieldVectors = {}, + serializedVectors = serializedIndex.fieldVectors, + invertedIndex = Object.create(null), + serializedInvertedIndex = serializedIndex.invertedIndex, + tokenSetBuilder = new lunr.TokenSet.Builder, + pipeline = lunr.Pipeline.load(serializedIndex.pipeline) + + if (serializedIndex.version != lunr.version) { + lunr.utils.warn("Version mismatch when loading serialised index. Current version of lunr '" + lunr.version + "' does not match serialized index '" + serializedIndex.version + "'") + } + + for (var i = 0; i < serializedVectors.length; i++) { + var tuple = serializedVectors[i], + ref = tuple[0], + elements = tuple[1] + + fieldVectors[ref] = new lunr.Vector(elements) + } + + for (var i = 0; i < serializedInvertedIndex.length; i++) { + var tuple = serializedInvertedIndex[i], + term = tuple[0], + posting = tuple[1] + + tokenSetBuilder.insert(term) + invertedIndex[term] = posting + } + + tokenSetBuilder.finish() + + attrs.fields = serializedIndex.fields + + attrs.fieldVectors = fieldVectors + attrs.invertedIndex = invertedIndex + attrs.tokenSet = tokenSetBuilder.root + attrs.pipeline = pipeline + + return new lunr.Index(attrs) +} +/*! + * lunr.Builder + * Copyright (C) 2020 Oliver Nightingale + */ + +/** + * lunr.Builder performs indexing on a set of documents and + * returns instances of lunr.Index ready for querying. + * + * All configuration of the index is done via the builder, the + * fields to index, the document reference, the text processing + * pipeline and document scoring parameters are all set on the + * builder before indexing. + * + * @constructor + * @property {string} _ref - Internal reference to the document reference field. + * @property {string[]} _fields - Internal reference to the document fields to index. + * @property {object} invertedIndex - The inverted index maps terms to document fields. + * @property {object} documentTermFrequencies - Keeps track of document term frequencies. + * @property {object} documentLengths - Keeps track of the length of documents added to the index. + * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing. + * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing. + * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index. + * @property {number} documentCount - Keeps track of the total number of documents indexed. + * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75. + * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2. + * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space. + * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index. + */ +lunr.Builder = function () { + this._ref = "id" + this._fields = Object.create(null) + this._documents = Object.create(null) + this.invertedIndex = Object.create(null) + this.fieldTermFrequencies = {} + this.fieldLengths = {} + this.tokenizer = lunr.tokenizer + this.pipeline = new lunr.Pipeline + this.searchPipeline = new lunr.Pipeline + this.documentCount = 0 + this._b = 0.75 + this._k1 = 1.2 + this.termIndex = 0 + this.metadataWhitelist = [] +} + +/** + * Sets the document field used as the document reference. Every document must have this field. + * The type of this field in the document should be a string, if it is not a string it will be + * coerced into a string by calling toString. + * + * The default ref is 'id'. + * + * The ref should _not_ be changed during indexing, it should be set before any documents are + * added to the index. Changing it during indexing can lead to inconsistent results. + * + * @param {string} ref - The name of the reference field in the document. + */ +lunr.Builder.prototype.ref = function (ref) { + this._ref = ref +} + +/** + * A function that is used to extract a field from a document. + * + * Lunr expects a field to be at the top level of a document, if however the field + * is deeply nested within a document an extractor function can be used to extract + * the right field for indexing. + * + * @callback fieldExtractor + * @param {object} doc - The document being added to the index. + * @returns {?(string|object|object[])} obj - The object that will be indexed for this field. + * @example Extracting a nested field + * function (doc) { return doc.nested.field } + */ + +/** + * Adds a field to the list of document fields that will be indexed. Every document being + * indexed should have this field. Null values for this field in indexed documents will + * not cause errors but will limit the chance of that document being retrieved by searches. + * + * All fields should be added before adding documents to the index. Adding fields after + * a document has been indexed will have no effect on already indexed documents. + * + * Fields can be boosted at build time. This allows terms within that field to have more + * importance when ranking search results. Use a field boost to specify that matches within + * one field are more important than other fields. + * + * @param {string} fieldName - The name of a field to index in all documents. + * @param {object} attributes - Optional attributes associated with this field. + * @param {number} [attributes.boost=1] - Boost applied to all terms within this field. + * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document. + * @throws {RangeError} fieldName cannot contain unsupported characters '/' + */ +lunr.Builder.prototype.field = function (fieldName, attributes) { + if (/\//.test(fieldName)) { + throw new RangeError ("Field '" + fieldName + "' contains illegal character '/'") + } + + this._fields[fieldName] = attributes || {} +} + +/** + * A parameter to tune the amount of field length normalisation that is applied when + * calculating relevance scores. A value of 0 will completely disable any normalisation + * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b + * will be clamped to the range 0 - 1. + * + * @param {number} number - The value to set for this tuning parameter. + */ +lunr.Builder.prototype.b = function (number) { + if (number < 0) { + this._b = 0 + } else if (number > 1) { + this._b = 1 + } else { + this._b = number + } +} + +/** + * A parameter that controls the speed at which a rise in term frequency results in term + * frequency saturation. The default value is 1.2. Setting this to a higher value will give + * slower saturation levels, a lower value will result in quicker saturation. + * + * @param {number} number - The value to set for this tuning parameter. + */ +lunr.Builder.prototype.k1 = function (number) { + this._k1 = number +} + +/** + * Adds a document to the index. + * + * Before adding fields to the index the index should have been fully setup, with the document + * ref and all fields to index already having been specified. + * + * The document must have a field name as specified by the ref (by default this is 'id') and + * it should have all fields defined for indexing, though null or undefined values will not + * cause errors. + * + * Entire documents can be boosted at build time. Applying a boost to a document indicates that + * this document should rank higher in search results than other documents. + * + * @param {object} doc - The document to add to the index. + * @param {object} attributes - Optional attributes associated with this document. + * @param {number} [attributes.boost=1] - Boost applied to all terms within this document. + */ +lunr.Builder.prototype.add = function (doc, attributes) { + var docRef = doc[this._ref], + fields = Object.keys(this._fields) + + this._documents[docRef] = attributes || {} + this.documentCount += 1 + + for (var i = 0; i < fields.length; i++) { + var fieldName = fields[i], + extractor = this._fields[fieldName].extractor, + field = extractor ? extractor(doc) : doc[fieldName], + tokens = this.tokenizer(field, { + fields: [fieldName] + }), + terms = this.pipeline.run(tokens), + fieldRef = new lunr.FieldRef (docRef, fieldName), + fieldTerms = Object.create(null) + + this.fieldTermFrequencies[fieldRef] = fieldTerms + this.fieldLengths[fieldRef] = 0 + + // store the length of this field for this document + this.fieldLengths[fieldRef] += terms.length + + // calculate term frequencies for this field + for (var j = 0; j < terms.length; j++) { + var term = terms[j] + + if (fieldTerms[term] == undefined) { + fieldTerms[term] = 0 + } + + fieldTerms[term] += 1 + + // add to inverted index + // create an initial posting if one doesn't exist + if (this.invertedIndex[term] == undefined) { + var posting = Object.create(null) + posting["_index"] = this.termIndex + this.termIndex += 1 + + for (var k = 0; k < fields.length; k++) { + posting[fields[k]] = Object.create(null) + } + + this.invertedIndex[term] = posting + } + + // add an entry for this term/fieldName/docRef to the invertedIndex + if (this.invertedIndex[term][fieldName][docRef] == undefined) { + this.invertedIndex[term][fieldName][docRef] = Object.create(null) + } + + // store all whitelisted metadata about this token in the + // inverted index + for (var l = 0; l < this.metadataWhitelist.length; l++) { + var metadataKey = this.metadataWhitelist[l], + metadata = term.metadata[metadataKey] + + if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) { + this.invertedIndex[term][fieldName][docRef][metadataKey] = [] + } + + this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata) + } + } + + } +} + +/** + * Calculates the average document length for this index + * + * @private + */ +lunr.Builder.prototype.calculateAverageFieldLengths = function () { + + var fieldRefs = Object.keys(this.fieldLengths), + numberOfFields = fieldRefs.length, + accumulator = {}, + documentsWithField = {} + + for (var i = 0; i < numberOfFields; i++) { + var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]), + field = fieldRef.fieldName + + documentsWithField[field] || (documentsWithField[field] = 0) + documentsWithField[field] += 1 + + accumulator[field] || (accumulator[field] = 0) + accumulator[field] += this.fieldLengths[fieldRef] + } + + var fields = Object.keys(this._fields) + + for (var i = 0; i < fields.length; i++) { + var fieldName = fields[i] + accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName] + } + + this.averageFieldLength = accumulator +} + +/** + * Builds a vector space model of every document using lunr.Vector + * + * @private + */ +lunr.Builder.prototype.createFieldVectors = function () { + var fieldVectors = {}, + fieldRefs = Object.keys(this.fieldTermFrequencies), + fieldRefsLength = fieldRefs.length, + termIdfCache = Object.create(null) + + for (var i = 0; i < fieldRefsLength; i++) { + var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]), + fieldName = fieldRef.fieldName, + fieldLength = this.fieldLengths[fieldRef], + fieldVector = new lunr.Vector, + termFrequencies = this.fieldTermFrequencies[fieldRef], + terms = Object.keys(termFrequencies), + termsLength = terms.length + + + var fieldBoost = this._fields[fieldName].boost || 1, + docBoost = this._documents[fieldRef.docRef].boost || 1 + + for (var j = 0; j < termsLength; j++) { + var term = terms[j], + tf = termFrequencies[term], + termIndex = this.invertedIndex[term]._index, + idf, score, scoreWithPrecision + + if (termIdfCache[term] === undefined) { + idf = lunr.idf(this.invertedIndex[term], this.documentCount) + termIdfCache[term] = idf + } else { + idf = termIdfCache[term] + } + + score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf) + score *= fieldBoost + score *= docBoost + scoreWithPrecision = Math.round(score * 1000) / 1000 + // Converts 1.23456789 to 1.234. + // Reducing the precision so that the vectors take up less + // space when serialised. Doing it now so that they behave + // the same before and after serialisation. Also, this is + // the fastest approach to reducing a number's precision in + // JavaScript. + + fieldVector.insert(termIndex, scoreWithPrecision) + } + + fieldVectors[fieldRef] = fieldVector + } + + this.fieldVectors = fieldVectors +} + +/** + * Creates a token set of all tokens in the index using lunr.TokenSet + * + * @private + */ +lunr.Builder.prototype.createTokenSet = function () { + this.tokenSet = lunr.TokenSet.fromArray( + Object.keys(this.invertedIndex).sort() + ) +} + +/** + * Builds the index, creating an instance of lunr.Index. + * + * This completes the indexing process and should only be called + * once all documents have been added to the index. + * + * @returns {lunr.Index} + */ +lunr.Builder.prototype.build = function () { + this.calculateAverageFieldLengths() + this.createFieldVectors() + this.createTokenSet() + + return new lunr.Index({ + invertedIndex: this.invertedIndex, + fieldVectors: this.fieldVectors, + tokenSet: this.tokenSet, + fields: Object.keys(this._fields), + pipeline: this.searchPipeline + }) +} + +/** + * Applies a plugin to the index builder. + * + * A plugin is a function that is called with the index builder as its context. + * Plugins can be used to customise or extend the behaviour of the index + * in some way. A plugin is just a function, that encapsulated the custom + * behaviour that should be applied when building the index. + * + * The plugin function will be called with the index builder as its argument, additional + * arguments can also be passed when calling use. The function will be called + * with the index builder as its context. + * + * @param {Function} plugin The plugin to apply. + */ +lunr.Builder.prototype.use = function (fn) { + var args = Array.prototype.slice.call(arguments, 1) + args.unshift(this) + fn.apply(this, args) +} +/** + * Contains and collects metadata about a matching document. + * A single instance of lunr.MatchData is returned as part of every + * lunr.Index~Result. + * + * @constructor + * @param {string} term - The term this match data is associated with + * @param {string} field - The field in which the term was found + * @param {object} metadata - The metadata recorded about this term in this field + * @property {object} metadata - A cloned collection of metadata associated with this document. + * @see {@link lunr.Index~Result} + */ +lunr.MatchData = function (term, field, metadata) { + var clonedMetadata = Object.create(null), + metadataKeys = Object.keys(metadata || {}) + + // Cloning the metadata to prevent the original + // being mutated during match data combination. + // Metadata is kept in an array within the inverted + // index so cloning the data can be done with + // Array#slice + for (var i = 0; i < metadataKeys.length; i++) { + var key = metadataKeys[i] + clonedMetadata[key] = metadata[key].slice() + } + + this.metadata = Object.create(null) + + if (term !== undefined) { + this.metadata[term] = Object.create(null) + this.metadata[term][field] = clonedMetadata + } +} + +/** + * An instance of lunr.MatchData will be created for every term that matches a + * document. However only one instance is required in a lunr.Index~Result. This + * method combines metadata from another instance of lunr.MatchData with this + * objects metadata. + * + * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one. + * @see {@link lunr.Index~Result} + */ +lunr.MatchData.prototype.combine = function (otherMatchData) { + var terms = Object.keys(otherMatchData.metadata) + + for (var i = 0; i < terms.length; i++) { + var term = terms[i], + fields = Object.keys(otherMatchData.metadata[term]) + + if (this.metadata[term] == undefined) { + this.metadata[term] = Object.create(null) + } + + for (var j = 0; j < fields.length; j++) { + var field = fields[j], + keys = Object.keys(otherMatchData.metadata[term][field]) + + if (this.metadata[term][field] == undefined) { + this.metadata[term][field] = Object.create(null) + } + + for (var k = 0; k < keys.length; k++) { + var key = keys[k] + + if (this.metadata[term][field][key] == undefined) { + this.metadata[term][field][key] = otherMatchData.metadata[term][field][key] + } else { + this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key]) + } + + } + } + } +} + +/** + * Add metadata for a term/field pair to this instance of match data. + * + * @param {string} term - The term this match data is associated with + * @param {string} field - The field in which the term was found + * @param {object} metadata - The metadata recorded about this term in this field + */ +lunr.MatchData.prototype.add = function (term, field, metadata) { + if (!(term in this.metadata)) { + this.metadata[term] = Object.create(null) + this.metadata[term][field] = metadata + return + } + + if (!(field in this.metadata[term])) { + this.metadata[term][field] = metadata + return + } + + var metadataKeys = Object.keys(metadata) + + for (var i = 0; i < metadataKeys.length; i++) { + var key = metadataKeys[i] + + if (key in this.metadata[term][field]) { + this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key]) + } else { + this.metadata[term][field][key] = metadata[key] + } + } +} +/** + * A lunr.Query provides a programmatic way of defining queries to be performed + * against a {@link lunr.Index}. + * + * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method + * so the query object is pre-initialized with the right index fields. + * + * @constructor + * @property {lunr.Query~Clause[]} clauses - An array of query clauses. + * @property {string[]} allFields - An array of all available fields in a lunr.Index. + */ +lunr.Query = function (allFields) { + this.clauses = [] + this.allFields = allFields +} + +/** + * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause. + * + * This allows wildcards to be added to the beginning and end of a term without having to manually do any string + * concatenation. + * + * The wildcard constants can be bitwise combined to select both leading and trailing wildcards. + * + * @constant + * @default + * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour + * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists + * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists + * @see lunr.Query~Clause + * @see lunr.Query#clause + * @see lunr.Query#term + * @example query term with trailing wildcard + * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING }) + * @example query term with leading and trailing wildcard + * query.term('foo', { + * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING + * }) + */ + +lunr.Query.wildcard = new String ("*") +lunr.Query.wildcard.NONE = 0 +lunr.Query.wildcard.LEADING = 1 +lunr.Query.wildcard.TRAILING = 2 + +/** + * Constants for indicating what kind of presence a term must have in matching documents. + * + * @constant + * @enum {number} + * @see lunr.Query~Clause + * @see lunr.Query#clause + * @see lunr.Query#term + * @example query term with required presence + * query.term('foo', { presence: lunr.Query.presence.REQUIRED }) + */ +lunr.Query.presence = { + /** + * Term's presence in a document is optional, this is the default value. + */ + OPTIONAL: 1, + + /** + * Term's presence in a document is required, documents that do not contain + * this term will not be returned. + */ + REQUIRED: 2, + + /** + * Term's presence in a document is prohibited, documents that do contain + * this term will not be returned. + */ + PROHIBITED: 3 +} + +/** + * A single clause in a {@link lunr.Query} contains a term and details on how to + * match that term against a {@link lunr.Index}. + * + * @typedef {Object} lunr.Query~Clause + * @property {string[]} fields - The fields in an index this clause should be matched against. + * @property {number} [boost=1] - Any boost that should be applied when matching this clause. + * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be. + * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline. + * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended. + * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents. + */ + +/** + * Adds a {@link lunr.Query~Clause} to this query. + * + * Unless the clause contains the fields to be matched all fields will be matched. In addition + * a default boost of 1 is applied to the clause. + * + * @param {lunr.Query~Clause} clause - The clause to add to this query. + * @see lunr.Query~Clause + * @returns {lunr.Query} + */ +lunr.Query.prototype.clause = function (clause) { + if (!('fields' in clause)) { + clause.fields = this.allFields + } + + if (!('boost' in clause)) { + clause.boost = 1 + } + + if (!('usePipeline' in clause)) { + clause.usePipeline = true + } + + if (!('wildcard' in clause)) { + clause.wildcard = lunr.Query.wildcard.NONE + } + + if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) { + clause.term = "*" + clause.term + } + + if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) { + clause.term = "" + clause.term + "*" + } + + if (!('presence' in clause)) { + clause.presence = lunr.Query.presence.OPTIONAL + } + + this.clauses.push(clause) + + return this +} + +/** + * A negated query is one in which every clause has a presence of + * prohibited. These queries require some special processing to return + * the expected results. + * + * @returns boolean + */ +lunr.Query.prototype.isNegated = function () { + for (var i = 0; i < this.clauses.length; i++) { + if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) { + return false + } + } + + return true +} + +/** + * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause} + * to the list of clauses that make up this query. + * + * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion + * to a token or token-like string should be done before calling this method. + * + * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an + * array, each term in the array will share the same options. + * + * @param {object|object[]} term - The term(s) to add to the query. + * @param {object} [options] - Any additional properties to add to the query clause. + * @returns {lunr.Query} + * @see lunr.Query#clause + * @see lunr.Query~Clause + * @example adding a single term to a query + * query.term("foo") + * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard + * query.term("foo", { + * fields: ["title"], + * boost: 10, + * wildcard: lunr.Query.wildcard.TRAILING + * }) + * @example using lunr.tokenizer to convert a string to tokens before using them as terms + * query.term(lunr.tokenizer("foo bar")) + */ +lunr.Query.prototype.term = function (term, options) { + if (Array.isArray(term)) { + term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this) + return this + } + + var clause = options || {} + clause.term = term.toString() + + this.clause(clause) + + return this +} +lunr.QueryParseError = function (message, start, end) { + this.name = "QueryParseError" + this.message = message + this.start = start + this.end = end +} + +lunr.QueryParseError.prototype = new Error +lunr.QueryLexer = function (str) { + this.lexemes = [] + this.str = str + this.length = str.length + this.pos = 0 + this.start = 0 + this.escapeCharPositions = [] +} + +lunr.QueryLexer.prototype.run = function () { + var state = lunr.QueryLexer.lexText + + while (state) { + state = state(this) + } +} + +lunr.QueryLexer.prototype.sliceString = function () { + var subSlices = [], + sliceStart = this.start, + sliceEnd = this.pos + + for (var i = 0; i < this.escapeCharPositions.length; i++) { + sliceEnd = this.escapeCharPositions[i] + subSlices.push(this.str.slice(sliceStart, sliceEnd)) + sliceStart = sliceEnd + 1 + } + + subSlices.push(this.str.slice(sliceStart, this.pos)) + this.escapeCharPositions.length = 0 + + return subSlices.join('') +} + +lunr.QueryLexer.prototype.emit = function (type) { + this.lexemes.push({ + type: type, + str: this.sliceString(), + start: this.start, + end: this.pos + }) + + this.start = this.pos +} + +lunr.QueryLexer.prototype.escapeCharacter = function () { + this.escapeCharPositions.push(this.pos - 1) + this.pos += 1 +} + +lunr.QueryLexer.prototype.next = function () { + if (this.pos >= this.length) { + return lunr.QueryLexer.EOS + } + + var char = this.str.charAt(this.pos) + this.pos += 1 + return char +} + +lunr.QueryLexer.prototype.width = function () { + return this.pos - this.start +} + +lunr.QueryLexer.prototype.ignore = function () { + if (this.start == this.pos) { + this.pos += 1 + } + + this.start = this.pos +} + +lunr.QueryLexer.prototype.backup = function () { + this.pos -= 1 +} + +lunr.QueryLexer.prototype.acceptDigitRun = function () { + var char, charCode + + do { + char = this.next() + charCode = char.charCodeAt(0) + } while (charCode > 47 && charCode < 58) + + if (char != lunr.QueryLexer.EOS) { + this.backup() + } +} + +lunr.QueryLexer.prototype.more = function () { + return this.pos < this.length +} + +lunr.QueryLexer.EOS = 'EOS' +lunr.QueryLexer.FIELD = 'FIELD' +lunr.QueryLexer.TERM = 'TERM' +lunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE' +lunr.QueryLexer.BOOST = 'BOOST' +lunr.QueryLexer.PRESENCE = 'PRESENCE' + +lunr.QueryLexer.lexField = function (lexer) { + lexer.backup() + lexer.emit(lunr.QueryLexer.FIELD) + lexer.ignore() + return lunr.QueryLexer.lexText +} + +lunr.QueryLexer.lexTerm = function (lexer) { + if (lexer.width() > 1) { + lexer.backup() + lexer.emit(lunr.QueryLexer.TERM) + } + + lexer.ignore() + + if (lexer.more()) { + return lunr.QueryLexer.lexText + } +} + +lunr.QueryLexer.lexEditDistance = function (lexer) { + lexer.ignore() + lexer.acceptDigitRun() + lexer.emit(lunr.QueryLexer.EDIT_DISTANCE) + return lunr.QueryLexer.lexText +} + +lunr.QueryLexer.lexBoost = function (lexer) { + lexer.ignore() + lexer.acceptDigitRun() + lexer.emit(lunr.QueryLexer.BOOST) + return lunr.QueryLexer.lexText +} + +lunr.QueryLexer.lexEOS = function (lexer) { + if (lexer.width() > 0) { + lexer.emit(lunr.QueryLexer.TERM) + } +} + +// This matches the separator used when tokenising fields +// within a document. These should match otherwise it is +// not possible to search for some tokens within a document. +// +// It is possible for the user to change the separator on the +// tokenizer so it _might_ clash with any other of the special +// characters already used within the search string, e.g. :. +// +// This means that it is possible to change the separator in +// such a way that makes some words unsearchable using a search +// string. +lunr.QueryLexer.termSeparator = lunr.tokenizer.separator + +lunr.QueryLexer.lexText = function (lexer) { + while (true) { + var char = lexer.next() + + if (char == lunr.QueryLexer.EOS) { + return lunr.QueryLexer.lexEOS + } + + // Escape character is '\' + if (char.charCodeAt(0) == 92) { + lexer.escapeCharacter() + continue + } + + if (char == ":") { + return lunr.QueryLexer.lexField + } + + if (char == "~") { + lexer.backup() + if (lexer.width() > 0) { + lexer.emit(lunr.QueryLexer.TERM) + } + return lunr.QueryLexer.lexEditDistance + } + + if (char == "^") { + lexer.backup() + if (lexer.width() > 0) { + lexer.emit(lunr.QueryLexer.TERM) + } + return lunr.QueryLexer.lexBoost + } + + // "+" indicates term presence is required + // checking for length to ensure that only + // leading "+" are considered + if (char == "+" && lexer.width() === 1) { + lexer.emit(lunr.QueryLexer.PRESENCE) + return lunr.QueryLexer.lexText + } + + // "-" indicates term presence is prohibited + // checking for length to ensure that only + // leading "-" are considered + if (char == "-" && lexer.width() === 1) { + lexer.emit(lunr.QueryLexer.PRESENCE) + return lunr.QueryLexer.lexText + } + + if (char.match(lunr.QueryLexer.termSeparator)) { + return lunr.QueryLexer.lexTerm + } + } +} + +lunr.QueryParser = function (str, query) { + this.lexer = new lunr.QueryLexer (str) + this.query = query + this.currentClause = {} + this.lexemeIdx = 0 +} + +lunr.QueryParser.prototype.parse = function () { + this.lexer.run() + this.lexemes = this.lexer.lexemes + + var state = lunr.QueryParser.parseClause + + while (state) { + state = state(this) + } + + return this.query +} + +lunr.QueryParser.prototype.peekLexeme = function () { + return this.lexemes[this.lexemeIdx] +} + +lunr.QueryParser.prototype.consumeLexeme = function () { + var lexeme = this.peekLexeme() + this.lexemeIdx += 1 + return lexeme +} + +lunr.QueryParser.prototype.nextClause = function () { + var completedClause = this.currentClause + this.query.clause(completedClause) + this.currentClause = {} +} + +lunr.QueryParser.parseClause = function (parser) { + var lexeme = parser.peekLexeme() + + if (lexeme == undefined) { + return + } + + switch (lexeme.type) { + case lunr.QueryLexer.PRESENCE: + return lunr.QueryParser.parsePresence + case lunr.QueryLexer.FIELD: + return lunr.QueryParser.parseField + case lunr.QueryLexer.TERM: + return lunr.QueryParser.parseTerm + default: + var errorMessage = "expected either a field or a term, found " + lexeme.type + + if (lexeme.str.length >= 1) { + errorMessage += " with value '" + lexeme.str + "'" + } + + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } +} + +lunr.QueryParser.parsePresence = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + switch (lexeme.str) { + case "-": + parser.currentClause.presence = lunr.Query.presence.PROHIBITED + break + case "+": + parser.currentClause.presence = lunr.Query.presence.REQUIRED + break + default: + var errorMessage = "unrecognised presence operator'" + lexeme.str + "'" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + var errorMessage = "expecting term or field, found nothing" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.FIELD: + return lunr.QueryParser.parseField + case lunr.QueryLexer.TERM: + return lunr.QueryParser.parseTerm + default: + var errorMessage = "expecting term or field, found '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } +} + +lunr.QueryParser.parseField = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + if (parser.query.allFields.indexOf(lexeme.str) == -1) { + var possibleFields = parser.query.allFields.map(function (f) { return "'" + f + "'" }).join(', '), + errorMessage = "unrecognised field '" + lexeme.str + "', possible fields: " + possibleFields + + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + parser.currentClause.fields = [lexeme.str] + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + var errorMessage = "expecting term, found nothing" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + return lunr.QueryParser.parseTerm + default: + var errorMessage = "expecting term, found '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } +} + +lunr.QueryParser.parseTerm = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + parser.currentClause.term = lexeme.str.toLowerCase() + + if (lexeme.str.indexOf("*") != -1) { + parser.currentClause.usePipeline = false + } + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + parser.nextClause() + return + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + parser.nextClause() + return lunr.QueryParser.parseTerm + case lunr.QueryLexer.FIELD: + parser.nextClause() + return lunr.QueryParser.parseField + case lunr.QueryLexer.EDIT_DISTANCE: + return lunr.QueryParser.parseEditDistance + case lunr.QueryLexer.BOOST: + return lunr.QueryParser.parseBoost + case lunr.QueryLexer.PRESENCE: + parser.nextClause() + return lunr.QueryParser.parsePresence + default: + var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } +} + +lunr.QueryParser.parseEditDistance = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + var editDistance = parseInt(lexeme.str, 10) + + if (isNaN(editDistance)) { + var errorMessage = "edit distance must be numeric" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + parser.currentClause.editDistance = editDistance + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + parser.nextClause() + return + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + parser.nextClause() + return lunr.QueryParser.parseTerm + case lunr.QueryLexer.FIELD: + parser.nextClause() + return lunr.QueryParser.parseField + case lunr.QueryLexer.EDIT_DISTANCE: + return lunr.QueryParser.parseEditDistance + case lunr.QueryLexer.BOOST: + return lunr.QueryParser.parseBoost + case lunr.QueryLexer.PRESENCE: + parser.nextClause() + return lunr.QueryParser.parsePresence + default: + var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } +} + +lunr.QueryParser.parseBoost = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + var boost = parseInt(lexeme.str, 10) + + if (isNaN(boost)) { + var errorMessage = "boost must be numeric" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + parser.currentClause.boost = boost + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + parser.nextClause() + return + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + parser.nextClause() + return lunr.QueryParser.parseTerm + case lunr.QueryLexer.FIELD: + parser.nextClause() + return lunr.QueryParser.parseField + case lunr.QueryLexer.EDIT_DISTANCE: + return lunr.QueryParser.parseEditDistance + case lunr.QueryLexer.BOOST: + return lunr.QueryParser.parseBoost + case lunr.QueryLexer.PRESENCE: + parser.nextClause() + return lunr.QueryParser.parsePresence + default: + var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } +} + + /** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ + ;(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + root.lunr = factory() + } + }(this, function () { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return lunr + })) +})(); diff --git a/search/main.js b/search/main.js new file mode 100644 index 0000000..a5e469d --- /dev/null +++ b/search/main.js @@ -0,0 +1,109 @@ +function getSearchTermFromLocation() { + var sPageURL = window.location.search.substring(1); + var sURLVariables = sPageURL.split('&'); + for (var i = 0; i < sURLVariables.length; i++) { + var sParameterName = sURLVariables[i].split('='); + if (sParameterName[0] == 'q') { + return decodeURIComponent(sParameterName[1].replace(/\+/g, '%20')); + } + } +} + +function joinUrl (base, path) { + if (path.substring(0, 1) === "/") { + // path starts with `/`. Thus it is absolute. + return path; + } + if (base.substring(base.length-1) === "/") { + // base ends with `/` + return base + path; + } + return base + "/" + path; +} + +function escapeHtml (value) { + return value.replace(/&/g, '&') + .replace(/"/g, '"') + .replace(//g, '>'); +} + +function formatResult (location, title, summary) { + return ''; +} + +function displayResults (results) { + var search_results = document.getElementById("mkdocs-search-results"); + while (search_results.firstChild) { + search_results.removeChild(search_results.firstChild); + } + if (results.length > 0){ + for (var i=0; i < results.length; i++){ + var result = results[i]; + var html = formatResult(result.location, result.title, result.summary); + search_results.insertAdjacentHTML('beforeend', html); + } + } else { + var noResultsText = search_results.getAttribute('data-no-results-text'); + if (!noResultsText) { + noResultsText = "No results found"; + } + search_results.insertAdjacentHTML('beforeend', '

' + noResultsText + '

'); + } +} + +function doSearch () { + var query = document.getElementById('mkdocs-search-query').value; + if (query.length > min_search_length) { + if (!window.Worker) { + displayResults(search(query)); + } else { + searchWorker.postMessage({query: query}); + } + } else { + // Clear results for short queries + displayResults([]); + } +} + +function initSearch () { + var search_input = document.getElementById('mkdocs-search-query'); + if (search_input) { + search_input.addEventListener("keyup", doSearch); + } + var term = getSearchTermFromLocation(); + if (term) { + search_input.value = term; + doSearch(); + } +} + +function onWorkerMessage (e) { + if (e.data.allowSearch) { + initSearch(); + } else if (e.data.results) { + var results = e.data.results; + displayResults(results); + } else if (e.data.config) { + min_search_length = e.data.config.min_search_length-1; + } +} + +if (!window.Worker) { + console.log('Web Worker API not supported'); + // load index in main thread + $.getScript(joinUrl(base_url, "search/worker.js")).done(function () { + console.log('Loaded worker'); + init(); + window.postMessage = function (msg) { + onWorkerMessage({data: msg}); + }; + }).fail(function (jqxhr, settings, exception) { + console.error('Could not load worker.js'); + }); +} else { + // Wrap search in a web worker + var searchWorker = new Worker(joinUrl(base_url, "search/worker.js")); + searchWorker.postMessage({init: true}); + searchWorker.onmessage = onWorkerMessage; +} diff --git a/search/search_index.json b/search/search_index.json new file mode 100644 index 0000000..9847fe4 --- /dev/null +++ b/search/search_index.json @@ -0,0 +1 @@ +{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"\u670d\u52a1\u6a21\u677f\u8bf4\u660e\u6587\u6863 \u670d\u52a1\u8bf4\u660e \u672c\u6587\u4ecb\u7ecd\u57fa\u4e8eMySQL\u8f6f\u4ef6\u5305\u5feb\u901f\u6784\u5efa\u6258\u7ba1\u7248\u5355\u79df\u6237\u8ba1\u7b97\u5de2\u670d\u52a1\uff0c\u5173\u4e8e\u8ba1\u7b97\u5de2\u6258\u7ba1\u7248\u53ef\u4ee5\u53c2\u8003 \u5e2e\u52a9\u6587\u6863 \uff0c \u672c\u793a\u4f8b\u91c7\u7528ECS+SLB\u7684\u67b6\u6784\uff0c\u9ed8\u8ba4\u652f\u6301\u79c1\u7f51\u6253\u901a\u3001\u7f51\u7edc\u53d8\u914d\u4e0e\u78c1\u76d8\u6269\u5bb9\u529f\u80fd\u3002\u7528\u6237\u90e8\u7f72\u670d\u52a1\u5b9e\u4f8b\u540e\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u5185\u7f51\u8bbf\u95ee\u90e8\u7f72\u5728\u670d\u52a1\u5546\u7684MySQL\uff0c\u9664\u6b64\u4e4b\u5916\u8fd8\u914d\u7f6e\u4e86\u4e09\u79cd\u5957\u9910\uff0c\u5206\u522b\u4e3a\uff1a \u5957\u9910\u540d SLB\u89c4\u683c ECS\u89c4\u683c\u65cf vCPU\u4e0e\u5185\u5b58 \u7cfb\u7edf\u76d8 \u516c\u7f51\u5e26\u5bbd \u4f4e\u914d\u7248 slb.s1.small ecs.c6.large \u5185\u5b58\u578bc6\uff0c2vCPU 4GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u57fa\u7840\u7248 slb.s1.small ecs.c6.xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u9ad8\u914d\u7248 slb.s3.small ecs.c6.2xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u672c\u793a\u4f8b\u5bf9\u5e94\u7684Git\u4ed3\u5e93\u5730\u5740\uff1a mysql-managed-demo \u672c\u793a\u4f8b\u4f1a\u81ea\u52a8\u7684\u6784\u5efa\u8ba1\u7b97\u5de2\u670d\u52a1\uff0c\u5177\u4f53\u7684\u670d\u52a1\u6784\u5efa\u6d41\u7a0b\u4e3a: \u5c06MySQL\u5b89\u88c5\u5305\uff08\u63d0\u524d\u5b58\u653e\u5230\u8be5github repo\u4e2d\uff09\u6784\u5efa\u4e3a\u8ba1\u7b97\u5de2\u6587\u4ef6\u90e8\u7f72\u7269 \u521b\u5efa\u8ba1\u7b97\u5de2\u670d\u52a1\u5e76\u5173\u8054\u6587\u4ef6\u90e8\u7f72\u7269 \u521b\u5efa\u8fc7\u7a0b\u5927\u7ea6\u6301\u7eed3\u5206\u949f\uff0c\u5f53\u670d\u52a1\u53d8\u6210\u5f85\u63d0\u4ea4\u540e\u6784\u5efa\u6210\u529f\u3002 \u90e8\u7f72\u67b6\u6784 \u672c\u90e8\u7f72\u67b6\u6784\u4e3aSLB+ECS\uff0c\u5b89\u5168\u7ec4\u5f00\u653e3306\u7aef\u53e3\uff0c\u5e76\u914d\u7f6e\u4e86\u7ec8\u7aef\u8282\u70b9\u3002 \u670d\u52a1\u6784\u5efa\u8ba1\u8d39\u8bf4\u660e \u6d4b\u8bd5\u672c\u670d\u52a1\u6784\u5efa\u65e0\u9700\u4efb\u4f55\u8d39\u7528\uff0c\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u6d89\u53ca\u7684\u8d39\u7528\u53c2\u8003\u670d\u52a1\u5b9e\u4f8b\u8ba1\u8d39\u8bf4\u660e\u3002 RAM\u8d26\u53f7\u6240\u9700\u6743\u9650 \u672c\u670d\u52a1\u9700\u8981\u5bf9ECS\u3001VPC\u7b49\u8d44\u6e90\u8fdb\u884c\u8bbf\u95ee\u548c\u521b\u5efa\u64cd\u4f5c\uff0c\u82e5\u60a8\u4f7f\u7528RAM\u7528\u6237\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\uff0c\u9700\u8981\u5728\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u524d\uff0c\u5bf9\u4f7f\u7528\u7684RAM\u7528\u6237\u7684\u8d26\u53f7\u6dfb\u52a0\u76f8\u5e94\u8d44\u6e90\u7684\u6743\u9650\u3002\u6dfb\u52a0RAM\u6743\u9650\u7684\u8be6\u7ec6\u64cd\u4f5c\uff0c\u8bf7\u53c2\u89c1 \u4e3aRAM\u7528\u6237\u6388\u6743 \u3002\u6240\u9700\u6743\u9650\u5982\u4e0b\u8868\u6240\u793a\u3002 \u6743\u9650\u7b56\u7565\u540d\u79f0 \u5907\u6ce8 AliyunECSFullAccess \u7ba1\u7406\u4e91\u670d\u52a1\u5668\u670d\u52a1\uff08ECS\uff09\u7684\u6743\u9650 AliyunVPCFullAccess \u7ba1\u7406\u4e13\u6709\u7f51\u7edc\uff08VPC\uff09\u7684\u6743\u9650 AliyunROSFullAccess \u7ba1\u7406\u8d44\u6e90\u7f16\u6392\u670d\u52a1\uff08ROS\uff09\u7684\u6743\u9650 AliyunComputeNestUserFullAccess \u7ba1\u7406\u8ba1\u7b97\u5de2\u670d\u52a1\uff08ComputeNest\uff09\u7684\u7528\u6237\u4fa7\u6743\u9650 AliyunComputeNestSupplierFullAccess \u7ba1\u7406\u8ba1\u7b97\u5de2\u670d\u52a1\uff08ComputeNest\uff09\u7684\u670d\u52a1\u5546\u4fa7\u6743\u9650 AliyunPrivateLinkFullAccess \u7ba1\u7406\u79c1\u7f51\u8fde\u63a5\uff08PrivateLink\uff09\u7684\u6743\u9650 \u670d\u52a1\u5b9e\u4f8b\u8ba1\u8d39\u8bf4\u660e \u6d4b\u8bd5\u672c\u670d\u52a1\u5728\u8ba1\u7b97\u5de2\u4e0a\u7684\u8d39\u7528\u4e3b\u8981\u6d89\u53ca\uff1a \u6240\u9009vCPU\u4e0e\u5185\u5b58\u89c4\u683c \u7cfb\u7edf\u76d8\u7c7b\u578b\u53ca\u5bb9\u91cf \u516c\u7f51\u5e26\u5bbd \u79c1\u7f51\u8fde\u63a5\u8d39\u7528 \u8ba1\u8d39\u65b9\u5f0f\u5305\u62ec\uff1a \u6309\u91cf\u4ed8\u8d39\uff08\u5c0f\u65f6\uff09 \u5305\u5e74\u5305\u6708 \u76ee\u524d\u63d0\u4f9b\u5982\u4e0b\u5957\u9910\uff1a \u5957\u9910\u540d SLB\u89c4\u683c ECS\u89c4\u683c\u65cf vCPU\u4e0e\u5185\u5b58 \u7cfb\u7edf\u76d8 \u516c\u7f51\u5e26\u5bbd \u4f4e\u914d\u7248 slb.s1.small ecs.c6.large \u5185\u5b58\u578bc6\uff0c2vCPU 4GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u57fa\u7840\u7248 slb.s1.small ecs.c6.xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u9ad8\u914d\u7248 slb.s3.small ecs.c6.2xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u9884\u4f30\u8d39\u7528\u5728\u521b\u5efa\u5b9e\u4f8b\u65f6\u53ef\u5b9e\u65f6\u770b\u5230\u3002\u79c1\u7f51\u8fde\u63a5\u53ea\u6709\u5728\u521b\u5efa\u670d\u52a1\u65f6\u5019\u5e76\u5efa\u7acb\u8fde\u63a5\u540e\u624d\u4f1a\u8ba1\u8d39\uff0c\u5177\u4f53\u7684\u8ba1\u8d39\u65b9\u5f0f\u53ef\u4ee5\u53c2\u8003\uff1ahttps://help.aliyun.com/document_detail/198081.html?spm=a2c4g.120462.0.0.5f104bffA7i9WJ \u90e8\u7f72\u6d41\u7a0b \u90e8\u7f72\u53c2\u6570\u8bf4\u660e \u53c2\u6570\u65cf \u53c2\u6570\u9879 \u8bf4\u660e \u57fa\u7840\u914d\u7f6e \u6570\u636e\u5e93root\u548cadmin\u8d26\u6237\u5bc6\u7801 \u6570\u636e\u5e93root\u548cadmin\u8d26\u6237\u5bc6\u7801\uff0c\u957f\u5ea68-32\u4e2a\u5b57\u7b26\uff0c\u53ef\u5305\u542b\u5927\u5c0f\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7279\u6b8a\u7b26\u53f7\uff08\u5305\u542b\uff1a!@#$%^&*-+=_\uff09\u3002 \u7f51\u7edc\u914d\u7f6e \u53ef\u7528\u533a \u9009\u62e9\u53ef\u7528\u533a\uff0c\u8d44\u6e90\u5c06\u5728\u670d\u52a1\u5546\u7684\u8be5\u53ef\u7528\u533a\u521b\u5efa\u3002 \u7f51\u7edc\u8bbe\u7f6e \u4e13\u6709\u7f51\u7edc \u9009\u62e9\u5efa\u7acb\u79c1\u7f51\u8fde\u63a5\u7684VPC\u3002 \u7f51\u7edc\u8bbe\u7f6e \u5b89\u5168\u7ec4 \u9009\u62e9\u5efa\u7acb\u79c1\u7f51\u8fde\u63a5\u7684\u5b89\u5168\u7ec4\u3002 \u7f51\u7edc\u8bbe\u7f6e \u4ea4\u6362\u673a\u548c\u53ef\u7528\u533a \u9009\u62e9\u5efa\u7acb\u79c1\u7f51\u8fde\u63a5\u7684\u53ef\u7528\u533a\u4e0e\u4ea4\u6362\u673a\u3002 \u90e8\u7f72\u6b65\u9aa4 \u90e8\u7f72\u94fe\u63a5 \u5355\u51fb\u90e8\u7f72\u94fe\u63a5\uff0c\u8fdb\u5165\u670d\u52a1\u5b9e\u4f8b\u90e8\u7f72\u754c\u9762\uff0c\u6839\u636e\u754c\u9762\u63d0\u793a\uff0c\u586b\u5199\u53c2\u6570\u5b8c\u6210\u90e8\u7f72\u3002 \u7f51\u7edc\u8bbe\u7f6e\u90e8\u5206\u5982\u679c\u586b\u5199\u7f51\u7edc\u4fe1\u606f\uff0c\u79c1\u7f51\u8fde\u63a5\u7684\u7ec8\u7aef\u8282\u70b9\u5c06\u5728\u8be5\u53ef\u7528\u533a\u521b\u5efa\u3002 \u6ce8\uff1a\u7531\u4e8e\u672c\u670d\u52a1\u5f00\u542f\u4e86\u7f51\u7edc\u53d8\u914d\u529f\u80fd\uff0c\u82e5\u6b64\u5904\u4e0d\u5f00\u542f\u79c1\u7f51\u8fde\u63a5\uff0c\u4e5f\u53ef\u901a\u8fc7\u53d8\u914d\u529f\u80fd\u5f00\u542f\u3002\u8be6\u60c5\u89c1\u53d8\u914d\u6d41\u7a0b-\u53d8\u914d\u79c1\u7f51\u8fde\u63a5\u3002 2. \u53c2\u6570\u586b\u5199\u5b8c\u6210\u540e\u70b9\u51fb \u4e0b\u4e00\u6b65\uff1a\u786e\u8ba4\u8ba2\u5355 \u786e\u8ba4\u53c2\u6570\u3002 3. \u786e\u8ba4\u8ba2\u5355\u5b8c\u6210\u540e\u540c\u610f\u670d\u52a1\u534f\u8bae\u5e76\u70b9\u51fb \u7acb\u5373\u521b\u5efa \uff0c\u968f\u540e\u8fdb\u5165\u90e8\u7f72\u9636\u6bb5\u3002 4. \u7b49\u5f85\u90e8\u7f72\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u670d\u52a1\u3002 5. \u4f7f\u7528\u670d\u52a1 1. \u672c\u670d\u52a1\u652f\u6301\u79c1\u7f51\u8bbf\u95ee\uff0c\u79df\u6237\u53ef\u4ee5\u901a\u8fc7PrivateLink\u5b9e\u73b0\u79c1\u7f51\u8bbf\u95ee\uff08 \u79c1\u7f51\u8bbf\u95ee\u5e2e\u52a9\u6587\u6863 \uff09\uff0c \u79df\u6237\u79c1\u7f51\u8bbf\u95ee\u6d41\u7a0b\uff1a 1. \u5728\u670d\u52a1\u5b9e\u4f8b\u7684\u865a\u62df\u4e92\u8054\u7f51\u9875\u7b7e\u4e2d\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\uff0c\u8fde\u63a5\u65f6\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u57df\u540d\uff08\u5982\u679c\u5728\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u65f6\u52fe\u9009\u4e86\u7684\u8bdd\uff09\u3001IP\u5730\u5740\u6216\u8005\u53ef\u7528\u533a\u57df\u540d\u8fdb\u884c\u8bbf\u95ee\u3002 2. \u5728\u5bf9\u5e94\u7684vsw\u4e2d\u521b\u5efaECS\uff0c\u521b\u5efa\u597d\u540e\u5b89\u88c5mysql\u5ba2\u6237\u7aef\u3002 yum install mysql or apt install mysql-client 3. \u5728\u8be5ECS\u4e2d\u8fde\u63a5MySQL\uff0c\u4e0b\u9762\u5c55\u793a\u5206\u522b\u7528\u81ea\u5b9a\u4e49\u57df\u540d\u3001IP\u4e0e\u53ef\u7528\u533a\u57df\u540d\u8fdb\u884c\u8fde\u63a5\uff1a 1. \u81ea\u5b9a\u4e49\u57df\u540d\u65b9\u5f0f\u8bbf\u95ee\uff1a ![\u81ea\u5b9a\u4e49\u57df\u540d\u8bbf\u95ee.png](\u81ea\u5b9a\u4e49\u57df\u540d\u8bbf\u95ee.png) 2. \u901a\u8fc7IP\u8bbf\u95ee\uff1a ![\u901a\u8fc7ip\u8bbf\u95ee.png](\u901a\u8fc7ip\u8bbf\u95ee.png) 3. \u901a\u8fc7\u53ef\u7528\u533a\u57df\u540d\u8bbf\u95ee\uff1a ![\u901a\u8fc7\u53ef\u7528\u533a\u57df\u540d\u8bbf\u95ee.png](\u901a\u8fc7\u53ef\u7528\u533a\u57df\u540d\u8bbf\u95ee.png) \u672c\u670d\u52a1\u652f\u6301\u4fee\u6539\u670d\u52a1\u914d\u7f6e\u53c2\u6570\u3002 \u8bf7\u6ce8\u610f\uff0c\u4fee\u6539\u53c2\u6570\u4f1a\u5f15\u8d77\u670d\u52a1\u91cd\u542f \u3002\u4fee\u6539\u670d\u52a1\u53c2\u6570\u7684\u6d41\u7a0b\uff1a \u8fdb\u5165\u670d\u52a1\u5b9e\u4f8b\u8be6\u60c5\uff1a \u70b9\u51fb \u4fee\u6539\u53c2\u6570 \uff0c\u7f16\u8f91\u4fee\u6539\u503c\uff0c\u5b8c\u6210\u540e\u70b9\u51fb \u4fdd\u5b58 \u3002 \u70b9\u51fb\u4fdd\u5b58\u540e\uff0c\u670d\u52a1\u5b9e\u4f8b\u4f1a\u8fdb\u5165\u53c2\u6570\u66f4\u65b0\u6d41\u7a0b\uff0c\u5927\u81f4\u9700\u89811~2\u5206\u949f\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u3002 \u53c2\u6570\u66f4\u65b0\u6d41\u7a0b\u5b8c\u6210\u540e\uff0c\u53c2\u6570\u751f\u6548\u3002 \u53d8\u914d\u6d41\u7a0b \u8bf4\u660e \u672c\u670d\u52a1\u9ed8\u8ba4\u5f00\u542f\u652f\u6301\u53d8\u914d\u79c1\u7f51\u8fde\u63a5\u3001\u652f\u6301\u6570\u636e\u76d8\u6269\u5bb9\u3002 \u79c1\u7f51\u8fde\u63a5\u53d8\u914d\uff1a\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u53d8\u914d\u5f00\u542f/\u5173\u95ed/\u65b0\u589e/\u5220\u9664\u79c1\u7f51\u8fde\u63a5\uff1b \u6570\u636e\u76d8\u6269\u5bb9\uff1a\u7528\u6237\u53ef\u901a\u8fc7\u53d8\u914d\u6269\u5bb9\u6570\u636e\u76d8\u5bb9\u91cf\u3002 \u53d8\u914d\u79c1\u7f51\u8fde\u63a5\u6b65\u9aa4 \u524d\u63d0\u8bf4\u660e\uff1a\u672c\u53d8\u914d\u793a\u4f8b\u4e3a\u7528\u6237\u5728\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u65f6\u672a\u5f00\u542f\u79c1\u7f51\u8fde\u63a5\uff0c\u5728\u670d\u52a1\u5b9e\u4f8b\u521b\u5efa\u5b8c\u6210\u540e\u9700\u8981\u5f00\u542f\u3002 \u7528\u6237\u5df2\u6709\u670d\u52a1\u5b9e\u4f8b\u672a\u5f00\u542f\u79c1\u7f51\u8fde\u63a5\u3002 \u70b9\u51fb\u53f3\u4e0a\u89d2 \u4fee\u6539\u914d\u7f6e \u8fdb\u5165\u53d8\u914d\u670d\u52a1\u5b9e\u4f8b\u9875\u9762\uff0c\u9009\u62e9 \u7f51\u7edc\u53d8\u914d \u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u8fdb\u5165 \u8bbe\u7f6e\u4fee\u6539\u53c2\u6570 \uff0c\u6dfb\u52a0\u79c1\u7f51\u8fde\u63a5\u53c2\u6570\u3002 \u6ce8\u610f\uff1a\u8bf7\u786e\u4fdd\u586b\u5165\u7684\u5b89\u5168\u7ec4\u5165\u65b9\u5411\u5f00\u542f3306\u7aef\u53e3\uff0c\u5426\u5219\u79c1\u7f51\u8bbf\u95ee\u5c06\u65e0\u6cd5\u8fde\u63a5\u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u9884\u89c8\u53d8\u914d\u5185\u5bb9\u3002 \u70b9\u51fb \u786e\u5b9a \u5f00\u59cb\u6267\u884c\u53d8\u914d\uff0c\u7b49\u5f85\u53d8\u914d\u5b8c\u6210\u3002 \u53d8\u914d\u5b8c\u6210\uff0c\u670d\u52a1\u5b9e\u4f8b\u72b6\u6001\u53d8\u4e3a\u5df2\u90e8\u7f72\uff0c\u8fdb\u5165\u7f51\u7edc\u914d\u7f6e\u53ef\u89c1\u65b0\u589e\u7684\u79c1\u7f51\u8fde\u63a5\u4fe1\u606f\u3002\u4e4b\u540e\u4fbf\u53ef\u901a\u8fc7 \u90e8\u7f72\u6d41\u7a0b \u6b65\u9aa45\u6240\u8ff0\u5b8c\u6210\u8fde\u63a5\u3002 \u540e\u7eed\u82e5\u9700\u8981\u5173\u95ed/\u65b0\u589e/\u5220\u9664\u79c1\u7f51\u8bbf\u95ee\u7b49\u5176\u4ed6\u64cd\u4f5c\uff0c\u540c\u6837\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u914d\u7f6e-\u7f51\u7edc\u53d8\u914d\u5b8c\u6210\u3002 \u78c1\u76d8\u5bb9\u91cf\u6269\u5bb9\u6b65\u9aa4 \u524d\u63d0\u8bf4\u660e \u672c\u53d8\u914d\u793a\u4f8b\u4e3a\u7528\u6237\u6269\u5bb9\u78c1\u76d8\u5bb9\u91cf\uff0c\u670d\u52a1\u6a21\u677f\u4e2d\u5c06\"\u6269\u5bb9\u78c1\u76d8\u5bb9\u91cf\"\u53d8\u914d\u7c7b\u578b\u8bbe\u7f6e\u4e3a\u5347\u914d\uff0c\u5373\u4ec5\u80fd\u6269\u5bb9\uff1b \u4e3a\u4f7f\u78c1\u76d8\u53ef\u53d8\u914d\u4e0e\u811a\u672c\u53ef\u6267\u884c\uff0c\u670d\u52a1\u6a21\u677f\u4e2d\u8d44\u6e90EcsInstanceGroup\u53c2\u6570UpdatePolicy\u9700\u8bbe\u7f6e\u4e3aForAllInstances\uff0c\u8d44\u6e90RunCommand\u53c2\u6570Sync\u9700\u8bbe\u7f6e\u4e3atrue\u3002 \u4ee5\u4e0a\u53c2\u6570\u6a21\u677f\u4e2d\u5747\u5df2\u914d\u7f6e\u597d\uff0c\u6b64\u5904\u4ec5\u544a\u77e5\u3002 \u70b9\u51fb\u53f3\u4e0a\u89d2 \u4fee\u6539\u914d\u7f6e \u8fdb\u5165\u53d8\u914d\u670d\u52a1\u5b9e\u4f8b\u9875\u9762\uff0c\u9009\u62e9 \u78c1\u76d8\u5bb9\u91cf\u6269\u5bb9 \u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u8fdb\u5165 \u8bbe\u7f6e\u4fee\u6539\u53c2\u6570 \uff0c\u5c06\u539f\u6709\u78c1\u76d8\u5bb9\u91cf\u4ece200GB\u4fee\u6539\u4e3a400GB\u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u9884\u89c8\u53d8\u914d\u53c2\u6570\u3002 \u70b9\u51fb\u786e\u5b9a\u5f00\u59cb\u6267\u884c\u53d8\u914d\uff0c\u7b49\u5f85\u53d8\u914d\u5b8c\u6210\u3002 \u53d8\u914d\u5b8c\u6210\uff0c\u670d\u52a1\u5b9e\u4f8b\u72b6\u6001\u53d8\u4e3a\u5df2\u90e8\u7f72\u3002 \u67e5\u770b\u7ed3\u679c\uff1a\u8fdb\u5165\u670d\u52a1\u7aefECS \u901a\u8fc7\u547d\u4ee4 df -h \u67e5\u770b\uff0c\u78c1\u76d8\u5bb9\u91cf\u5df2\u4fee\u6539: \u53d8\u914d\u524d\uff1a \u53d8\u914d\u540e\uff1a \u670d\u52a1\u8be6\u7ec6\u8bf4\u660e \u672c\u6587\u63d0\u524d\u5c06MySQL\u793e\u533a\u7248\u5b89\u88c5\u5305\u5b58\u653e\u5230\u8be5Github Repo\u4e2d\uff0c\u6784\u5efa\u670d\u52a1\u8fc7\u7a0b\u4e2d\u4f1a\u5c06\u8be5\u5b89\u88c5\u5305\u53d1\u5e03\u4e3a\u8ba1\u7b97\u5de2\u90e8\u7f72\u7269\uff0c\u5e76\u5728ROS\u6a21\u677f\u5199\u5165\u5b89\u88c5\u6307\u4ee4\uff0cROS\u6a21\u677f\u5f15\u64ce\u5728\u6267\u884c\u65f6\u4fbf\u4f1a\u81ea\u52a8\u6267\u884c\u5b89\u88c5\u4e86\u3002 wget '{{ computenest::file::MySQL }}' -O mysql-community-release-el6-5.noarch.rpm rpm -ivh mysql-community-release-el6-5.noarch.rpm yum repolist all | grep mysql yum install mysql-community-server -y {{ computenest::file::MySQL }} \u4e3a\u5360\u4f4d\u7b26\uff0c\u4f1a\u7531\u8ba1\u7b97\u5de2\u670d\u52a1\u66ff\u6362\u6210\u6587\u4ef6\u90e8\u7f72\u7269MySQL\u7684http\u4e0b\u8f7d\u5730\u5740\u3002 \u6587\u4ef6\u8bf4\u660e \u6587\u4ef6\u8def\u5f84 \u8bf4\u660e config.yaml \u6784\u5efa\u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u670d\u52a1\u6784\u5efa\u8fc7\u7a0b\u4e2d\u4f1a\u4f7f\u7528\u8ba1\u7b97\u5de2\u547d\u4ee4\u884c\u5de5\u5177 computenest-cli \uff0ccomputenest-cli\u4f1a\u57fa\u4e8e\u8be5\u914d\u7f6e\u6587\u4ef6\u6784\u5efa\u670d\u52a1\u3002 parameters.yaml \u672c\u670d\u52a1\u4e3a\u6258\u7ba1\u7248\u5355\u79df\uff0c\u4f7f\u7528\u8be5\u6587\u4ef6\u6e32\u67d3\u670d\u52a1\u5546\u9700\u8981\u914d\u7f6e\u7684\u7f51\u7edc\u53c2\u6570\uff0c\u5305\u62ecVpcId\uff0cVSwitch\u7b49\u3002 artifact/mysql-community-release-el6-5.noarch.rpm MySQL\u793e\u533a\u7248\u5b89\u88c5\u5305\uff0c\u6784\u5efa\u8fc7\u7a0b\u4f1a\u5c06\u8be5\u5305\u53d1\u5e03\u4e3a\u8ba1\u7b97\u5de2\u90e8\u7f72\u7269\u3002 icons/service_logo.jpg \u6784\u5efa\u670d\u52a1\u9ed8\u8ba4\u7684\u56fe\u6807\u3002 templates/parameters.yaml \u672c\u670d\u52a1\u4e3a\u6258\u7ba1\u7248\u5355\u79df\u670d\u52a1\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u7528\u6237\u586b\u5199\u4e00\u90e8\u5206\u53c2\u6570\uff0c\u901a\u8fc7\u8be5\u6587\u4ef6\u6307\u5b9a\u7528\u6237\u6240\u586b\u53c2\u6570\u3002 templates/template.yaml ROS\u6a21\u677f\u6587\u4ef6\uff0cROS\u6a21\u677f\u5f15\u64ce\u6839\u636e\u8be5\u6a21\u677f\u80fd\u591f\u81ea\u52a8\u521b\u5efa\u51fa\u6240\u6709\u7684\u8d44\u6e90\u3002 templates/template.yaml\u4e3b\u8981\u7531\u4e09\u90e8\u5206\u7ec4\u6210 Parameters\u5b9a\u4e49\u9700\u8981\u7528\u6237\u586b\u5199\u7684\u53c2\u6570\uff0c\u5305\u62ec\u4ed8\u8d39\u7c7b\u578b\uff0c\u5b9e\u4f8b\u89c4\u683c\u548c\u5b9e\u4f8b\u5bc6\u7801\u53ef\u7528\u533a\u53c2\u6570\u3002 ZoneId: Type: String AssociationProperty: ALIYUN::ECS::Instance:ZoneId Label: en: VSwitch Available Zone zh-cn: \u53ef\u7528\u533a # \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801 Password: # \u67e5\u8be2\u8be5\u53c2\u6570\u65f6\u53ea\u8f93\u51fa\u661f\u53f7\uff08*\uff09 NoEcho: true Type: String Description: en: 'Database root account passwor, 8-32 characters, including uppercase and lowercase letters, numbers and special symbols (including: !@#$%^&*-+=_).' zh-cn: \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801\uff0c\u957f\u5ea68-32\u4e2a\u5b57\u7b26\uff0c\u53ef\u5305\u542b\u5927\u5c0f\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7279\u6b8a\u7b26\u53f7\uff08\u5305\u542b\uff1a!@#$%^&*-+=_\uff09\u3002 Label: en: Root Account Password zh-cn: \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801 ConstraintDescription: en: '8-32 characters, including uppercase and lowercase letters, numbers and special symbols (including: !@#$%^&*-+=_).' zh-cn: 8-32\u4e2a\u5b57\u7b26\uff0c\u53ef\u5305\u542b\u5927\u5c0f\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7279\u6b8a\u7b26\u53f7\uff08\u5305\u542b\uff1a!@#$%^&*-+=_\uff09\u3002 MinLength: '8' MaxLength: '32' AssociationProperty: ALIYUN::ECS::Instance::Password # \u4e13\u6709\u7f51\u7edcVPC\u5b9e\u4f8bID VpcId: AssociationProperty: ALIYUN::ECS::VPC::VPCId Type: String Label: en: VPC ID zh-cn: \u4e13\u6709\u7f51\u7edcVPC\u5b9e\u4f8bID # \u4ea4\u6362\u673a\u5b9e\u4f8bID VSwitchId: AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId AssociationPropertyMetadata: VpcId: ${VpcId} ZoneId: ${ZoneId} Type: String Label: en: VSwitch ID zh-cn: \u4ea4\u6362\u673a\u5b9e\u4f8bID # \u6570\u636e\u76d8\u5927\u5c0f DataDiskSize: Description: zh-cn: ECS\u5b9e\u4f8b\u6570\u636e\u76d8\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3aGiB\u3002\u53d6\u503c\u8303\u56f4\uff1a100~32768 en: 'ECS Instance disk size, range of values: 100-32768, units: GB' Default: 200 MaxValue: 32768 MinValue: 100 Label: zh-cn: \u6570\u636e\u76d8\u7a7a\u95f4 en: Data Disk Space Type: Number # Ecs\u5b9e\u4f8b\u7c7b\u578b EcsInstanceType: Type: String Label: en: Instance Type zh-cn: Ecs\u5b9e\u4f8b\u7c7b\u578b AssociationProperty: ALIYUN::ECS::Instance::InstanceType AllowedValues: - ecs.c6.large - ecs.c6.xlarge - ecs.c6.2xlarge - ecs.c6.4xlarge SlbInstanceType: Type: String Label: en: Instance Type zh-cn: Slb\u5b9e\u4f8b\u7c7b\u578b AssociationProperty: ALIYUN::Slb::LoadBalance::LoadBalancerSpec AllowedValues: - slb.s1.small - slb.s3.small Resources\u5b9a\u4e49\u9700\u8981\u5f00\u7684\u8d44\u6e90\uff0c\u5305\u62ec\u65b0\u5f00\u7684Vpc,\u3001VSwitch\u3001ECS\u3001Slb\u5b9e\u4f8b\u3001\u79c1\u7f51\u8fde\u63a5\u3002 EcsSecurityGroup: Type: 'ALIYUN::ECS::SecurityGroup' Properties: VpcId: Ref: VpcId SecurityGroupIngress: - Priority: 1 PortRange: 3306/3306 NicType: internet SourceCidrIp: 0.0.0.0/0 IpProtocol: tcp # Ecs\u5b9e\u4f8b EcsInstanceGroup: Type: ALIYUN::ECS::InstanceGroup Properties: # I/O\u4f18\u5316\u5b9e\u4f8b IoOptimized: optimized ZoneId: Ref: ZoneId DiskMappings: - Category: cloud_essd Device: /dev/xvdb Size: Ref: DataDiskSize SystemDiskSize: 40 # \u4ed8\u8d39\u65b9\u5f0f\uff1a\u6309\u91cf\u4ed8\u8d39 InstanceChargeType: PostPaid MaxAmount: 1 # \u7cfb\u7edf\u76d8\u7c7b\u578b\uff1acloud_essd SystemDiskCategory: cloud_essd # \u5b9e\u4f8b\u540d\u79f0 InstanceName: Ref: ALIYUN::StackName VpcId: Ref: VpcId SecurityGroupId: Ref: EcsSecurityGroup VSwitchId: Ref: VSwitchId # \u6307\u5b9aCentOS 7.9\u955c\u50cf\uff0c\u5982\u679c\u4fee\u6539\u955c\u50cf\uff0cUserData\u811a\u672c\u9700\u8981\u8fdb\u884c\u9002\u914d ImageId: \"centos_7_9_x64_20G_alibase_20220727.vhd\" InstanceType: Ref: EcsInstanceType # \u4e3b\u673a\u540d HostName: Ref: ALIYUN::StackName # Ecs\u767b\u5f55\u5bc6\u7801 Password: Ref: Password # \u662f\u5426\u4e3a\u5b9e\u4f8b\u5206\u914d\u516c\u7f51IP AllocatePublicIP: true InternetMaxBandwidthOut: 1 # ECS\u6267\u884c\u811a\u672c RunCommand: Type: ALIYUN::ECS::RunCommand Properties: CommandContent: Fn::Sub: - | #!/bin/sh FLAG_FILE=\"/root/.disk_initialized\" PARTITION=/dev/vdb1 MOUNT_POINT=/data1 initialize_disk() { # \u521d\u59cb\u5316\u6570\u636e\u76d8\uff0c\u5bf9\u6570\u636e\u76d8\u5206\u533a cat >> /root/InitDataDisk.sh << EOF #!/bin/bash echo \"p n p w \" | fdisk -u /dev/vdb EOF /bin/bash /root/InitDataDisk.sh rm -f /root/InitDataDisk.sh rm -f InitDataDisk.sh # \u5728\u65b0\u5206\u533a\u4e0a\u521b\u5efa\u6587\u4ef6\u7cfb\u7edf mkfs.ext4 /dev/vdb1 # \u521b\u5efa\u76ee\u5f55\uff0cMySQL\u5c06\u5b89\u88c5\u5728\u8be5\u76ee\u5f55\u4e0b mkdir /data1 # \u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf mount /dev/vdb1 /data1 # \u5411 /etc/fstab \u5199\u5165\u65b0\u5206\u533a\u4fe1\u606f echo /dev/vdb1 /data1 ext4 defaults,nodelalloc,noatime 0 2 >> /etc/fstab } install_mysql() { # \u5b89\u88c5\u793e\u533a\u7248MySQL cd /data1/ wget '{{ computenest::file::MySQL }}' -O mysql-community-release-el6-5.noarch.rpm rpm -ivh mysql-community-release-el6-5.noarch.rpm yum repolist all | grep mysql yum install mysql-community-server -y # \u542f\u52a8MySQL\u670d\u52a1 service mysqld start } configure_mysql() { # \u4ee5\u8d85\u7ea7\u7528\u6237\u8eab\u4efd\u767b\u5165\uff0c\u521b\u5efaadmin\u7528\u6237\uff0c\u5e76\u5141\u8bb8admin\u7528\u6237\u4ee5Password\u4e3a\u5bc6\u7801\u8fdc\u7a0b\u767b\u5f55 mysqladmin -u root password '${Password}' echo \"create database test character set utf8 collate utf8_bin;\" > ./test.sql echo \"CREATE USER 'admin'@'%' IDENTIFIED BY '${Password}';\" >> ./test.sql echo \"GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;\" >> ./test.sql mysql -u root -p'${Password}' < ./test.sql } move_mysql_data() { # \u5c06MySQL\u7684\u914d\u7f6e\u548c\u6570\u636e\u8def\u5f84\u79fb\u52a8\u5230\u6570\u636e\u76d8\u4e0a systemctl stop mysqld rsync -av /var/lib/mysql /data1 # \u4fee\u6539\u914d\u7f6e\u6587\u4ef6 sed -i 's/\\/var\\/lib/\\/data1/g' /etc/my.cnf echo -e '\\n' >> /etc/my.cnf echo '[client]' >> /etc/my.cnf echo 'port=3306' >> /etc/my.cnf echo 'socket=/data1/mysql/mysql.sock' >> /etc/my.cnf # \u91cd\u542fMySQL systemctl start mysqld } expand_partition() { # \u4f7f\u7528 growpart \u6269\u5c55\u5206\u533a echo \"Expanding partition...\" if ! growpart /dev/vdb 1; then echo \"Failed to expand partition\" exit 1 fi # \u901a\u77e5\u7cfb\u7edf\u5206\u533a\u7684\u66f4\u6539 partprobe $PARTITION # \u4f7f\u7528 e2fsck \u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf echo \"Checking filesystem...\" e2fsck -f -y $PARTITION # \u6269\u5c55\u6587\u4ef6\u7cfb\u7edf echo \"Resizing filesystem...\" resize2fs $PARTITION } if [ ! -f \"$FLAG_FILE\" ]; then # \u9996\u6b21\u521b\u5efaECS\u65f6\u6267\u884c # \u786e\u4fdd\u7f51\u7edc\u5c31\u7eea sleep 15 initialize_disk install_mysql configure_mysql move_mysql_data # \u5f53\u521d\u59cb\u5316\u5b8c\u6210\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u6807\u5fd7\u6587\u4ef6 touch \"$FLAG_FILE\" echo \"Initialization complete. Flag file created.\" # \u6267\u884c\u6210\u529f\u56de\u8c03WaitCondition\u7ed3\u675fWaitCondition\u7684\u7b49\u5f85 ${CurlCli} -d \"{\\\"Data\\\" : \\\"SUCCESS\\\", \\\"Status\\\" : \\\"SUCCESS\\\"}\" else # \u6269\u5bb9\u6570\u636e\u76d8\u65f6\u6267\u884c # \u505c\u6b62MySQL\u670d\u52a1 systemctl stop mysqld # \u68c0\u67e5\u5e76\u786e\u4fdd\u5206\u533a\u672a\u88ab\u6302\u8f7d if mountpoint -q $MOUNT_POINT; then umount $MOUNT_POINT fi expand_partition # \u91cd\u65b0\u6302\u8f7d\u5206\u533a echo \"Remounting partition...\" mount $PARTITION $MOUNT_POINT # \u542f\u52a8MySQL\u670d\u52a1 systemctl start mysqld fi # \u83b7\u53d6\u5230WaitConditionHandle\u7684\u5730\u5740\u653e\u5230 ${CurlCli}\u53d8\u91cf\u91cc - CurlCli: Fn::GetAtt: - WaitConditionHandle - CurlCli # \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801 Password: Ref: Password Type: RunShellScript Timeout: 900 Sync: true InstanceIds: - Ref: EcsInstanceGroup Slb: Type: ALIYUN::SLB::LoadBalancer Properties: LoadBalancerName: Fn::Join: - '-' - - mysql - Ref: ALIYUN::StackName VpcId: Ref: VpcId VSwitchId: Ref: VSwitchId PayType: PayOnDemand AddressType: intranet LoadBalancerSpec: Ref: SlbInstanceType SupportPrivateLink: true SlbBackendServerAttachment: DependsOn: - EcsInstanceGroup Type: ALIYUN::SLB::BackendServerAttachment Properties: BackendServerList: Fn::GetAtt: - EcsInstanceGroup - InstanceIds LoadBalancerId: Ref: Slb BackendServerWeightList: - 100 - 0 SlbListener: DependsOn: Slb Type: ALIYUN::SLB::Listener Properties: Persistence: CookieTimeout: 60 StickySession: 'on' PersistenceTimeout: 180 XForwardedFor: 'off' StickySessionType: insert ListenerPort: 3306 Bandwidth: -1 HealthCheck: HttpCode: http_2xx,http_3xx,http_4xx,http_5xx HealthCheckType: tcp UnhealthyThreshold: 3 Timeout: 5 HealthyThreshold: 3 Port: 3306 URI: / Interval: 2 LoadBalancerId: Ref: Slb BackendServerPort: 3306 Protocol: tcp VpcEndpointService: DependsOn: Slb Type: ALIYUN::PrivateLink::VpcEndpointService Properties: ServiceDescription: isv service Resource: - ZoneId: Ref: ZoneId ResourceId: Ref: Slb ResourceType: slb AutoAcceptEnabled: true Outputs\u5b9a\u4e49\u9700\u8981\u6700\u7ec8\u5728\u8ba1\u7b97\u5de2\u6982\u89c8\u9875\u4e2d\u5bf9\u7528\u6237\u5c55\u793a\u7684\u8f93\u51fa Outputs: EndpointServiceId: Description: en: EndpointService Id zh-cn: \u7ec8\u7aef\u8282\u70b9\u670d\u52a1Id Value: Fn::GetAtt: - VpcEndpointService - ServiceId Endpoint: Value: Fn::Join: - '' - - Ref: ALIYUN::StackName - .mysql.com MysqlUserName: Description: en: MySQL User Name zh-cn: MySQL\u767b\u5f55\u7528\u6237\u540d Value: admin \u670d\u52a1\u914d\u7f6e \u521b\u5efa\u4ee3\u8fd0\u7ef4\u670d\u52a1\u5b8c\u6210\u5b9e\u4f8b\u8fd0\u7ef4 \u521b\u5efa\u5305\u542b\u53d8\u914d\u529f\u80fd\u7684\u670d\u52a1 \u521b\u5efa\u5305\u542b\u670d\u52a1\u5347\u7ea7\u529f\u80fd\u7684\u670d\u52a1 \u670d\u52a1\u4ea4\u4ed8 \u81ea\u5b9a\u4e49\u670d\u52a1\u67b6\u6784\u56fe \u670d\u52a1\u6587\u6863\u4e0a\u7ebf\u6d41\u7a0b \u5c06\u670d\u52a1\u4e0a\u67b6\u4e91\u5e02\u573a\u5e76\u4e0a\u5230\u4e91\u5e02\u573a\u552e\u5356","title":"\u670d\u52a1\u6a21\u677f\u8bf4\u660e\u6587\u6863"},{"location":"#_1","text":"","title":"\u670d\u52a1\u6a21\u677f\u8bf4\u660e\u6587\u6863"},{"location":"#_2","text":"\u672c\u6587\u4ecb\u7ecd\u57fa\u4e8eMySQL\u8f6f\u4ef6\u5305\u5feb\u901f\u6784\u5efa\u6258\u7ba1\u7248\u5355\u79df\u6237\u8ba1\u7b97\u5de2\u670d\u52a1\uff0c\u5173\u4e8e\u8ba1\u7b97\u5de2\u6258\u7ba1\u7248\u53ef\u4ee5\u53c2\u8003 \u5e2e\u52a9\u6587\u6863 \uff0c \u672c\u793a\u4f8b\u91c7\u7528ECS+SLB\u7684\u67b6\u6784\uff0c\u9ed8\u8ba4\u652f\u6301\u79c1\u7f51\u6253\u901a\u3001\u7f51\u7edc\u53d8\u914d\u4e0e\u78c1\u76d8\u6269\u5bb9\u529f\u80fd\u3002\u7528\u6237\u90e8\u7f72\u670d\u52a1\u5b9e\u4f8b\u540e\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u5185\u7f51\u8bbf\u95ee\u90e8\u7f72\u5728\u670d\u52a1\u5546\u7684MySQL\uff0c\u9664\u6b64\u4e4b\u5916\u8fd8\u914d\u7f6e\u4e86\u4e09\u79cd\u5957\u9910\uff0c\u5206\u522b\u4e3a\uff1a \u5957\u9910\u540d SLB\u89c4\u683c ECS\u89c4\u683c\u65cf vCPU\u4e0e\u5185\u5b58 \u7cfb\u7edf\u76d8 \u516c\u7f51\u5e26\u5bbd \u4f4e\u914d\u7248 slb.s1.small ecs.c6.large \u5185\u5b58\u578bc6\uff0c2vCPU 4GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u57fa\u7840\u7248 slb.s1.small ecs.c6.xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u9ad8\u914d\u7248 slb.s3.small ecs.c6.2xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u672c\u793a\u4f8b\u5bf9\u5e94\u7684Git\u4ed3\u5e93\u5730\u5740\uff1a mysql-managed-demo \u672c\u793a\u4f8b\u4f1a\u81ea\u52a8\u7684\u6784\u5efa\u8ba1\u7b97\u5de2\u670d\u52a1\uff0c\u5177\u4f53\u7684\u670d\u52a1\u6784\u5efa\u6d41\u7a0b\u4e3a: \u5c06MySQL\u5b89\u88c5\u5305\uff08\u63d0\u524d\u5b58\u653e\u5230\u8be5github repo\u4e2d\uff09\u6784\u5efa\u4e3a\u8ba1\u7b97\u5de2\u6587\u4ef6\u90e8\u7f72\u7269 \u521b\u5efa\u8ba1\u7b97\u5de2\u670d\u52a1\u5e76\u5173\u8054\u6587\u4ef6\u90e8\u7f72\u7269 \u521b\u5efa\u8fc7\u7a0b\u5927\u7ea6\u6301\u7eed3\u5206\u949f\uff0c\u5f53\u670d\u52a1\u53d8\u6210\u5f85\u63d0\u4ea4\u540e\u6784\u5efa\u6210\u529f\u3002","title":"\u670d\u52a1\u8bf4\u660e"},{"location":"#_3","text":"\u672c\u90e8\u7f72\u67b6\u6784\u4e3aSLB+ECS\uff0c\u5b89\u5168\u7ec4\u5f00\u653e3306\u7aef\u53e3\uff0c\u5e76\u914d\u7f6e\u4e86\u7ec8\u7aef\u8282\u70b9\u3002","title":"\u90e8\u7f72\u67b6\u6784"},{"location":"#_4","text":"\u6d4b\u8bd5\u672c\u670d\u52a1\u6784\u5efa\u65e0\u9700\u4efb\u4f55\u8d39\u7528\uff0c\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u6d89\u53ca\u7684\u8d39\u7528\u53c2\u8003\u670d\u52a1\u5b9e\u4f8b\u8ba1\u8d39\u8bf4\u660e\u3002","title":"\u670d\u52a1\u6784\u5efa\u8ba1\u8d39\u8bf4\u660e"},{"location":"#ram","text":"\u672c\u670d\u52a1\u9700\u8981\u5bf9ECS\u3001VPC\u7b49\u8d44\u6e90\u8fdb\u884c\u8bbf\u95ee\u548c\u521b\u5efa\u64cd\u4f5c\uff0c\u82e5\u60a8\u4f7f\u7528RAM\u7528\u6237\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\uff0c\u9700\u8981\u5728\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u524d\uff0c\u5bf9\u4f7f\u7528\u7684RAM\u7528\u6237\u7684\u8d26\u53f7\u6dfb\u52a0\u76f8\u5e94\u8d44\u6e90\u7684\u6743\u9650\u3002\u6dfb\u52a0RAM\u6743\u9650\u7684\u8be6\u7ec6\u64cd\u4f5c\uff0c\u8bf7\u53c2\u89c1 \u4e3aRAM\u7528\u6237\u6388\u6743 \u3002\u6240\u9700\u6743\u9650\u5982\u4e0b\u8868\u6240\u793a\u3002 \u6743\u9650\u7b56\u7565\u540d\u79f0 \u5907\u6ce8 AliyunECSFullAccess \u7ba1\u7406\u4e91\u670d\u52a1\u5668\u670d\u52a1\uff08ECS\uff09\u7684\u6743\u9650 AliyunVPCFullAccess \u7ba1\u7406\u4e13\u6709\u7f51\u7edc\uff08VPC\uff09\u7684\u6743\u9650 AliyunROSFullAccess \u7ba1\u7406\u8d44\u6e90\u7f16\u6392\u670d\u52a1\uff08ROS\uff09\u7684\u6743\u9650 AliyunComputeNestUserFullAccess \u7ba1\u7406\u8ba1\u7b97\u5de2\u670d\u52a1\uff08ComputeNest\uff09\u7684\u7528\u6237\u4fa7\u6743\u9650 AliyunComputeNestSupplierFullAccess \u7ba1\u7406\u8ba1\u7b97\u5de2\u670d\u52a1\uff08ComputeNest\uff09\u7684\u670d\u52a1\u5546\u4fa7\u6743\u9650 AliyunPrivateLinkFullAccess \u7ba1\u7406\u79c1\u7f51\u8fde\u63a5\uff08PrivateLink\uff09\u7684\u6743\u9650","title":"RAM\u8d26\u53f7\u6240\u9700\u6743\u9650"},{"location":"#_5","text":"\u6d4b\u8bd5\u672c\u670d\u52a1\u5728\u8ba1\u7b97\u5de2\u4e0a\u7684\u8d39\u7528\u4e3b\u8981\u6d89\u53ca\uff1a \u6240\u9009vCPU\u4e0e\u5185\u5b58\u89c4\u683c \u7cfb\u7edf\u76d8\u7c7b\u578b\u53ca\u5bb9\u91cf \u516c\u7f51\u5e26\u5bbd \u79c1\u7f51\u8fde\u63a5\u8d39\u7528 \u8ba1\u8d39\u65b9\u5f0f\u5305\u62ec\uff1a \u6309\u91cf\u4ed8\u8d39\uff08\u5c0f\u65f6\uff09 \u5305\u5e74\u5305\u6708 \u76ee\u524d\u63d0\u4f9b\u5982\u4e0b\u5957\u9910\uff1a \u5957\u9910\u540d SLB\u89c4\u683c ECS\u89c4\u683c\u65cf vCPU\u4e0e\u5185\u5b58 \u7cfb\u7edf\u76d8 \u516c\u7f51\u5e26\u5bbd \u4f4e\u914d\u7248 slb.s1.small ecs.c6.large \u5185\u5b58\u578bc6\uff0c2vCPU 4GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u57fa\u7840\u7248 slb.s1.small ecs.c6.xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u9ad8\u914d\u7248 slb.s3.small ecs.c6.2xlarge \u5185\u5b58\u578bc6\uff0c4vCPU 8GiB ESSD\u4e91\u76d8 200GiB PL0 \u56fa\u5b9a\u5e26\u5bbd1Mbps \u9884\u4f30\u8d39\u7528\u5728\u521b\u5efa\u5b9e\u4f8b\u65f6\u53ef\u5b9e\u65f6\u770b\u5230\u3002\u79c1\u7f51\u8fde\u63a5\u53ea\u6709\u5728\u521b\u5efa\u670d\u52a1\u65f6\u5019\u5e76\u5efa\u7acb\u8fde\u63a5\u540e\u624d\u4f1a\u8ba1\u8d39\uff0c\u5177\u4f53\u7684\u8ba1\u8d39\u65b9\u5f0f\u53ef\u4ee5\u53c2\u8003\uff1ahttps://help.aliyun.com/document_detail/198081.html?spm=a2c4g.120462.0.0.5f104bffA7i9WJ","title":"\u670d\u52a1\u5b9e\u4f8b\u8ba1\u8d39\u8bf4\u660e"},{"location":"#_6","text":"","title":"\u90e8\u7f72\u6d41\u7a0b"},{"location":"#_7","text":"\u53c2\u6570\u65cf \u53c2\u6570\u9879 \u8bf4\u660e \u57fa\u7840\u914d\u7f6e \u6570\u636e\u5e93root\u548cadmin\u8d26\u6237\u5bc6\u7801 \u6570\u636e\u5e93root\u548cadmin\u8d26\u6237\u5bc6\u7801\uff0c\u957f\u5ea68-32\u4e2a\u5b57\u7b26\uff0c\u53ef\u5305\u542b\u5927\u5c0f\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7279\u6b8a\u7b26\u53f7\uff08\u5305\u542b\uff1a!@#$%^&*-+=_\uff09\u3002 \u7f51\u7edc\u914d\u7f6e \u53ef\u7528\u533a \u9009\u62e9\u53ef\u7528\u533a\uff0c\u8d44\u6e90\u5c06\u5728\u670d\u52a1\u5546\u7684\u8be5\u53ef\u7528\u533a\u521b\u5efa\u3002 \u7f51\u7edc\u8bbe\u7f6e \u4e13\u6709\u7f51\u7edc \u9009\u62e9\u5efa\u7acb\u79c1\u7f51\u8fde\u63a5\u7684VPC\u3002 \u7f51\u7edc\u8bbe\u7f6e \u5b89\u5168\u7ec4 \u9009\u62e9\u5efa\u7acb\u79c1\u7f51\u8fde\u63a5\u7684\u5b89\u5168\u7ec4\u3002 \u7f51\u7edc\u8bbe\u7f6e \u4ea4\u6362\u673a\u548c\u53ef\u7528\u533a \u9009\u62e9\u5efa\u7acb\u79c1\u7f51\u8fde\u63a5\u7684\u53ef\u7528\u533a\u4e0e\u4ea4\u6362\u673a\u3002","title":"\u90e8\u7f72\u53c2\u6570\u8bf4\u660e"},{"location":"#_8","text":"\u90e8\u7f72\u94fe\u63a5 \u5355\u51fb\u90e8\u7f72\u94fe\u63a5\uff0c\u8fdb\u5165\u670d\u52a1\u5b9e\u4f8b\u90e8\u7f72\u754c\u9762\uff0c\u6839\u636e\u754c\u9762\u63d0\u793a\uff0c\u586b\u5199\u53c2\u6570\u5b8c\u6210\u90e8\u7f72\u3002 \u7f51\u7edc\u8bbe\u7f6e\u90e8\u5206\u5982\u679c\u586b\u5199\u7f51\u7edc\u4fe1\u606f\uff0c\u79c1\u7f51\u8fde\u63a5\u7684\u7ec8\u7aef\u8282\u70b9\u5c06\u5728\u8be5\u53ef\u7528\u533a\u521b\u5efa\u3002 \u6ce8\uff1a\u7531\u4e8e\u672c\u670d\u52a1\u5f00\u542f\u4e86\u7f51\u7edc\u53d8\u914d\u529f\u80fd\uff0c\u82e5\u6b64\u5904\u4e0d\u5f00\u542f\u79c1\u7f51\u8fde\u63a5\uff0c\u4e5f\u53ef\u901a\u8fc7\u53d8\u914d\u529f\u80fd\u5f00\u542f\u3002\u8be6\u60c5\u89c1\u53d8\u914d\u6d41\u7a0b-\u53d8\u914d\u79c1\u7f51\u8fde\u63a5\u3002 2. \u53c2\u6570\u586b\u5199\u5b8c\u6210\u540e\u70b9\u51fb \u4e0b\u4e00\u6b65\uff1a\u786e\u8ba4\u8ba2\u5355 \u786e\u8ba4\u53c2\u6570\u3002 3. \u786e\u8ba4\u8ba2\u5355\u5b8c\u6210\u540e\u540c\u610f\u670d\u52a1\u534f\u8bae\u5e76\u70b9\u51fb \u7acb\u5373\u521b\u5efa \uff0c\u968f\u540e\u8fdb\u5165\u90e8\u7f72\u9636\u6bb5\u3002 4. \u7b49\u5f85\u90e8\u7f72\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u670d\u52a1\u3002 5. \u4f7f\u7528\u670d\u52a1 1. \u672c\u670d\u52a1\u652f\u6301\u79c1\u7f51\u8bbf\u95ee\uff0c\u79df\u6237\u53ef\u4ee5\u901a\u8fc7PrivateLink\u5b9e\u73b0\u79c1\u7f51\u8bbf\u95ee\uff08 \u79c1\u7f51\u8bbf\u95ee\u5e2e\u52a9\u6587\u6863 \uff09\uff0c \u79df\u6237\u79c1\u7f51\u8bbf\u95ee\u6d41\u7a0b\uff1a 1. \u5728\u670d\u52a1\u5b9e\u4f8b\u7684\u865a\u62df\u4e92\u8054\u7f51\u9875\u7b7e\u4e2d\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\uff0c\u8fde\u63a5\u65f6\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u57df\u540d\uff08\u5982\u679c\u5728\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u65f6\u52fe\u9009\u4e86\u7684\u8bdd\uff09\u3001IP\u5730\u5740\u6216\u8005\u53ef\u7528\u533a\u57df\u540d\u8fdb\u884c\u8bbf\u95ee\u3002 2. \u5728\u5bf9\u5e94\u7684vsw\u4e2d\u521b\u5efaECS\uff0c\u521b\u5efa\u597d\u540e\u5b89\u88c5mysql\u5ba2\u6237\u7aef\u3002 yum install mysql or apt install mysql-client 3. \u5728\u8be5ECS\u4e2d\u8fde\u63a5MySQL\uff0c\u4e0b\u9762\u5c55\u793a\u5206\u522b\u7528\u81ea\u5b9a\u4e49\u57df\u540d\u3001IP\u4e0e\u53ef\u7528\u533a\u57df\u540d\u8fdb\u884c\u8fde\u63a5\uff1a 1. \u81ea\u5b9a\u4e49\u57df\u540d\u65b9\u5f0f\u8bbf\u95ee\uff1a ![\u81ea\u5b9a\u4e49\u57df\u540d\u8bbf\u95ee.png](\u81ea\u5b9a\u4e49\u57df\u540d\u8bbf\u95ee.png) 2. \u901a\u8fc7IP\u8bbf\u95ee\uff1a ![\u901a\u8fc7ip\u8bbf\u95ee.png](\u901a\u8fc7ip\u8bbf\u95ee.png) 3. \u901a\u8fc7\u53ef\u7528\u533a\u57df\u540d\u8bbf\u95ee\uff1a ![\u901a\u8fc7\u53ef\u7528\u533a\u57df\u540d\u8bbf\u95ee.png](\u901a\u8fc7\u53ef\u7528\u533a\u57df\u540d\u8bbf\u95ee.png) \u672c\u670d\u52a1\u652f\u6301\u4fee\u6539\u670d\u52a1\u914d\u7f6e\u53c2\u6570\u3002 \u8bf7\u6ce8\u610f\uff0c\u4fee\u6539\u53c2\u6570\u4f1a\u5f15\u8d77\u670d\u52a1\u91cd\u542f \u3002\u4fee\u6539\u670d\u52a1\u53c2\u6570\u7684\u6d41\u7a0b\uff1a \u8fdb\u5165\u670d\u52a1\u5b9e\u4f8b\u8be6\u60c5\uff1a \u70b9\u51fb \u4fee\u6539\u53c2\u6570 \uff0c\u7f16\u8f91\u4fee\u6539\u503c\uff0c\u5b8c\u6210\u540e\u70b9\u51fb \u4fdd\u5b58 \u3002 \u70b9\u51fb\u4fdd\u5b58\u540e\uff0c\u670d\u52a1\u5b9e\u4f8b\u4f1a\u8fdb\u5165\u53c2\u6570\u66f4\u65b0\u6d41\u7a0b\uff0c\u5927\u81f4\u9700\u89811~2\u5206\u949f\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u3002 \u53c2\u6570\u66f4\u65b0\u6d41\u7a0b\u5b8c\u6210\u540e\uff0c\u53c2\u6570\u751f\u6548\u3002","title":"\u90e8\u7f72\u6b65\u9aa4"},{"location":"#_9","text":"","title":"\u53d8\u914d\u6d41\u7a0b"},{"location":"#_10","text":"\u672c\u670d\u52a1\u9ed8\u8ba4\u5f00\u542f\u652f\u6301\u53d8\u914d\u79c1\u7f51\u8fde\u63a5\u3001\u652f\u6301\u6570\u636e\u76d8\u6269\u5bb9\u3002 \u79c1\u7f51\u8fde\u63a5\u53d8\u914d\uff1a\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u53d8\u914d\u5f00\u542f/\u5173\u95ed/\u65b0\u589e/\u5220\u9664\u79c1\u7f51\u8fde\u63a5\uff1b \u6570\u636e\u76d8\u6269\u5bb9\uff1a\u7528\u6237\u53ef\u901a\u8fc7\u53d8\u914d\u6269\u5bb9\u6570\u636e\u76d8\u5bb9\u91cf\u3002","title":"\u8bf4\u660e"},{"location":"#_11","text":"\u524d\u63d0\u8bf4\u660e\uff1a\u672c\u53d8\u914d\u793a\u4f8b\u4e3a\u7528\u6237\u5728\u521b\u5efa\u670d\u52a1\u5b9e\u4f8b\u65f6\u672a\u5f00\u542f\u79c1\u7f51\u8fde\u63a5\uff0c\u5728\u670d\u52a1\u5b9e\u4f8b\u521b\u5efa\u5b8c\u6210\u540e\u9700\u8981\u5f00\u542f\u3002 \u7528\u6237\u5df2\u6709\u670d\u52a1\u5b9e\u4f8b\u672a\u5f00\u542f\u79c1\u7f51\u8fde\u63a5\u3002 \u70b9\u51fb\u53f3\u4e0a\u89d2 \u4fee\u6539\u914d\u7f6e \u8fdb\u5165\u53d8\u914d\u670d\u52a1\u5b9e\u4f8b\u9875\u9762\uff0c\u9009\u62e9 \u7f51\u7edc\u53d8\u914d \u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u8fdb\u5165 \u8bbe\u7f6e\u4fee\u6539\u53c2\u6570 \uff0c\u6dfb\u52a0\u79c1\u7f51\u8fde\u63a5\u53c2\u6570\u3002 \u6ce8\u610f\uff1a\u8bf7\u786e\u4fdd\u586b\u5165\u7684\u5b89\u5168\u7ec4\u5165\u65b9\u5411\u5f00\u542f3306\u7aef\u53e3\uff0c\u5426\u5219\u79c1\u7f51\u8bbf\u95ee\u5c06\u65e0\u6cd5\u8fde\u63a5\u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u9884\u89c8\u53d8\u914d\u5185\u5bb9\u3002 \u70b9\u51fb \u786e\u5b9a \u5f00\u59cb\u6267\u884c\u53d8\u914d\uff0c\u7b49\u5f85\u53d8\u914d\u5b8c\u6210\u3002 \u53d8\u914d\u5b8c\u6210\uff0c\u670d\u52a1\u5b9e\u4f8b\u72b6\u6001\u53d8\u4e3a\u5df2\u90e8\u7f72\uff0c\u8fdb\u5165\u7f51\u7edc\u914d\u7f6e\u53ef\u89c1\u65b0\u589e\u7684\u79c1\u7f51\u8fde\u63a5\u4fe1\u606f\u3002\u4e4b\u540e\u4fbf\u53ef\u901a\u8fc7 \u90e8\u7f72\u6d41\u7a0b \u6b65\u9aa45\u6240\u8ff0\u5b8c\u6210\u8fde\u63a5\u3002 \u540e\u7eed\u82e5\u9700\u8981\u5173\u95ed/\u65b0\u589e/\u5220\u9664\u79c1\u7f51\u8bbf\u95ee\u7b49\u5176\u4ed6\u64cd\u4f5c\uff0c\u540c\u6837\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u914d\u7f6e-\u7f51\u7edc\u53d8\u914d\u5b8c\u6210\u3002","title":"\u53d8\u914d\u79c1\u7f51\u8fde\u63a5\u6b65\u9aa4"},{"location":"#_12","text":"\u524d\u63d0\u8bf4\u660e \u672c\u53d8\u914d\u793a\u4f8b\u4e3a\u7528\u6237\u6269\u5bb9\u78c1\u76d8\u5bb9\u91cf\uff0c\u670d\u52a1\u6a21\u677f\u4e2d\u5c06\"\u6269\u5bb9\u78c1\u76d8\u5bb9\u91cf\"\u53d8\u914d\u7c7b\u578b\u8bbe\u7f6e\u4e3a\u5347\u914d\uff0c\u5373\u4ec5\u80fd\u6269\u5bb9\uff1b \u4e3a\u4f7f\u78c1\u76d8\u53ef\u53d8\u914d\u4e0e\u811a\u672c\u53ef\u6267\u884c\uff0c\u670d\u52a1\u6a21\u677f\u4e2d\u8d44\u6e90EcsInstanceGroup\u53c2\u6570UpdatePolicy\u9700\u8bbe\u7f6e\u4e3aForAllInstances\uff0c\u8d44\u6e90RunCommand\u53c2\u6570Sync\u9700\u8bbe\u7f6e\u4e3atrue\u3002 \u4ee5\u4e0a\u53c2\u6570\u6a21\u677f\u4e2d\u5747\u5df2\u914d\u7f6e\u597d\uff0c\u6b64\u5904\u4ec5\u544a\u77e5\u3002 \u70b9\u51fb\u53f3\u4e0a\u89d2 \u4fee\u6539\u914d\u7f6e \u8fdb\u5165\u53d8\u914d\u670d\u52a1\u5b9e\u4f8b\u9875\u9762\uff0c\u9009\u62e9 \u78c1\u76d8\u5bb9\u91cf\u6269\u5bb9 \u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u8fdb\u5165 \u8bbe\u7f6e\u4fee\u6539\u53c2\u6570 \uff0c\u5c06\u539f\u6709\u78c1\u76d8\u5bb9\u91cf\u4ece200GB\u4fee\u6539\u4e3a400GB\u3002 \u70b9\u51fb \u4e0b\u4e00\u6b65 \u9884\u89c8\u53d8\u914d\u53c2\u6570\u3002 \u70b9\u51fb\u786e\u5b9a\u5f00\u59cb\u6267\u884c\u53d8\u914d\uff0c\u7b49\u5f85\u53d8\u914d\u5b8c\u6210\u3002 \u53d8\u914d\u5b8c\u6210\uff0c\u670d\u52a1\u5b9e\u4f8b\u72b6\u6001\u53d8\u4e3a\u5df2\u90e8\u7f72\u3002 \u67e5\u770b\u7ed3\u679c\uff1a\u8fdb\u5165\u670d\u52a1\u7aefECS \u901a\u8fc7\u547d\u4ee4 df -h \u67e5\u770b\uff0c\u78c1\u76d8\u5bb9\u91cf\u5df2\u4fee\u6539: \u53d8\u914d\u524d\uff1a \u53d8\u914d\u540e\uff1a","title":"\u78c1\u76d8\u5bb9\u91cf\u6269\u5bb9\u6b65\u9aa4"},{"location":"#_13","text":"\u672c\u6587\u63d0\u524d\u5c06MySQL\u793e\u533a\u7248\u5b89\u88c5\u5305\u5b58\u653e\u5230\u8be5Github Repo\u4e2d\uff0c\u6784\u5efa\u670d\u52a1\u8fc7\u7a0b\u4e2d\u4f1a\u5c06\u8be5\u5b89\u88c5\u5305\u53d1\u5e03\u4e3a\u8ba1\u7b97\u5de2\u90e8\u7f72\u7269\uff0c\u5e76\u5728ROS\u6a21\u677f\u5199\u5165\u5b89\u88c5\u6307\u4ee4\uff0cROS\u6a21\u677f\u5f15\u64ce\u5728\u6267\u884c\u65f6\u4fbf\u4f1a\u81ea\u52a8\u6267\u884c\u5b89\u88c5\u4e86\u3002 wget '{{ computenest::file::MySQL }}' -O mysql-community-release-el6-5.noarch.rpm rpm -ivh mysql-community-release-el6-5.noarch.rpm yum repolist all | grep mysql yum install mysql-community-server -y {{ computenest::file::MySQL }} \u4e3a\u5360\u4f4d\u7b26\uff0c\u4f1a\u7531\u8ba1\u7b97\u5de2\u670d\u52a1\u66ff\u6362\u6210\u6587\u4ef6\u90e8\u7f72\u7269MySQL\u7684http\u4e0b\u8f7d\u5730\u5740\u3002 \u6587\u4ef6\u8bf4\u660e \u6587\u4ef6\u8def\u5f84 \u8bf4\u660e config.yaml \u6784\u5efa\u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u670d\u52a1\u6784\u5efa\u8fc7\u7a0b\u4e2d\u4f1a\u4f7f\u7528\u8ba1\u7b97\u5de2\u547d\u4ee4\u884c\u5de5\u5177 computenest-cli \uff0ccomputenest-cli\u4f1a\u57fa\u4e8e\u8be5\u914d\u7f6e\u6587\u4ef6\u6784\u5efa\u670d\u52a1\u3002 parameters.yaml \u672c\u670d\u52a1\u4e3a\u6258\u7ba1\u7248\u5355\u79df\uff0c\u4f7f\u7528\u8be5\u6587\u4ef6\u6e32\u67d3\u670d\u52a1\u5546\u9700\u8981\u914d\u7f6e\u7684\u7f51\u7edc\u53c2\u6570\uff0c\u5305\u62ecVpcId\uff0cVSwitch\u7b49\u3002 artifact/mysql-community-release-el6-5.noarch.rpm MySQL\u793e\u533a\u7248\u5b89\u88c5\u5305\uff0c\u6784\u5efa\u8fc7\u7a0b\u4f1a\u5c06\u8be5\u5305\u53d1\u5e03\u4e3a\u8ba1\u7b97\u5de2\u90e8\u7f72\u7269\u3002 icons/service_logo.jpg \u6784\u5efa\u670d\u52a1\u9ed8\u8ba4\u7684\u56fe\u6807\u3002 templates/parameters.yaml \u672c\u670d\u52a1\u4e3a\u6258\u7ba1\u7248\u5355\u79df\u670d\u52a1\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u7528\u6237\u586b\u5199\u4e00\u90e8\u5206\u53c2\u6570\uff0c\u901a\u8fc7\u8be5\u6587\u4ef6\u6307\u5b9a\u7528\u6237\u6240\u586b\u53c2\u6570\u3002 templates/template.yaml ROS\u6a21\u677f\u6587\u4ef6\uff0cROS\u6a21\u677f\u5f15\u64ce\u6839\u636e\u8be5\u6a21\u677f\u80fd\u591f\u81ea\u52a8\u521b\u5efa\u51fa\u6240\u6709\u7684\u8d44\u6e90\u3002 templates/template.yaml\u4e3b\u8981\u7531\u4e09\u90e8\u5206\u7ec4\u6210 Parameters\u5b9a\u4e49\u9700\u8981\u7528\u6237\u586b\u5199\u7684\u53c2\u6570\uff0c\u5305\u62ec\u4ed8\u8d39\u7c7b\u578b\uff0c\u5b9e\u4f8b\u89c4\u683c\u548c\u5b9e\u4f8b\u5bc6\u7801\u53ef\u7528\u533a\u53c2\u6570\u3002 ZoneId: Type: String AssociationProperty: ALIYUN::ECS::Instance:ZoneId Label: en: VSwitch Available Zone zh-cn: \u53ef\u7528\u533a # \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801 Password: # \u67e5\u8be2\u8be5\u53c2\u6570\u65f6\u53ea\u8f93\u51fa\u661f\u53f7\uff08*\uff09 NoEcho: true Type: String Description: en: 'Database root account passwor, 8-32 characters, including uppercase and lowercase letters, numbers and special symbols (including: !@#$%^&*-+=_).' zh-cn: \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801\uff0c\u957f\u5ea68-32\u4e2a\u5b57\u7b26\uff0c\u53ef\u5305\u542b\u5927\u5c0f\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7279\u6b8a\u7b26\u53f7\uff08\u5305\u542b\uff1a!@#$%^&*-+=_\uff09\u3002 Label: en: Root Account Password zh-cn: \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801 ConstraintDescription: en: '8-32 characters, including uppercase and lowercase letters, numbers and special symbols (including: !@#$%^&*-+=_).' zh-cn: 8-32\u4e2a\u5b57\u7b26\uff0c\u53ef\u5305\u542b\u5927\u5c0f\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7279\u6b8a\u7b26\u53f7\uff08\u5305\u542b\uff1a!@#$%^&*-+=_\uff09\u3002 MinLength: '8' MaxLength: '32' AssociationProperty: ALIYUN::ECS::Instance::Password # \u4e13\u6709\u7f51\u7edcVPC\u5b9e\u4f8bID VpcId: AssociationProperty: ALIYUN::ECS::VPC::VPCId Type: String Label: en: VPC ID zh-cn: \u4e13\u6709\u7f51\u7edcVPC\u5b9e\u4f8bID # \u4ea4\u6362\u673a\u5b9e\u4f8bID VSwitchId: AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId AssociationPropertyMetadata: VpcId: ${VpcId} ZoneId: ${ZoneId} Type: String Label: en: VSwitch ID zh-cn: \u4ea4\u6362\u673a\u5b9e\u4f8bID # \u6570\u636e\u76d8\u5927\u5c0f DataDiskSize: Description: zh-cn: ECS\u5b9e\u4f8b\u6570\u636e\u76d8\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3aGiB\u3002\u53d6\u503c\u8303\u56f4\uff1a100~32768 en: 'ECS Instance disk size, range of values: 100-32768, units: GB' Default: 200 MaxValue: 32768 MinValue: 100 Label: zh-cn: \u6570\u636e\u76d8\u7a7a\u95f4 en: Data Disk Space Type: Number # Ecs\u5b9e\u4f8b\u7c7b\u578b EcsInstanceType: Type: String Label: en: Instance Type zh-cn: Ecs\u5b9e\u4f8b\u7c7b\u578b AssociationProperty: ALIYUN::ECS::Instance::InstanceType AllowedValues: - ecs.c6.large - ecs.c6.xlarge - ecs.c6.2xlarge - ecs.c6.4xlarge SlbInstanceType: Type: String Label: en: Instance Type zh-cn: Slb\u5b9e\u4f8b\u7c7b\u578b AssociationProperty: ALIYUN::Slb::LoadBalance::LoadBalancerSpec AllowedValues: - slb.s1.small - slb.s3.small Resources\u5b9a\u4e49\u9700\u8981\u5f00\u7684\u8d44\u6e90\uff0c\u5305\u62ec\u65b0\u5f00\u7684Vpc,\u3001VSwitch\u3001ECS\u3001Slb\u5b9e\u4f8b\u3001\u79c1\u7f51\u8fde\u63a5\u3002 EcsSecurityGroup: Type: 'ALIYUN::ECS::SecurityGroup' Properties: VpcId: Ref: VpcId SecurityGroupIngress: - Priority: 1 PortRange: 3306/3306 NicType: internet SourceCidrIp: 0.0.0.0/0 IpProtocol: tcp # Ecs\u5b9e\u4f8b EcsInstanceGroup: Type: ALIYUN::ECS::InstanceGroup Properties: # I/O\u4f18\u5316\u5b9e\u4f8b IoOptimized: optimized ZoneId: Ref: ZoneId DiskMappings: - Category: cloud_essd Device: /dev/xvdb Size: Ref: DataDiskSize SystemDiskSize: 40 # \u4ed8\u8d39\u65b9\u5f0f\uff1a\u6309\u91cf\u4ed8\u8d39 InstanceChargeType: PostPaid MaxAmount: 1 # \u7cfb\u7edf\u76d8\u7c7b\u578b\uff1acloud_essd SystemDiskCategory: cloud_essd # \u5b9e\u4f8b\u540d\u79f0 InstanceName: Ref: ALIYUN::StackName VpcId: Ref: VpcId SecurityGroupId: Ref: EcsSecurityGroup VSwitchId: Ref: VSwitchId # \u6307\u5b9aCentOS 7.9\u955c\u50cf\uff0c\u5982\u679c\u4fee\u6539\u955c\u50cf\uff0cUserData\u811a\u672c\u9700\u8981\u8fdb\u884c\u9002\u914d ImageId: \"centos_7_9_x64_20G_alibase_20220727.vhd\" InstanceType: Ref: EcsInstanceType # \u4e3b\u673a\u540d HostName: Ref: ALIYUN::StackName # Ecs\u767b\u5f55\u5bc6\u7801 Password: Ref: Password # \u662f\u5426\u4e3a\u5b9e\u4f8b\u5206\u914d\u516c\u7f51IP AllocatePublicIP: true InternetMaxBandwidthOut: 1 # ECS\u6267\u884c\u811a\u672c RunCommand: Type: ALIYUN::ECS::RunCommand Properties: CommandContent: Fn::Sub: - | #!/bin/sh FLAG_FILE=\"/root/.disk_initialized\" PARTITION=/dev/vdb1 MOUNT_POINT=/data1 initialize_disk() { # \u521d\u59cb\u5316\u6570\u636e\u76d8\uff0c\u5bf9\u6570\u636e\u76d8\u5206\u533a cat >> /root/InitDataDisk.sh << EOF #!/bin/bash echo \"p n p w \" | fdisk -u /dev/vdb EOF /bin/bash /root/InitDataDisk.sh rm -f /root/InitDataDisk.sh rm -f InitDataDisk.sh # \u5728\u65b0\u5206\u533a\u4e0a\u521b\u5efa\u6587\u4ef6\u7cfb\u7edf mkfs.ext4 /dev/vdb1 # \u521b\u5efa\u76ee\u5f55\uff0cMySQL\u5c06\u5b89\u88c5\u5728\u8be5\u76ee\u5f55\u4e0b mkdir /data1 # \u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf mount /dev/vdb1 /data1 # \u5411 /etc/fstab \u5199\u5165\u65b0\u5206\u533a\u4fe1\u606f echo /dev/vdb1 /data1 ext4 defaults,nodelalloc,noatime 0 2 >> /etc/fstab } install_mysql() { # \u5b89\u88c5\u793e\u533a\u7248MySQL cd /data1/ wget '{{ computenest::file::MySQL }}' -O mysql-community-release-el6-5.noarch.rpm rpm -ivh mysql-community-release-el6-5.noarch.rpm yum repolist all | grep mysql yum install mysql-community-server -y # \u542f\u52a8MySQL\u670d\u52a1 service mysqld start } configure_mysql() { # \u4ee5\u8d85\u7ea7\u7528\u6237\u8eab\u4efd\u767b\u5165\uff0c\u521b\u5efaadmin\u7528\u6237\uff0c\u5e76\u5141\u8bb8admin\u7528\u6237\u4ee5Password\u4e3a\u5bc6\u7801\u8fdc\u7a0b\u767b\u5f55 mysqladmin -u root password '${Password}' echo \"create database test character set utf8 collate utf8_bin;\" > ./test.sql echo \"CREATE USER 'admin'@'%' IDENTIFIED BY '${Password}';\" >> ./test.sql echo \"GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;\" >> ./test.sql mysql -u root -p'${Password}' < ./test.sql } move_mysql_data() { # \u5c06MySQL\u7684\u914d\u7f6e\u548c\u6570\u636e\u8def\u5f84\u79fb\u52a8\u5230\u6570\u636e\u76d8\u4e0a systemctl stop mysqld rsync -av /var/lib/mysql /data1 # \u4fee\u6539\u914d\u7f6e\u6587\u4ef6 sed -i 's/\\/var\\/lib/\\/data1/g' /etc/my.cnf echo -e '\\n' >> /etc/my.cnf echo '[client]' >> /etc/my.cnf echo 'port=3306' >> /etc/my.cnf echo 'socket=/data1/mysql/mysql.sock' >> /etc/my.cnf # \u91cd\u542fMySQL systemctl start mysqld } expand_partition() { # \u4f7f\u7528 growpart \u6269\u5c55\u5206\u533a echo \"Expanding partition...\" if ! growpart /dev/vdb 1; then echo \"Failed to expand partition\" exit 1 fi # \u901a\u77e5\u7cfb\u7edf\u5206\u533a\u7684\u66f4\u6539 partprobe $PARTITION # \u4f7f\u7528 e2fsck \u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf echo \"Checking filesystem...\" e2fsck -f -y $PARTITION # \u6269\u5c55\u6587\u4ef6\u7cfb\u7edf echo \"Resizing filesystem...\" resize2fs $PARTITION } if [ ! -f \"$FLAG_FILE\" ]; then # \u9996\u6b21\u521b\u5efaECS\u65f6\u6267\u884c # \u786e\u4fdd\u7f51\u7edc\u5c31\u7eea sleep 15 initialize_disk install_mysql configure_mysql move_mysql_data # \u5f53\u521d\u59cb\u5316\u5b8c\u6210\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u6807\u5fd7\u6587\u4ef6 touch \"$FLAG_FILE\" echo \"Initialization complete. Flag file created.\" # \u6267\u884c\u6210\u529f\u56de\u8c03WaitCondition\u7ed3\u675fWaitCondition\u7684\u7b49\u5f85 ${CurlCli} -d \"{\\\"Data\\\" : \\\"SUCCESS\\\", \\\"Status\\\" : \\\"SUCCESS\\\"}\" else # \u6269\u5bb9\u6570\u636e\u76d8\u65f6\u6267\u884c # \u505c\u6b62MySQL\u670d\u52a1 systemctl stop mysqld # \u68c0\u67e5\u5e76\u786e\u4fdd\u5206\u533a\u672a\u88ab\u6302\u8f7d if mountpoint -q $MOUNT_POINT; then umount $MOUNT_POINT fi expand_partition # \u91cd\u65b0\u6302\u8f7d\u5206\u533a echo \"Remounting partition...\" mount $PARTITION $MOUNT_POINT # \u542f\u52a8MySQL\u670d\u52a1 systemctl start mysqld fi # \u83b7\u53d6\u5230WaitConditionHandle\u7684\u5730\u5740\u653e\u5230 ${CurlCli}\u53d8\u91cf\u91cc - CurlCli: Fn::GetAtt: - WaitConditionHandle - CurlCli # \u6570\u636e\u5e93root\u8d26\u6237\u5bc6\u7801 Password: Ref: Password Type: RunShellScript Timeout: 900 Sync: true InstanceIds: - Ref: EcsInstanceGroup Slb: Type: ALIYUN::SLB::LoadBalancer Properties: LoadBalancerName: Fn::Join: - '-' - - mysql - Ref: ALIYUN::StackName VpcId: Ref: VpcId VSwitchId: Ref: VSwitchId PayType: PayOnDemand AddressType: intranet LoadBalancerSpec: Ref: SlbInstanceType SupportPrivateLink: true SlbBackendServerAttachment: DependsOn: - EcsInstanceGroup Type: ALIYUN::SLB::BackendServerAttachment Properties: BackendServerList: Fn::GetAtt: - EcsInstanceGroup - InstanceIds LoadBalancerId: Ref: Slb BackendServerWeightList: - 100 - 0 SlbListener: DependsOn: Slb Type: ALIYUN::SLB::Listener Properties: Persistence: CookieTimeout: 60 StickySession: 'on' PersistenceTimeout: 180 XForwardedFor: 'off' StickySessionType: insert ListenerPort: 3306 Bandwidth: -1 HealthCheck: HttpCode: http_2xx,http_3xx,http_4xx,http_5xx HealthCheckType: tcp UnhealthyThreshold: 3 Timeout: 5 HealthyThreshold: 3 Port: 3306 URI: / Interval: 2 LoadBalancerId: Ref: Slb BackendServerPort: 3306 Protocol: tcp VpcEndpointService: DependsOn: Slb Type: ALIYUN::PrivateLink::VpcEndpointService Properties: ServiceDescription: isv service Resource: - ZoneId: Ref: ZoneId ResourceId: Ref: Slb ResourceType: slb AutoAcceptEnabled: true Outputs\u5b9a\u4e49\u9700\u8981\u6700\u7ec8\u5728\u8ba1\u7b97\u5de2\u6982\u89c8\u9875\u4e2d\u5bf9\u7528\u6237\u5c55\u793a\u7684\u8f93\u51fa Outputs: EndpointServiceId: Description: en: EndpointService Id zh-cn: \u7ec8\u7aef\u8282\u70b9\u670d\u52a1Id Value: Fn::GetAtt: - VpcEndpointService - ServiceId Endpoint: Value: Fn::Join: - '' - - Ref: ALIYUN::StackName - .mysql.com MysqlUserName: Description: en: MySQL User Name zh-cn: MySQL\u767b\u5f55\u7528\u6237\u540d Value: admin","title":"\u670d\u52a1\u8be6\u7ec6\u8bf4\u660e"},{"location":"#_14","text":"\u521b\u5efa\u4ee3\u8fd0\u7ef4\u670d\u52a1\u5b8c\u6210\u5b9e\u4f8b\u8fd0\u7ef4 \u521b\u5efa\u5305\u542b\u53d8\u914d\u529f\u80fd\u7684\u670d\u52a1 \u521b\u5efa\u5305\u542b\u670d\u52a1\u5347\u7ea7\u529f\u80fd\u7684\u670d\u52a1","title":"\u670d\u52a1\u914d\u7f6e"},{"location":"#_15","text":"\u81ea\u5b9a\u4e49\u670d\u52a1\u67b6\u6784\u56fe \u670d\u52a1\u6587\u6863\u4e0a\u7ebf\u6d41\u7a0b \u5c06\u670d\u52a1\u4e0a\u67b6\u4e91\u5e02\u573a\u5e76\u4e0a\u5230\u4e91\u5e02\u573a\u552e\u5356","title":"\u670d\u52a1\u4ea4\u4ed8"}]} \ No newline at end of file diff --git a/search/worker.js b/search/worker.js new file mode 100644 index 0000000..8628dbc --- /dev/null +++ b/search/worker.js @@ -0,0 +1,133 @@ +var base_path = 'function' === typeof importScripts ? '.' : '/search/'; +var allowSearch = false; +var index; +var documents = {}; +var lang = ['en']; +var data; + +function getScript(script, callback) { + console.log('Loading script: ' + script); + $.getScript(base_path + script).done(function () { + callback(); + }).fail(function (jqxhr, settings, exception) { + console.log('Error: ' + exception); + }); +} + +function getScriptsInOrder(scripts, callback) { + if (scripts.length === 0) { + callback(); + return; + } + getScript(scripts[0], function() { + getScriptsInOrder(scripts.slice(1), callback); + }); +} + +function loadScripts(urls, callback) { + if( 'function' === typeof importScripts ) { + importScripts.apply(null, urls); + callback(); + } else { + getScriptsInOrder(urls, callback); + } +} + +function onJSONLoaded () { + data = JSON.parse(this.responseText); + var scriptsToLoad = ['lunr.js']; + if (data.config && data.config.lang && data.config.lang.length) { + lang = data.config.lang; + } + if (lang.length > 1 || lang[0] !== "en") { + scriptsToLoad.push('lunr.stemmer.support.js'); + if (lang.length > 1) { + scriptsToLoad.push('lunr.multi.js'); + } + if (lang.includes("ja") || lang.includes("jp")) { + scriptsToLoad.push('tinyseg.js'); + } + for (var i=0; i < lang.length; i++) { + if (lang[i] != 'en') { + scriptsToLoad.push(['lunr', lang[i], 'js'].join('.')); + } + } + } + loadScripts(scriptsToLoad, onScriptsLoaded); +} + +function onScriptsLoaded () { + console.log('All search scripts loaded, building Lunr index...'); + if (data.config && data.config.separator && data.config.separator.length) { + lunr.tokenizer.separator = new RegExp(data.config.separator); + } + + if (data.index) { + index = lunr.Index.load(data.index); + data.docs.forEach(function (doc) { + documents[doc.location] = doc; + }); + console.log('Lunr pre-built index loaded, search ready'); + } else { + index = lunr(function () { + if (lang.length === 1 && lang[0] !== "en" && lunr[lang[0]]) { + this.use(lunr[lang[0]]); + } else if (lang.length > 1) { + this.use(lunr.multiLanguage.apply(null, lang)); // spread operator not supported in all browsers: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Browser_compatibility + } + this.field('title'); + this.field('text'); + this.ref('location'); + + for (var i=0; i < data.docs.length; i++) { + var doc = data.docs[i]; + this.add(doc); + documents[doc.location] = doc; + } + }); + console.log('Lunr index built, search ready'); + } + allowSearch = true; + postMessage({config: data.config}); + postMessage({allowSearch: allowSearch}); +} + +function init () { + var oReq = new XMLHttpRequest(); + oReq.addEventListener("load", onJSONLoaded); + var index_path = base_path + '/search_index.json'; + if( 'function' === typeof importScripts ){ + index_path = 'search_index.json'; + } + oReq.open("GET", index_path); + oReq.send(); +} + +function search (query) { + if (!allowSearch) { + console.error('Assets for search still loading'); + return; + } + + var resultDocuments = []; + var results = index.search(query); + for (var i=0; i < results.length; i++){ + var result = results[i]; + doc = documents[result.ref]; + doc.summary = doc.text.substring(0, 200); + resultDocuments.push(doc); + } + return resultDocuments; +} + +if( 'function' === typeof importScripts ) { + onmessage = function (e) { + if (e.data.init) { + init(); + } else if (e.data.query) { + postMessage({ results: search(e.data.query) }); + } else { + console.error("Worker - Unrecognized message: " + e); + } + }; +} diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 0000000..0f8724e --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz new file mode 100644 index 0000000..9e15723 Binary files /dev/null and b/sitemap.xml.gz differ diff --git "a/\344\277\256\346\224\271\344\270\255.png" "b/\344\277\256\346\224\271\344\270\255.png" new file mode 100644 index 0000000..d753d3f Binary files /dev/null and "b/\344\277\256\346\224\271\344\270\255.png" differ diff --git "a/\344\277\256\346\224\271\351\205\215\347\275\256-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" "b/\344\277\256\346\224\271\351\205\215\347\275\256-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" new file mode 100644 index 0000000..04f0f26 Binary files /dev/null and "b/\344\277\256\346\224\271\351\205\215\347\275\256-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" differ diff --git "a/\344\277\256\346\224\271\351\205\215\347\275\256-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" "b/\344\277\256\346\224\271\351\205\215\347\275\256-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" new file mode 100644 index 0000000..c17e145 Binary files /dev/null and "b/\344\277\256\346\224\271\351\205\215\347\275\256-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" differ diff --git "a/\344\277\256\346\224\271\351\205\215\347\275\256\345\217\202\346\225\260.png" "b/\344\277\256\346\224\271\351\205\215\347\275\256\345\217\202\346\225\260.png" new file mode 100644 index 0000000..76fa54b Binary files /dev/null and "b/\344\277\256\346\224\271\351\205\215\347\275\256\345\217\202\346\225\260.png" differ diff --git "a/\345\210\233\345\273\272\345\217\202\346\225\260\347\241\256\350\256\244.jpg" "b/\345\210\233\345\273\272\345\217\202\346\225\260\347\241\256\350\256\244.jpg" new file mode 100644 index 0000000..410ff57 Binary files /dev/null and "b/\345\210\233\345\273\272\345\217\202\346\225\260\347\241\256\350\256\244.jpg" differ diff --git "a/\345\210\233\345\273\272\346\234\215\345\212\241\345\256\236\344\276\213\346\234\252\345\274\200\345\220\257\347\247\201\347\275\221\350\277\236\346\216\245.jpg" "b/\345\210\233\345\273\272\346\234\215\345\212\241\345\256\236\344\276\213\346\234\252\345\274\200\345\220\257\347\247\201\347\275\221\350\277\236\346\216\245.jpg" new file mode 100644 index 0000000..9d92851 Binary files /dev/null and "b/\345\210\233\345\273\272\346\234\215\345\212\241\345\256\236\344\276\213\346\234\252\345\274\200\345\220\257\347\247\201\347\275\221\350\277\236\346\216\245.jpg" differ diff --git "a/\345\210\233\345\273\272\347\273\210\347\253\257\350\212\202\347\202\271.jpg" "b/\345\210\233\345\273\272\347\273\210\347\253\257\350\212\202\347\202\271.jpg" new file mode 100644 index 0000000..ff12e85 Binary files /dev/null and "b/\345\210\233\345\273\272\347\273\210\347\253\257\350\212\202\347\202\271.jpg" differ diff --git "a/\345\217\202\346\225\260\344\277\256\346\224\271\345\256\214\346\210\220.png" "b/\345\217\202\346\225\260\344\277\256\346\224\271\345\256\214\346\210\220.png" new file mode 100644 index 0000000..fbaf613 Binary files /dev/null and "b/\345\217\202\346\225\260\344\277\256\346\224\271\345\256\214\346\210\220.png" differ diff --git "a/\345\217\230\351\205\215\345\211\215\346\225\260\346\215\256\347\233\230\345\256\271\351\207\217.jpg" "b/\345\217\230\351\205\215\345\211\215\346\225\260\346\215\256\347\233\230\345\256\271\351\207\217.jpg" new file mode 100644 index 0000000..acdbbf7 Binary files /dev/null and "b/\345\217\230\351\205\215\345\211\215\346\225\260\346\215\256\347\233\230\345\256\271\351\207\217.jpg" differ diff --git "a/\345\217\230\351\205\215\345\220\216\346\225\260\346\215\256\347\233\230\345\256\271\351\207\217.jpg" "b/\345\217\230\351\205\215\345\220\216\346\225\260\346\215\256\347\233\230\345\256\271\351\207\217.jpg" new file mode 100644 index 0000000..b748c9a Binary files /dev/null and "b/\345\217\230\351\205\215\345\220\216\346\225\260\346\215\256\347\233\230\345\256\271\351\207\217.jpg" differ diff --git "a/\346\210\220\345\212\237\345\210\233\345\273\272\347\273\210\347\253\257\350\212\202\347\202\271.jpg" "b/\346\210\220\345\212\237\345\210\233\345\273\272\347\273\210\347\253\257\350\212\202\347\202\271.jpg" new file mode 100644 index 0000000..39d6b52 Binary files /dev/null and "b/\346\210\220\345\212\237\345\210\233\345\273\272\347\273\210\347\253\257\350\212\202\347\202\271.jpg" differ diff --git "a/\346\217\220\344\272\244\346\210\220\345\212\237.png" "b/\346\217\220\344\272\244\346\210\220\345\212\237.png" new file mode 100644 index 0000000..06782b5 Binary files /dev/null and "b/\346\217\220\344\272\244\346\210\220\345\212\237.png" differ diff --git "a/\346\226\260\347\211\210\351\203\250\347\275\262\345\217\202\346\225\260.jpg" "b/\346\226\260\347\211\210\351\203\250\347\275\262\345\217\202\346\225\260.jpg" new file mode 100644 index 0000000..bb22005 Binary files /dev/null and "b/\346\226\260\347\211\210\351\203\250\347\275\262\345\217\202\346\225\260.jpg" differ diff --git "a/\346\234\215\345\212\241\345\256\236\344\276\213\345\217\230\351\205\215\344\270\255.jpg" "b/\346\234\215\345\212\241\345\256\236\344\276\213\345\217\230\351\205\215\344\270\255.jpg" new file mode 100644 index 0000000..94beaec Binary files /dev/null and "b/\346\234\215\345\212\241\345\256\236\344\276\213\345\217\230\351\205\215\344\270\255.jpg" differ diff --git "a/\346\234\215\345\212\241\345\256\236\344\276\213\345\217\230\351\205\215\345\256\214\346\210\220-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" "b/\346\234\215\345\212\241\345\256\236\344\276\213\345\217\230\351\205\215\345\256\214\346\210\220-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" new file mode 100644 index 0000000..a08a716 Binary files /dev/null and "b/\346\234\215\345\212\241\345\256\236\344\276\213\345\217\230\351\205\215\345\256\214\346\210\220-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" differ diff --git "a/\346\234\215\345\212\241\345\256\236\344\276\213\346\234\252\345\274\200\345\220\257\347\247\201\347\275\221\350\277\236\346\216\245.jpg" "b/\346\234\215\345\212\241\345\256\236\344\276\213\346\234\252\345\274\200\345\220\257\347\247\201\347\275\221\350\277\236\346\216\245.jpg" new file mode 100644 index 0000000..363805a Binary files /dev/null and "b/\346\234\215\345\212\241\345\256\236\344\276\213\346\234\252\345\274\200\345\220\257\347\247\201\347\275\221\350\277\236\346\216\245.jpg" differ diff --git "a/\347\275\221\347\273\234\351\205\215\347\275\256.png" "b/\347\275\221\347\273\234\351\205\215\347\275\256.png" new file mode 100644 index 0000000..6472cab Binary files /dev/null and "b/\347\275\221\347\273\234\351\205\215\347\275\256.png" differ diff --git "a/\350\207\252\345\256\232\344\271\211\345\237\237\345\220\215\350\256\277\351\227\256.png" "b/\350\207\252\345\256\232\344\271\211\345\237\237\345\220\215\350\256\277\351\227\256.png" new file mode 100644 index 0000000..158e63f Binary files /dev/null and "b/\350\207\252\345\256\232\344\271\211\345\237\237\345\220\215\350\256\277\351\227\256.png" differ diff --git "a/\350\231\232\346\213\237\344\272\222\350\201\224\347\275\221.png" "b/\350\231\232\346\213\237\344\272\222\350\201\224\347\275\221.png" new file mode 100644 index 0000000..fc60f4b Binary files /dev/null and "b/\350\231\232\346\213\237\344\272\222\350\201\224\347\275\221.png" differ diff --git "a/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\346\267\273\345\212\240\347\275\221\347\273\234\345\217\230\351\205\215\344\277\241\346\201\257.jpg" "b/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\346\267\273\345\212\240\347\275\221\347\273\234\345\217\230\351\205\215\344\277\241\346\201\257.jpg" new file mode 100644 index 0000000..d88e240 Binary files /dev/null and "b/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\346\267\273\345\212\240\347\275\221\347\273\234\345\217\230\351\205\215\344\277\241\346\201\257.jpg" differ diff --git "a/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" "b/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" new file mode 100644 index 0000000..2218cc3 Binary files /dev/null and "b/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" differ diff --git "a/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" "b/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" new file mode 100644 index 0000000..ce1ae05 Binary files /dev/null and "b/\350\256\276\347\275\256\344\277\256\346\224\271\345\217\202\346\225\260-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" differ diff --git "a/\351\200\232\350\277\207ip\350\256\277\351\227\256.png" "b/\351\200\232\350\277\207ip\350\256\277\351\227\256.png" new file mode 100644 index 0000000..e77f951 Binary files /dev/null and "b/\351\200\232\350\277\207ip\350\256\277\351\227\256.png" differ diff --git "a/\351\200\232\350\277\207\345\217\257\347\224\250\345\214\272\345\237\237\345\220\215\350\256\277\351\227\256.png" "b/\351\200\232\350\277\207\345\217\257\347\224\250\345\214\272\345\237\237\345\220\215\350\256\277\351\227\256.png" new file mode 100644 index 0000000..6fd7f90 Binary files /dev/null and "b/\351\200\232\350\277\207\345\217\257\347\224\250\345\214\272\345\237\237\345\220\215\350\256\277\351\227\256.png" differ diff --git "a/\351\203\250\347\275\262\346\210\220\345\212\237.png" "b/\351\203\250\347\275\262\346\210\220\345\212\237.png" new file mode 100644 index 0000000..a5ba3e5 Binary files /dev/null and "b/\351\203\250\347\275\262\346\210\220\345\212\237.png" differ diff --git "a/\351\203\250\347\275\262\350\277\233\345\272\246.jpg" "b/\351\203\250\347\275\262\350\277\233\345\272\246.jpg" new file mode 100644 index 0000000..da0ec8f Binary files /dev/null and "b/\351\203\250\347\275\262\350\277\233\345\272\246.jpg" differ diff --git "a/\351\203\250\347\275\262\351\223\276\346\216\245.jpg" "b/\351\203\250\347\275\262\351\223\276\346\216\245.jpg" new file mode 100644 index 0000000..46451c4 Binary files /dev/null and "b/\351\203\250\347\275\262\351\223\276\346\216\245.jpg" differ diff --git "a/\351\205\215\347\275\256\345\217\202\346\225\260\350\257\246\346\203\205.png" "b/\351\205\215\347\275\256\345\217\202\346\225\260\350\257\246\346\203\205.png" new file mode 100644 index 0000000..121c65f Binary files /dev/null and "b/\351\205\215\347\275\256\345\217\202\346\225\260\350\257\246\346\203\205.png" differ diff --git "a/\351\242\204\350\247\210\345\217\202\346\225\260-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" "b/\351\242\204\350\247\210\345\217\202\346\225\260-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" new file mode 100644 index 0000000..42d1175 Binary files /dev/null and "b/\351\242\204\350\247\210\345\217\202\346\225\260-\347\243\201\347\233\230\346\211\251\345\256\271.jpg" differ diff --git "a/\351\242\204\350\247\210\345\217\202\346\225\260-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" "b/\351\242\204\350\247\210\345\217\202\346\225\260-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" new file mode 100644 index 0000000..4c11399 Binary files /dev/null and "b/\351\242\204\350\247\210\345\217\202\346\225\260-\347\275\221\347\273\234\345\217\230\351\205\215.jpg" differ