securemark 0.296.2 → 0.296.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/index.js +24 -15
- package/package.json +1 -1
- package/src/combinator/control/manipulation/surround.ts +1 -1
- package/src/combinator/data/parser/context.test.ts +2 -2
- package/src/combinator/data/parser/context.ts +11 -2
- package/src/parser/api/bind.ts +6 -6
- package/src/parser/api/parse.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.296.
|
|
1
|
+
/*! securemark v0.296.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -3113,7 +3113,7 @@ function surround(opener, parser, closer, optional = false, backtracks = [], f,
|
|
|
3113
3113
|
const result = g?.([nodesO, nodesM], context);
|
|
3114
3114
|
return result || void revert(context, linebreak);
|
|
3115
3115
|
}
|
|
3116
|
-
const nodesC =
|
|
3116
|
+
const nodesC = optional || nodesM ? closer(input) : undefined;
|
|
3117
3117
|
context.range = context.position - position;
|
|
3118
3118
|
if (nodesC === undefined) {
|
|
3119
3119
|
wbs && setBacktrack(context, wbs, position);
|
|
@@ -3720,15 +3720,24 @@ exports.constraint = exports.state = exports.precedence = exports.recursion = ex
|
|
|
3720
3720
|
const alias_1 = __webpack_require__(5413);
|
|
3721
3721
|
const assign_1 = __webpack_require__(9888);
|
|
3722
3722
|
function reset(base, parser) {
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3723
|
+
return input => {
|
|
3724
|
+
const {
|
|
3725
|
+
context
|
|
3726
|
+
} = input;
|
|
3727
|
+
// @ts-expect-error
|
|
3728
|
+
context.resources ??= {
|
|
3729
|
+
clock: base.resources?.clock,
|
|
3730
|
+
recursions: base.resources?.recursions.slice()
|
|
3731
|
+
};
|
|
3732
|
+
context.backtracks = {};
|
|
3733
|
+
return parser(input);
|
|
3734
|
+
};
|
|
3735
|
+
// removed by dead control flow
|
|
3736
|
+
|
|
3737
|
+
// removed by dead control flow
|
|
3738
|
+
|
|
3739
|
+
// removed by dead control flow
|
|
3740
|
+
|
|
3732
3741
|
}
|
|
3733
3742
|
exports.reset = reset;
|
|
3734
3743
|
function context(base, parser) {
|
|
@@ -4228,7 +4237,7 @@ function bind(target, settings) {
|
|
|
4228
4237
|
context.header = true;
|
|
4229
4238
|
for (; index < sourceSegments.length - last; ++index) {
|
|
4230
4239
|
const seg = sourceSegments[index];
|
|
4231
|
-
const es = (0, block_1.block)((0, parser_1.input)(seg, context))?.foldl((acc, {
|
|
4240
|
+
const es = (0, block_1.block)((0, parser_1.input)(seg, new context_1.Context(context)))?.foldl((acc, {
|
|
4232
4241
|
value
|
|
4233
4242
|
}) => void acc.push(value) || acc, []) ?? [];
|
|
4234
4243
|
// @ts-expect-error
|
|
@@ -4237,7 +4246,7 @@ function bind(target, settings) {
|
|
|
4237
4246
|
if (es.length === 0) continue;
|
|
4238
4247
|
// All deletion processes always run after all addition processes have done.
|
|
4239
4248
|
// Therefore any `base` node will never be unavailable by deletions until all the dependent `el` nodes are added.
|
|
4240
|
-
|
|
4249
|
+
adds.push(...es.map(el => [el, base]));
|
|
4241
4250
|
adds.reverse();
|
|
4242
4251
|
for (; adds.length > 0;) {
|
|
4243
4252
|
const [el, base] = adds.pop();
|
|
@@ -4254,7 +4263,7 @@ function bind(target, settings) {
|
|
|
4254
4263
|
for (let refuse = (0, array_1.splice)(blocks, index, blocks.length - sourceSegments.length), i = 0; i < refuse.length; ++i) {
|
|
4255
4264
|
const es = refuse[i][1];
|
|
4256
4265
|
if (es.length === 0) continue;
|
|
4257
|
-
|
|
4266
|
+
dels.push(...es.map(el => [el]));
|
|
4258
4267
|
}
|
|
4259
4268
|
adds.reverse();
|
|
4260
4269
|
for (; adds.length > 0;) {
|
|
@@ -4539,7 +4548,7 @@ function parse(source, options = {}, context) {
|
|
|
4539
4548
|
// @ts-expect-error
|
|
4540
4549
|
context.header = true;
|
|
4541
4550
|
for (const seg of (0, segment_1.segment)(source)) {
|
|
4542
|
-
node.append(...((0, block_1.block)((0, parser_1.input)(seg, context))?.foldl((acc, {
|
|
4551
|
+
node.append(...((0, block_1.block)((0, parser_1.input)(seg, new context_1.Context(context)))?.foldl((acc, {
|
|
4543
4552
|
value
|
|
4544
4553
|
}) => void acc.push(value) || acc, []) ?? []));
|
|
4545
4554
|
// @ts-expect-error
|
package/package.json
CHANGED
|
@@ -103,7 +103,7 @@ export function surround<N>(
|
|
|
103
103
|
const result = g?.([nodesO, nodesM], context);
|
|
104
104
|
return result || void revert(context, linebreak);
|
|
105
105
|
}
|
|
106
|
-
const nodesC =
|
|
106
|
+
const nodesC = optional || nodesM ? closer(input) : undefined;
|
|
107
107
|
context.range = context.position - position;
|
|
108
108
|
if (nodesC === undefined) {
|
|
109
109
|
wbs && setBacktrack(context, wbs, position);
|
|
@@ -21,9 +21,9 @@ describe('Unit: combinator/data/parser/context', () => {
|
|
|
21
21
|
const ctx: Ctx = new Context();
|
|
22
22
|
assert.deepStrictEqual([...unwrap(reset(base, parser)(input('123', ctx))!)], [3, 2, 1]);
|
|
23
23
|
assert(base.resources?.clock === 3);
|
|
24
|
-
assert(ctx.resources?.clock ===
|
|
24
|
+
assert(ctx.resources?.clock === 0);
|
|
25
25
|
assert.throws(() => reset(base, parser)(input('1234', ctx)));
|
|
26
|
-
assert(ctx.resources?.clock ===
|
|
26
|
+
assert(ctx.resources?.clock === 0);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it('node', () => {
|
|
@@ -4,13 +4,22 @@ import { clone } from 'spica/assign';
|
|
|
4
4
|
|
|
5
5
|
export function reset<P extends Parser>(base: Options, parser: P): P;
|
|
6
6
|
export function reset<N>(base: Context, parser: Parser<N>): Parser<N> {
|
|
7
|
+
return input => {
|
|
8
|
+
const { context } = input;
|
|
9
|
+
// @ts-expect-error
|
|
10
|
+
context.resources ??= {
|
|
11
|
+
clock: base.resources?.clock,
|
|
12
|
+
recursions: base.resources?.recursions.slice(),
|
|
13
|
+
};
|
|
14
|
+
context.backtracks = {};
|
|
15
|
+
return parser(input);
|
|
16
|
+
};
|
|
7
17
|
assert(Object.getPrototypeOf(base) === Object.prototype);
|
|
8
18
|
assert(Object.freeze(base));
|
|
9
19
|
const changes = Object.entries(base);
|
|
10
20
|
const values = Array(changes.length);
|
|
11
21
|
return ({ context }) =>
|
|
12
|
-
|
|
13
|
-
apply(parser, { ...context }, changes, values, true);
|
|
22
|
+
apply(parser, context, changes, values, true);
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
export function context<P extends Parser>(base: Options, parser: P): P;
|
package/src/parser/api/bind.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { headers } from './header';
|
|
|
8
8
|
import { figure } from '../processor/figure';
|
|
9
9
|
import { note } from '../processor/note';
|
|
10
10
|
import { ReadonlyURL } from 'spica/url';
|
|
11
|
-
import {
|
|
11
|
+
import { splice } from 'spica/array';
|
|
12
12
|
|
|
13
13
|
interface Settings extends ParserSettings {
|
|
14
14
|
}
|
|
@@ -29,8 +29,8 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
|
|
|
29
29
|
if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
|
|
30
30
|
type Block = readonly [segment: string, blocks: readonly HTMLElement[], url: string];
|
|
31
31
|
const blocks: Block[] = [];
|
|
32
|
-
const adds: [HTMLElement, Node | null][] = [];
|
|
33
|
-
const dels: [HTMLElement][] = [];
|
|
32
|
+
const adds: (readonly [HTMLElement, Node | null])[] = [];
|
|
33
|
+
const dels: (readonly [HTMLElement])[] = [];
|
|
34
34
|
const bottom = target.firstChild;
|
|
35
35
|
let revision: symbol | undefined;
|
|
36
36
|
return {
|
|
@@ -75,7 +75,7 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
|
|
|
75
75
|
for (; index < sourceSegments.length - last; ++index) {
|
|
76
76
|
assert(rev === revision);
|
|
77
77
|
const seg = sourceSegments[index];
|
|
78
|
-
const es = block(input(seg, context))
|
|
78
|
+
const es = block(input(seg, new Context(context)))
|
|
79
79
|
?.foldl<HTMLElement[]>((acc, { value }) => void acc.push(value) || acc, []) ?? [];
|
|
80
80
|
// @ts-expect-error
|
|
81
81
|
context.header = false;
|
|
@@ -83,7 +83,7 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
|
|
|
83
83
|
if (es.length === 0) continue;
|
|
84
84
|
// All deletion processes always run after all addition processes have done.
|
|
85
85
|
// Therefore any `base` node will never be unavailable by deletions until all the dependent `el` nodes are added.
|
|
86
|
-
push(
|
|
86
|
+
adds.push(...es.map(el => [el, base] as const));
|
|
87
87
|
adds.reverse();
|
|
88
88
|
for (; adds.length > 0;) {
|
|
89
89
|
assert(rev === revision);
|
|
@@ -98,7 +98,7 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
|
|
|
98
98
|
assert(rev === revision);
|
|
99
99
|
const es = refuse[i][1];
|
|
100
100
|
if (es.length === 0) continue;
|
|
101
|
-
push(
|
|
101
|
+
dels.push(...es.map(el => [el] as const));
|
|
102
102
|
}
|
|
103
103
|
assert(blocks.length === sourceSegments.length);
|
|
104
104
|
adds.reverse();
|
package/src/parser/api/parse.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function parse(source: string, options: Options = {}, context?: Context):
|
|
|
34
34
|
context.header = true;
|
|
35
35
|
for (const seg of segment(source)) {
|
|
36
36
|
node.append(
|
|
37
|
-
...block(input(seg, context))
|
|
37
|
+
...block(input(seg, new Context(context)))
|
|
38
38
|
?.foldl<HTMLElement[]>((acc, { value }) => void acc.push(value) || acc, []) ?? []);
|
|
39
39
|
// @ts-expect-error
|
|
40
40
|
context.header = false;
|