@wordpress/element 6.32.0 → 6.32.1-next.47f435fc9.0
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/build/create-interpolate-element.js +79 -183
- package/build/create-interpolate-element.js.map +7 -1
- package/build/index.js +52 -74
- package/build/index.js.map +7 -1
- package/build/platform.android.js +29 -16
- package/build/platform.android.js.map +7 -1
- package/build/platform.ios.js +29 -16
- package/build/platform.ios.js.map +7 -1
- package/build/platform.js +25 -40
- package/build/platform.js.map +7 -1
- package/build/raw-html.js +28 -47
- package/build/raw-html.js.map +7 -1
- package/build/react-platform.js +43 -55
- package/build/react-platform.js.map +7 -1
- package/build/react.js +114 -411
- package/build/react.js.map +7 -1
- package/build/serialize.js +418 -325
- package/build/serialize.js.map +7 -1
- package/build/utils.js +29 -15
- package/build/utils.js.map +7 -1
- package/build-module/create-interpolate-element.js +63 -175
- package/build-module/create-interpolate-element.js.map +7 -1
- package/build-module/index.js +14 -8
- package/build-module/index.js.map +7 -1
- package/build-module/platform.android.js +10 -10
- package/build-module/platform.android.js.map +7 -1
- package/build-module/platform.ios.js +10 -10
- package/build-module/platform.ios.js.map +7 -1
- package/build-module/platform.js +7 -36
- package/build-module/platform.js.map +7 -1
- package/build-module/raw-html.js +11 -44
- package/build-module/raw-html.js.map +7 -1
- package/build-module/react-platform.js +20 -71
- package/build-module/react-platform.js.map +7 -1
- package/build-module/react.js +91 -255
- package/build-module/react.js.map +7 -1
- package/build-module/serialize.js +382 -311
- package/build-module/serialize.js.map +7 -1
- package/build-module/utils.js +7 -10
- package/build-module/utils.js.map +7 -1
- package/package.json +11 -4
- package/build/react-platform.native.js +0 -22
- package/build/react-platform.native.js.map +0 -1
- package/build-module/react-platform.native.js +0 -15
- package/build-module/react-platform.native.js.map +0 -1
|
@@ -1,54 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var create_interpolate_element_exports = {};
|
|
20
|
+
__export(create_interpolate_element_exports, {
|
|
21
|
+
default: () => create_interpolate_element_default
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(create_interpolate_element_exports);
|
|
24
|
+
var import_react = require("./react");
|
|
12
25
|
let indoc;
|
|
13
26
|
let offset;
|
|
14
27
|
let output;
|
|
15
28
|
let stack;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Matches tags in the localized string
|
|
19
|
-
*
|
|
20
|
-
* This is used for extracting the tag pattern groups for parsing the localized
|
|
21
|
-
* string and along with the map converting it to a react element.
|
|
22
|
-
*
|
|
23
|
-
* There are four references extracted using this tokenizer:
|
|
24
|
-
*
|
|
25
|
-
* match: Full match of the tag (i.e. <strong>, </strong>, <br/>)
|
|
26
|
-
* isClosing: The closing slash, if it exists.
|
|
27
|
-
* name: The name portion of the tag (strong, br) (if )
|
|
28
|
-
* isSelfClosed: The slash on a self closing tag, if it exists.
|
|
29
|
-
*/
|
|
30
29
|
const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
|
|
31
|
-
/**
|
|
32
|
-
* Tracks recursive-descent parse state.
|
|
33
|
-
*
|
|
34
|
-
* This is a Stack frame holding parent elements until all children have been
|
|
35
|
-
* parsed.
|
|
36
|
-
*
|
|
37
|
-
* @private
|
|
38
|
-
* @param element A parent element which may still have
|
|
39
|
-
* nested children not yet parsed.
|
|
40
|
-
* @param tokenStart Offset at which parent element first
|
|
41
|
-
* appears.
|
|
42
|
-
* @param tokenLength Length of string marking start of parent
|
|
43
|
-
* element.
|
|
44
|
-
* @param prevOffset Running offset at which parsing should
|
|
45
|
-
* continue.
|
|
46
|
-
* @param leadingTextStart Offset at which last closing element
|
|
47
|
-
* finished, used for finding text between
|
|
48
|
-
* elements.
|
|
49
|
-
*
|
|
50
|
-
* @return The stack frame tracking parse progress.
|
|
51
|
-
*/
|
|
52
30
|
function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
|
|
53
31
|
return {
|
|
54
32
|
element,
|
|
@@ -59,34 +37,6 @@ function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextSt
|
|
|
59
37
|
children: []
|
|
60
38
|
};
|
|
61
39
|
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* This function creates an interpolated element from a passed in string with
|
|
65
|
-
* specific tags matching how the string should be converted to an element via
|
|
66
|
-
* the conversion map value.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* For example, for the given string:
|
|
70
|
-
*
|
|
71
|
-
* "This is a <span>string</span> with <a>a link</a> and a self-closing
|
|
72
|
-
* <CustomComponentB/> tag"
|
|
73
|
-
*
|
|
74
|
-
* You would have something like this as the conversionMap value:
|
|
75
|
-
*
|
|
76
|
-
* ```js
|
|
77
|
-
* {
|
|
78
|
-
* span: <span />,
|
|
79
|
-
* a: <a href={ 'https://github.com' } />,
|
|
80
|
-
* CustomComponentB: <CustomComponent />,
|
|
81
|
-
* }
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @param interpolatedString The interpolation string to be parsed.
|
|
85
|
-
* @param conversionMap The map used to convert the string to
|
|
86
|
-
* a react element.
|
|
87
|
-
* @throws {TypeError}
|
|
88
|
-
* @return A wp element.
|
|
89
|
-
*/
|
|
90
40
|
const createInterpolateElement = (interpolatedString, conversionMap) => {
|
|
91
41
|
indoc = interpolatedString;
|
|
92
42
|
offset = 0;
|
|
@@ -94,40 +44,19 @@ const createInterpolateElement = (interpolatedString, conversionMap) => {
|
|
|
94
44
|
stack = [];
|
|
95
45
|
tokenizer.lastIndex = 0;
|
|
96
46
|
if (!isValidConversionMap(conversionMap)) {
|
|
97
|
-
throw new TypeError(
|
|
47
|
+
throw new TypeError(
|
|
48
|
+
"The conversionMap provided is not valid. It must be an object with values that are React Elements"
|
|
49
|
+
);
|
|
98
50
|
}
|
|
99
51
|
do {
|
|
100
|
-
// twiddle our thumbs
|
|
101
52
|
} while (proceed(conversionMap));
|
|
102
|
-
return (0,
|
|
53
|
+
return (0, import_react.createElement)(import_react.Fragment, null, ...output);
|
|
103
54
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* Validate conversion map.
|
|
107
|
-
*
|
|
108
|
-
* A map is considered valid if it's an object and every value in the object
|
|
109
|
-
* is a React Element
|
|
110
|
-
*
|
|
111
|
-
* @private
|
|
112
|
-
*
|
|
113
|
-
* @param conversionMap The map being validated.
|
|
114
|
-
*
|
|
115
|
-
* @return True means the map is valid.
|
|
116
|
-
*/
|
|
117
|
-
const isValidConversionMap = conversionMap => {
|
|
118
|
-
const isObject = typeof conversionMap === 'object' && conversionMap !== null;
|
|
55
|
+
const isValidConversionMap = (conversionMap) => {
|
|
56
|
+
const isObject = typeof conversionMap === "object" && conversionMap !== null;
|
|
119
57
|
const values = isObject && Object.values(conversionMap);
|
|
120
|
-
return isObject && values.length > 0 && values.every(element => (0,
|
|
58
|
+
return isObject && values.length > 0 && values.every((element) => (0, import_react.isValidElement)(element));
|
|
121
59
|
};
|
|
122
|
-
/**
|
|
123
|
-
* This is the iterator over the matches in the string.
|
|
124
|
-
*
|
|
125
|
-
* @private
|
|
126
|
-
*
|
|
127
|
-
* @param conversionMap The conversion map for the string.
|
|
128
|
-
*
|
|
129
|
-
* @return true for continuing to iterate, false for finished.
|
|
130
|
-
*/
|
|
131
60
|
function proceed(conversionMap) {
|
|
132
61
|
const next = nextToken();
|
|
133
62
|
const [tokenType, name, startOffset, tokenLength] = next;
|
|
@@ -138,49 +67,63 @@ function proceed(conversionMap) {
|
|
|
138
67
|
return false;
|
|
139
68
|
}
|
|
140
69
|
switch (tokenType) {
|
|
141
|
-
case
|
|
70
|
+
case "no-more-tokens":
|
|
142
71
|
if (stackDepth !== 0) {
|
|
143
|
-
const {
|
|
144
|
-
leadingTextStart: stackLeadingText,
|
|
145
|
-
tokenStart
|
|
146
|
-
} = stack.pop();
|
|
72
|
+
const { leadingTextStart: stackLeadingText, tokenStart } = stack.pop();
|
|
147
73
|
output.push(indoc.substr(stackLeadingText, tokenStart));
|
|
148
74
|
}
|
|
149
75
|
addText();
|
|
150
76
|
return false;
|
|
151
|
-
case
|
|
77
|
+
case "self-closed":
|
|
152
78
|
if (0 === stackDepth) {
|
|
153
79
|
if (null !== leadingTextStart) {
|
|
154
|
-
output.push(
|
|
80
|
+
output.push(
|
|
81
|
+
indoc.substr(
|
|
82
|
+
leadingTextStart,
|
|
83
|
+
startOffset - leadingTextStart
|
|
84
|
+
)
|
|
85
|
+
);
|
|
155
86
|
}
|
|
156
87
|
output.push(conversionMap[name]);
|
|
157
88
|
offset = startOffset + tokenLength;
|
|
158
89
|
return true;
|
|
159
90
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
91
|
+
addChild(
|
|
92
|
+
createFrame(conversionMap[name], startOffset, tokenLength)
|
|
93
|
+
);
|
|
163
94
|
offset = startOffset + tokenLength;
|
|
164
95
|
return true;
|
|
165
|
-
case
|
|
166
|
-
stack.push(
|
|
96
|
+
case "opener":
|
|
97
|
+
stack.push(
|
|
98
|
+
createFrame(
|
|
99
|
+
conversionMap[name],
|
|
100
|
+
startOffset,
|
|
101
|
+
tokenLength,
|
|
102
|
+
startOffset + tokenLength,
|
|
103
|
+
leadingTextStart
|
|
104
|
+
)
|
|
105
|
+
);
|
|
167
106
|
offset = startOffset + tokenLength;
|
|
168
107
|
return true;
|
|
169
|
-
case
|
|
170
|
-
// If we're not nesting then this is easy - close the block.
|
|
108
|
+
case "closer":
|
|
171
109
|
if (1 === stackDepth) {
|
|
172
110
|
closeOuterElement(startOffset);
|
|
173
111
|
offset = startOffset + tokenLength;
|
|
174
112
|
return true;
|
|
175
113
|
}
|
|
176
|
-
|
|
177
|
-
// Otherwise we're nested and we have to close out the current
|
|
178
|
-
// block and add it as a innerBlock to the parent.
|
|
179
114
|
const stackTop = stack.pop();
|
|
180
|
-
const text = indoc.substr(
|
|
115
|
+
const text = indoc.substr(
|
|
116
|
+
stackTop.prevOffset,
|
|
117
|
+
startOffset - stackTop.prevOffset
|
|
118
|
+
);
|
|
181
119
|
stackTop.children.push(text);
|
|
182
120
|
stackTop.prevOffset = startOffset + tokenLength;
|
|
183
|
-
const frame = createFrame(
|
|
121
|
+
const frame = createFrame(
|
|
122
|
+
stackTop.element,
|
|
123
|
+
stackTop.tokenStart,
|
|
124
|
+
stackTop.tokenLength,
|
|
125
|
+
startOffset + tokenLength
|
|
126
|
+
);
|
|
184
127
|
frame.children = stackTop.children;
|
|
185
128
|
addChild(frame);
|
|
186
129
|
offset = startOffset + tokenLength;
|
|
@@ -190,39 +133,22 @@ function proceed(conversionMap) {
|
|
|
190
133
|
return false;
|
|
191
134
|
}
|
|
192
135
|
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Grabs the next token match in the string and returns it's details.
|
|
196
|
-
*
|
|
197
|
-
* @private
|
|
198
|
-
*
|
|
199
|
-
* @return An array of details for the token matched.
|
|
200
|
-
*/
|
|
201
136
|
function nextToken() {
|
|
202
137
|
const matches = tokenizer.exec(indoc);
|
|
203
|
-
// We have no more tokens.
|
|
204
138
|
if (null === matches) {
|
|
205
|
-
return [
|
|
139
|
+
return ["no-more-tokens"];
|
|
206
140
|
}
|
|
207
141
|
const startedAt = matches.index;
|
|
208
142
|
const [match, isClosing, name, isSelfClosed] = matches;
|
|
209
143
|
const length = match.length;
|
|
210
144
|
if (isSelfClosed) {
|
|
211
|
-
return [
|
|
145
|
+
return ["self-closed", name, startedAt, length];
|
|
212
146
|
}
|
|
213
147
|
if (isClosing) {
|
|
214
|
-
return [
|
|
148
|
+
return ["closer", name, startedAt, length];
|
|
215
149
|
}
|
|
216
|
-
return [
|
|
150
|
+
return ["opener", name, startedAt, length];
|
|
217
151
|
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Pushes text extracted from the indoc string to the output stack given the
|
|
221
|
-
* current rawLength value and offset (if rawLength is provided ) or the
|
|
222
|
-
* indoc.length and offset.
|
|
223
|
-
*
|
|
224
|
-
* @private
|
|
225
|
-
*/
|
|
226
152
|
function addText() {
|
|
227
153
|
const length = indoc.length - offset;
|
|
228
154
|
if (0 === length) {
|
|
@@ -230,61 +156,31 @@ function addText() {
|
|
|
230
156
|
}
|
|
231
157
|
output.push(indoc.substr(offset, length));
|
|
232
158
|
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Pushes a child element to the associated parent element's children for the
|
|
236
|
-
* parent currently active in the stack.
|
|
237
|
-
*
|
|
238
|
-
* @private
|
|
239
|
-
*
|
|
240
|
-
* @param {Frame} frame The Frame containing the child element and it's
|
|
241
|
-
* token information.
|
|
242
|
-
*/
|
|
243
159
|
function addChild(frame) {
|
|
244
|
-
const {
|
|
245
|
-
element,
|
|
246
|
-
tokenStart,
|
|
247
|
-
tokenLength,
|
|
248
|
-
prevOffset,
|
|
249
|
-
children
|
|
250
|
-
} = frame;
|
|
160
|
+
const { element, tokenStart, tokenLength, prevOffset, children } = frame;
|
|
251
161
|
const parent = stack[stack.length - 1];
|
|
252
|
-
const text = indoc.substr(
|
|
162
|
+
const text = indoc.substr(
|
|
163
|
+
parent.prevOffset,
|
|
164
|
+
tokenStart - parent.prevOffset
|
|
165
|
+
);
|
|
253
166
|
if (text) {
|
|
254
167
|
parent.children.push(text);
|
|
255
168
|
}
|
|
256
|
-
parent.children.push((0,
|
|
169
|
+
parent.children.push((0, import_react.cloneElement)(element, null, ...children));
|
|
257
170
|
parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
|
|
258
171
|
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* This is called for closing tags. It creates the element currently active in
|
|
262
|
-
* the stack.
|
|
263
|
-
*
|
|
264
|
-
* @private
|
|
265
|
-
*
|
|
266
|
-
* @param {number} endOffset Offset at which the closing tag for the element
|
|
267
|
-
* begins in the string. If this is greater than the
|
|
268
|
-
* prevOffset attached to the element, then this
|
|
269
|
-
* helps capture any remaining nested text nodes in
|
|
270
|
-
* the element.
|
|
271
|
-
*/
|
|
272
172
|
function closeOuterElement(endOffset) {
|
|
273
|
-
const {
|
|
274
|
-
element,
|
|
275
|
-
leadingTextStart,
|
|
276
|
-
prevOffset,
|
|
277
|
-
tokenStart,
|
|
278
|
-
children
|
|
279
|
-
} = stack.pop();
|
|
173
|
+
const { element, leadingTextStart, prevOffset, tokenStart, children } = stack.pop();
|
|
280
174
|
const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
|
|
281
175
|
if (text) {
|
|
282
176
|
children.push(text);
|
|
283
177
|
}
|
|
284
178
|
if (null !== leadingTextStart) {
|
|
285
|
-
output.push(
|
|
179
|
+
output.push(
|
|
180
|
+
indoc.substr(leadingTextStart, tokenStart - leadingTextStart)
|
|
181
|
+
);
|
|
286
182
|
}
|
|
287
|
-
output.push((0,
|
|
183
|
+
output.push((0, import_react.cloneElement)(element, null, ...children));
|
|
288
184
|
}
|
|
289
|
-
var
|
|
290
|
-
//# sourceMappingURL=create-interpolate-element.js.map
|
|
185
|
+
var create_interpolate_element_default = createInterpolateElement;
|
|
186
|
+
//# sourceMappingURL=create-interpolate-element.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","createElement","Fragment","isObject","values","Object","length","every","isValidElement","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","cloneElement","endOffset","_default","exports","default"],"sources":["@wordpress/element/src/create-interpolate-element.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateElement,\n\tcloneElement,\n\tFragment,\n\tisValidElement,\n\ttype Element as ReactElement,\n} from './react';\n\nlet indoc: string;\nlet offset: number;\nlet output: ( string | ReactElement )[];\nlet stack: Frame[];\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, if it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\ninterface Frame {\n\t/**\n\t * A parent element which may still have nested children not yet parsed.\n\t */\n\telement: ReactElement;\n\n\t/**\n\t * Offset at which parent element first appears.\n\t */\n\ttokenStart: number;\n\n\t/**\n\t * Length of string marking start of parent element.\n\t */\n\ttokenLength: number;\n\n\t/**\n\t * Running offset at which parsing should continue.\n\t */\n\tprevOffset?: number;\n\n\t/**\n\t * Offset at which last closing element finished, used for finding text between elements.\n\t */\n\tleadingTextStart?: number | null;\n\n\t/**\n\t * Children.\n\t */\n\tchildren: ( string | ReactElement )[];\n}\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param element A parent element which may still have\n * nested children not yet parsed.\n * @param tokenStart Offset at which parent element first\n * appears.\n * @param tokenLength Length of string marking start of parent\n * element.\n * @param prevOffset Running offset at which parsing should\n * continue.\n * @param leadingTextStart Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement: ReactElement,\n\ttokenStart: number,\n\ttokenLength: number,\n\tprevOffset?: number,\n\tleadingTextStart?: number | null\n): Frame {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param interpolatedString The interpolation string to be parsed.\n * @param conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return A wp element.\n */\nconst createInterpolateElement = (\n\tinterpolatedString: string,\n\tconversionMap: Record< string, ReactElement >\n): ReactElement => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are React Elements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a React Element\n *\n * @private\n *\n * @param conversionMap The map being validated.\n *\n * @return True means the map is valid.\n */\nconst isValidConversionMap = (\n\tconversionMap: Record< string, ReactElement >\n): boolean => {\n\tconst isObject =\n\t\ttypeof conversionMap === 'object' && conversionMap !== null;\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length > 0 &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\ntype TokenType = 'no-more-tokens' | 'self-closed' | 'opener' | 'closer';\ntype TokenResult =\n\t| [ TokenType & 'no-more-tokens' ]\n\t| [\n\t\t\tTokenType & ( 'self-closed' | 'opener' | 'closer' ),\n\t\t\tstring,\n\t\t\tnumber,\n\t\t\tnumber,\n\t ];\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param conversionMap The conversion map for the string.\n *\n * @return true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap: Record< string, ReactElement > ): boolean {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( name && ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst { leadingTextStart: stackLeadingText, tokenStart } =\n\t\t\t\t\tstack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner element.\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return An array of details for the token matched.\n */\nfunction nextToken(): TokenResult {\n\tconst matches = tokenizer.exec( indoc );\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText(): void {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame: Frame ): void {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset: number ): void {\n\tconst { element, leadingTextStart, prevOffset, tokenStart, children } =\n\t\tstack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AASA,IAAIC,KAAa;AACjB,IAAIC,MAAc;AAClB,IAAIC,MAAmC;AACvC,IAAIC,KAAc;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG,uBAAuB;AAkCzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CACnBC,OAAqB,EACrBC,UAAkB,EAClBC,WAAmB,EACnBC,UAAmB,EACnBC,gBAAgC,EACxB;EACR,OAAO;IACNJ,OAAO;IACPC,UAAU;IACVC,WAAW;IACXC,UAAU;IACVC,gBAAgB;IAChBC,QAAQ,EAAE;EACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,wBAAwB,GAAGA,CAChCC,kBAA0B,EAC1BC,aAA6C,KAC3B;EAClBd,KAAK,GAAGa,kBAAkB;EAC1BZ,MAAM,GAAG,CAAC;EACVC,MAAM,GAAG,EAAE;EACXC,KAAK,GAAG,EAAE;EACVC,SAAS,CAACW,SAAS,GAAG,CAAC;EAEvB,IAAK,CAAEC,oBAAoB,CAAEF,aAAc,CAAC,EAAG;IAC9C,MAAM,IAAIG,SAAS,CAClB,mGACD,CAAC;EACF;EAEA,GAAG;IACF;EA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AAE5B,UAAW,CAAC;EAE7B,IAAKgC,IAAI,EAAG;IACX9B,QAAQ,CAACyB,IAAI,CAAEK,IAAK,CAAC;EACtB;EAEA,IAAK,IAAI,KAAK/B,gBAAgB,EAAG;IAChCR,MAAM,CAACkC,IAAI,CACVpC,KAAK,CAACqC,MAAM,CAAE3B,gBAAgB,EAAEH,UAAU,GAAGG,gBAAiB,CAC/D,CAAC;EACF;EAEAR,MAAM,CAACkC,IAAI,CAAE,IAAAe,mBAAY,EAAE7C,OAAO,EAAE,IAAI,EAAE,GAAGK,QAAS,CAAE,CAAC;AAC1D;AAAC,IAAA0C,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc3C,wBAAwB","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/create-interpolate-element.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tcreateElement,\n\tcloneElement,\n\tFragment,\n\tisValidElement,\n\ttype Element as ReactElement,\n} from './react';\n\nlet indoc: string;\nlet offset: number;\nlet output: ( string | ReactElement )[];\nlet stack: Frame[];\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, if it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\ninterface Frame {\n\t/**\n\t * A parent element which may still have nested children not yet parsed.\n\t */\n\telement: ReactElement;\n\n\t/**\n\t * Offset at which parent element first appears.\n\t */\n\ttokenStart: number;\n\n\t/**\n\t * Length of string marking start of parent element.\n\t */\n\ttokenLength: number;\n\n\t/**\n\t * Running offset at which parsing should continue.\n\t */\n\tprevOffset?: number;\n\n\t/**\n\t * Offset at which last closing element finished, used for finding text between elements.\n\t */\n\tleadingTextStart?: number | null;\n\n\t/**\n\t * Children.\n\t */\n\tchildren: ( string | ReactElement )[];\n}\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param element A parent element which may still have\n * nested children not yet parsed.\n * @param tokenStart Offset at which parent element first\n * appears.\n * @param tokenLength Length of string marking start of parent\n * element.\n * @param prevOffset Running offset at which parsing should\n * continue.\n * @param leadingTextStart Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement: ReactElement,\n\ttokenStart: number,\n\ttokenLength: number,\n\tprevOffset?: number,\n\tleadingTextStart?: number | null\n): Frame {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param interpolatedString The interpolation string to be parsed.\n * @param conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return A wp element.\n */\nconst createInterpolateElement = (\n\tinterpolatedString: string,\n\tconversionMap: Record< string, ReactElement >\n): ReactElement => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are React Elements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a React Element\n *\n * @private\n *\n * @param conversionMap The map being validated.\n *\n * @return True means the map is valid.\n */\nconst isValidConversionMap = (\n\tconversionMap: Record< string, ReactElement >\n): boolean => {\n\tconst isObject =\n\t\ttypeof conversionMap === 'object' && conversionMap !== null;\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length > 0 &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\ntype TokenType = 'no-more-tokens' | 'self-closed' | 'opener' | 'closer';\ntype TokenResult =\n\t| [ TokenType & 'no-more-tokens' ]\n\t| [\n\t\t\tTokenType & ( 'self-closed' | 'opener' | 'closer' ),\n\t\t\tstring,\n\t\t\tnumber,\n\t\t\tnumber,\n\t ];\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param conversionMap The conversion map for the string.\n *\n * @return true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap: Record< string, ReactElement > ): boolean {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( name && ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst { leadingTextStart: stackLeadingText, tokenStart } =\n\t\t\t\t\tstack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner element.\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return An array of details for the token matched.\n */\nfunction nextToken(): TokenResult {\n\tconst matches = tokenizer.exec( indoc );\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText(): void {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame: Frame ): void {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset: number ): void {\n\tconst { element, leadingTextStart, prevOffset, tokenStart, children } =\n\t\tstack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAMO;AAEP,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAeJ,MAAM,YAAY;AAuDlB,SAAS,YACR,SACA,YACA,aACA,YACA,kBACQ;AACR,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACZ;AACD;AA6BA,MAAM,2BAA2B,CAChC,oBACA,kBACkB;AAClB,UAAQ;AACR,WAAS;AACT,WAAS,CAAC;AACV,UAAQ,CAAC;AACT,YAAU,YAAY;AAEtB,MAAK,CAAE,qBAAsB,aAAc,GAAI;AAC9C,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,KAAG;AAAA,EAEH,SAAU,QAAS,aAAc;AACjC,aAAO,4BAAe,uBAAU,MAAM,GAAG,MAAO;AACjD;AAcA,MAAM,uBAAuB,CAC5B,kBACa;AACb,QAAM,WACL,OAAO,kBAAkB,YAAY,kBAAkB;AACxD,QAAM,SAAS,YAAY,OAAO,OAAQ,aAAc;AACxD,SACC,YACA,OAAO,SAAS,KAChB,OAAO,MAAO,CAAE,gBAAa,6BAAgB,OAAQ,CAAE;AAEzD;AAqBA,SAAS,QAAS,eAAyD;AAC1E,QAAM,OAAO,UAAU;AACvB,QAAM,CAAE,WAAW,MAAM,aAAa,WAAY,IAAI;AACtD,QAAM,aAAa,MAAM;AACzB,QAAM,mBAAmB,cAAc,SAAS,SAAS;AACzD,MAAK,QAAQ,CAAE,cAAe,IAAK,GAAI;A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D;AAAA,EACD;AAEA,SAAO,SAAM,2BAAc,SAAS,MAAM,GAAG,QAAS,CAAE;AACzD;AAEA,IAAO,qCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/index.js
CHANGED
|
@@ -1,77 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
RawHTML: true
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "RawHTML", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _rawHtml.default;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "createInterpolateElement", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _createInterpolateElement.default;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "renderToString", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _serialize.default;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
35
17
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var _platform = _interopRequireDefault(require("./platform"));
|
|
75
|
-
var _serialize = _interopRequireDefault(require("./serialize"));
|
|
76
|
-
var _rawHtml = _interopRequireDefault(require("./raw-html"));
|
|
77
|
-
//# sourceMappingURL=index.js.map
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
Platform: () => import_platform.default,
|
|
33
|
+
RawHTML: () => import_raw_html.default,
|
|
34
|
+
createInterpolateElement: () => import_create_interpolate_element.default,
|
|
35
|
+
renderToString: () => import_serialize.default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var import_create_interpolate_element = __toESM(require("./create-interpolate-element"));
|
|
39
|
+
__reExport(index_exports, require("./react"), module.exports);
|
|
40
|
+
__reExport(index_exports, require("./react-platform"), module.exports);
|
|
41
|
+
__reExport(index_exports, require("./utils"), module.exports);
|
|
42
|
+
var import_platform = __toESM(require("./platform"));
|
|
43
|
+
var import_serialize = __toESM(require("./serialize"));
|
|
44
|
+
var import_raw_html = __toESM(require("./raw-html"));
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
Platform,
|
|
48
|
+
RawHTML,
|
|
49
|
+
createInterpolateElement,
|
|
50
|
+
renderToString,
|
|
51
|
+
...require("./react"),
|
|
52
|
+
...require("./react-platform"),
|
|
53
|
+
...require("./utils")
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { default as createInterpolateElement } from './create-interpolate-element';\nexport * from './react';\nexport * from './react-platform';\nexport * from './utils';\nexport { default as Platform } from './platform';\nexport { default as renderToString } from './serialize';\nexport { default as RawHTML } from './raw-html';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAoD;AACpD,0BAAc,oBADd;AAEA,0BAAc,6BAFd;AAGA,0BAAc,oBAHd;AAIA,sBAAoC;AACpC,uBAA0C;AAC1C,sBAAmC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var platform_android_exports = {};
|
|
20
|
+
__export(platform_android_exports, {
|
|
21
|
+
default: () => platform_android_default
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* External dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(platform_android_exports);
|
|
24
|
+
var import_react_native = require("react-native");
|
|
12
25
|
const Platform = {
|
|
13
|
-
...
|
|
14
|
-
OS:
|
|
15
|
-
select: spec => {
|
|
16
|
-
if (
|
|
26
|
+
...import_react_native.Platform,
|
|
27
|
+
OS: "native",
|
|
28
|
+
select: (spec) => {
|
|
29
|
+
if ("android" in spec) {
|
|
17
30
|
return spec.android;
|
|
18
|
-
} else if (
|
|
31
|
+
} else if ("native" in spec) {
|
|
19
32
|
return spec.native;
|
|
20
33
|
}
|
|
21
34
|
return spec.default;
|
|
@@ -23,5 +36,5 @@ const Platform = {
|
|
|
23
36
|
isNative: true,
|
|
24
37
|
isAndroid: true
|
|
25
38
|
};
|
|
26
|
-
var
|
|
27
|
-
//# sourceMappingURL=platform.android.js.map
|
|
39
|
+
var platform_android_default = Platform;
|
|
40
|
+
//# sourceMappingURL=platform.android.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/platform.android.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'android' in spec ) {\n\t\t\treturn spec.android;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisAndroid: true,\n};\n\nexport default Platform;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA6C;AAE7C,MAAM,WAAW;AAAA,EAChB,GAAG,oBAAAA;AAAA,EACH,IAAI;AAAA,EACJ,QAAQ,CAAE,SAAU;AACnB,QAAK,aAAa,MAAO;AACxB,aAAO,KAAK;AAAA,IACb,WAAY,YAAY,MAAO;AAC9B,aAAO,KAAK;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACb;AAAA,EACA,UAAU;AAAA,EACV,WAAW;AACZ;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["OriginalPlatform"]
|
|
7
|
+
}
|