@blotch/angular-lynx-native 22.2.7 → 22.2.9
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/README.md +2 -0
- package/package.json +2 -1
- package/templates/android/README.md +6 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/AssetsModule.kt +41 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasUI.kt +76 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +9 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLContext.kt +1442 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLModule.kt +220 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLOps.kt +211 -0
- package/templates/ios/App/AngularLynxWebGL.h +80 -0
- package/templates/ios/App/AngularLynxWebGL.m +338 -0
- package/templates/ios/App/AngularLynxWebGLContext.m +2220 -0
- package/templates/ios/App/AngularLynxWebGLOps.h +209 -0
- package/templates/ios/App/AssetsModule.swift +53 -0
- package/templates/ios/App/LynxViewController.swift +11 -0
- package/templates/ios/App/XElementRegistry.swift +6 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// Generated from packages/runtime/src/lib/canvas/webgl-ops.ts by
|
|
2
|
+
// packages/native/scripts/webgl-ops.ts: run `npm run generate:webgl-ops -w
|
|
3
|
+
// packages/native` rather than editing it.
|
|
4
|
+
|
|
5
|
+
#import <Foundation/Foundation.h>
|
|
6
|
+
|
|
7
|
+
/// The commands of the WebGL bridge, as `<canvas>`'s context in the runtime
|
|
8
|
+
/// records them: below 200 they return nothing, from 200 each answers one
|
|
9
|
+
/// query.
|
|
10
|
+
typedef NS_ENUM(NSInteger, ALWebGLOp) {
|
|
11
|
+
ALWebGLOpActiveTexture = 1,
|
|
12
|
+
ALWebGLOpAttachShader = 2,
|
|
13
|
+
ALWebGLOpBindAttribLocation = 3,
|
|
14
|
+
ALWebGLOpBindBuffer = 4,
|
|
15
|
+
ALWebGLOpBindBufferBase = 5,
|
|
16
|
+
ALWebGLOpBindBufferRange = 6,
|
|
17
|
+
ALWebGLOpBindFramebuffer = 7,
|
|
18
|
+
ALWebGLOpBindRenderbuffer = 8,
|
|
19
|
+
ALWebGLOpBindSampler = 9,
|
|
20
|
+
ALWebGLOpBindTexture = 10,
|
|
21
|
+
ALWebGLOpBindTransformFeedback = 11,
|
|
22
|
+
ALWebGLOpBindVertexArray = 12,
|
|
23
|
+
ALWebGLOpBeginQuery = 13,
|
|
24
|
+
ALWebGLOpBeginTransformFeedback = 14,
|
|
25
|
+
ALWebGLOpBlendColor = 15,
|
|
26
|
+
ALWebGLOpBlendEquation = 16,
|
|
27
|
+
ALWebGLOpBlendEquationSeparate = 17,
|
|
28
|
+
ALWebGLOpBlendFunc = 18,
|
|
29
|
+
ALWebGLOpBlendFuncSeparate = 19,
|
|
30
|
+
ALWebGLOpBlitFramebuffer = 20,
|
|
31
|
+
ALWebGLOpBufferData = 21,
|
|
32
|
+
ALWebGLOpBufferSubData = 22,
|
|
33
|
+
ALWebGLOpClear = 23,
|
|
34
|
+
ALWebGLOpClearBufferfv = 24,
|
|
35
|
+
ALWebGLOpClearBufferiv = 25,
|
|
36
|
+
ALWebGLOpClearBufferuiv = 26,
|
|
37
|
+
ALWebGLOpClearBufferfi = 27,
|
|
38
|
+
ALWebGLOpClearColor = 28,
|
|
39
|
+
ALWebGLOpClearDepth = 29,
|
|
40
|
+
ALWebGLOpClearStencil = 30,
|
|
41
|
+
ALWebGLOpColorMask = 31,
|
|
42
|
+
ALWebGLOpCompileShader = 32,
|
|
43
|
+
ALWebGLOpCompressedTexImage2D = 33,
|
|
44
|
+
ALWebGLOpCompressedTexImage3D = 34,
|
|
45
|
+
ALWebGLOpCompressedTexSubImage2D = 35,
|
|
46
|
+
ALWebGLOpCompressedTexSubImage3D = 36,
|
|
47
|
+
ALWebGLOpCopyBufferSubData = 37,
|
|
48
|
+
ALWebGLOpCopyTexImage2D = 38,
|
|
49
|
+
ALWebGLOpCopyTexSubImage2D = 39,
|
|
50
|
+
ALWebGLOpCopyTexSubImage3D = 40,
|
|
51
|
+
ALWebGLOpCreateBuffer = 41,
|
|
52
|
+
ALWebGLOpCreateFramebuffer = 42,
|
|
53
|
+
ALWebGLOpCreateProgram = 43,
|
|
54
|
+
ALWebGLOpCreateQuery = 44,
|
|
55
|
+
ALWebGLOpCreateRenderbuffer = 45,
|
|
56
|
+
ALWebGLOpCreateSampler = 46,
|
|
57
|
+
ALWebGLOpCreateShader = 47,
|
|
58
|
+
ALWebGLOpCreateTexture = 48,
|
|
59
|
+
ALWebGLOpCreateTransformFeedback = 49,
|
|
60
|
+
ALWebGLOpCreateVertexArray = 50,
|
|
61
|
+
ALWebGLOpCullFace = 51,
|
|
62
|
+
ALWebGLOpDeleteBuffer = 52,
|
|
63
|
+
ALWebGLOpDeleteFramebuffer = 53,
|
|
64
|
+
ALWebGLOpDeleteProgram = 54,
|
|
65
|
+
ALWebGLOpDeleteQuery = 55,
|
|
66
|
+
ALWebGLOpDeleteRenderbuffer = 56,
|
|
67
|
+
ALWebGLOpDeleteSampler = 57,
|
|
68
|
+
ALWebGLOpDeleteShader = 58,
|
|
69
|
+
ALWebGLOpDeleteSync = 59,
|
|
70
|
+
ALWebGLOpDeleteTexture = 60,
|
|
71
|
+
ALWebGLOpDeleteTransformFeedback = 61,
|
|
72
|
+
ALWebGLOpDeleteVertexArray = 62,
|
|
73
|
+
ALWebGLOpDepthFunc = 63,
|
|
74
|
+
ALWebGLOpDepthMask = 64,
|
|
75
|
+
ALWebGLOpDepthRange = 65,
|
|
76
|
+
ALWebGLOpDetachShader = 66,
|
|
77
|
+
ALWebGLOpDisable = 67,
|
|
78
|
+
ALWebGLOpDisableVertexAttribArray = 68,
|
|
79
|
+
ALWebGLOpDrawArrays = 69,
|
|
80
|
+
ALWebGLOpDrawArraysInstanced = 70,
|
|
81
|
+
ALWebGLOpDrawBuffers = 71,
|
|
82
|
+
ALWebGLOpDrawElements = 72,
|
|
83
|
+
ALWebGLOpDrawElementsInstanced = 73,
|
|
84
|
+
ALWebGLOpDrawRangeElements = 74,
|
|
85
|
+
ALWebGLOpEnable = 75,
|
|
86
|
+
ALWebGLOpEnableVertexAttribArray = 76,
|
|
87
|
+
ALWebGLOpEndQuery = 77,
|
|
88
|
+
ALWebGLOpEndTransformFeedback = 78,
|
|
89
|
+
ALWebGLOpFenceSync = 79,
|
|
90
|
+
ALWebGLOpFinish = 80,
|
|
91
|
+
ALWebGLOpFlush = 81,
|
|
92
|
+
ALWebGLOpFramebufferRenderbuffer = 82,
|
|
93
|
+
ALWebGLOpFramebufferTexture2D = 83,
|
|
94
|
+
ALWebGLOpFramebufferTextureLayer = 84,
|
|
95
|
+
ALWebGLOpFrontFace = 85,
|
|
96
|
+
ALWebGLOpGenerateMipmap = 86,
|
|
97
|
+
ALWebGLOpHint = 87,
|
|
98
|
+
ALWebGLOpInvalidateFramebuffer = 88,
|
|
99
|
+
ALWebGLOpInvalidateSubFramebuffer = 89,
|
|
100
|
+
ALWebGLOpLineWidth = 90,
|
|
101
|
+
ALWebGLOpLinkProgram = 91,
|
|
102
|
+
ALWebGLOpPauseTransformFeedback = 92,
|
|
103
|
+
ALWebGLOpPixelStorei = 93,
|
|
104
|
+
ALWebGLOpPolygonOffset = 94,
|
|
105
|
+
ALWebGLOpReadBuffer = 95,
|
|
106
|
+
ALWebGLOpReadPixelsToBuffer = 96,
|
|
107
|
+
ALWebGLOpRenderbufferStorage = 97,
|
|
108
|
+
ALWebGLOpRenderbufferStorageMultisample = 98,
|
|
109
|
+
ALWebGLOpResumeTransformFeedback = 99,
|
|
110
|
+
ALWebGLOpSampleCoverage = 100,
|
|
111
|
+
ALWebGLOpSamplerParameterf = 101,
|
|
112
|
+
ALWebGLOpSamplerParameteri = 102,
|
|
113
|
+
ALWebGLOpScissor = 103,
|
|
114
|
+
ALWebGLOpShaderSource = 104,
|
|
115
|
+
ALWebGLOpStencilFunc = 105,
|
|
116
|
+
ALWebGLOpStencilFuncSeparate = 106,
|
|
117
|
+
ALWebGLOpStencilMask = 107,
|
|
118
|
+
ALWebGLOpStencilMaskSeparate = 108,
|
|
119
|
+
ALWebGLOpStencilOp = 109,
|
|
120
|
+
ALWebGLOpStencilOpSeparate = 110,
|
|
121
|
+
ALWebGLOpTexImage2D = 111,
|
|
122
|
+
ALWebGLOpTexImage3D = 112,
|
|
123
|
+
ALWebGLOpTexParameterf = 113,
|
|
124
|
+
ALWebGLOpTexParameteri = 114,
|
|
125
|
+
ALWebGLOpTexStorage2D = 115,
|
|
126
|
+
ALWebGLOpTexStorage3D = 116,
|
|
127
|
+
ALWebGLOpTexSubImage2D = 117,
|
|
128
|
+
ALWebGLOpTexSubImage3D = 118,
|
|
129
|
+
ALWebGLOpTransformFeedbackVaryings = 119,
|
|
130
|
+
ALWebGLOpUniform1f = 120,
|
|
131
|
+
ALWebGLOpUniform2f = 121,
|
|
132
|
+
ALWebGLOpUniform3f = 122,
|
|
133
|
+
ALWebGLOpUniform4f = 123,
|
|
134
|
+
ALWebGLOpUniform1i = 124,
|
|
135
|
+
ALWebGLOpUniform2i = 125,
|
|
136
|
+
ALWebGLOpUniform3i = 126,
|
|
137
|
+
ALWebGLOpUniform4i = 127,
|
|
138
|
+
ALWebGLOpUniform1ui = 128,
|
|
139
|
+
ALWebGLOpUniform2ui = 129,
|
|
140
|
+
ALWebGLOpUniform3ui = 130,
|
|
141
|
+
ALWebGLOpUniform4ui = 131,
|
|
142
|
+
ALWebGLOpUniform1fv = 132,
|
|
143
|
+
ALWebGLOpUniform2fv = 133,
|
|
144
|
+
ALWebGLOpUniform3fv = 134,
|
|
145
|
+
ALWebGLOpUniform4fv = 135,
|
|
146
|
+
ALWebGLOpUniform1iv = 136,
|
|
147
|
+
ALWebGLOpUniform2iv = 137,
|
|
148
|
+
ALWebGLOpUniform3iv = 138,
|
|
149
|
+
ALWebGLOpUniform4iv = 139,
|
|
150
|
+
ALWebGLOpUniform1uiv = 140,
|
|
151
|
+
ALWebGLOpUniform2uiv = 141,
|
|
152
|
+
ALWebGLOpUniform3uiv = 142,
|
|
153
|
+
ALWebGLOpUniform4uiv = 143,
|
|
154
|
+
ALWebGLOpUniformMatrix2fv = 144,
|
|
155
|
+
ALWebGLOpUniformMatrix3fv = 145,
|
|
156
|
+
ALWebGLOpUniformMatrix4fv = 146,
|
|
157
|
+
ALWebGLOpUniformMatrix2x3fv = 147,
|
|
158
|
+
ALWebGLOpUniformMatrix3x2fv = 148,
|
|
159
|
+
ALWebGLOpUniformMatrix2x4fv = 149,
|
|
160
|
+
ALWebGLOpUniformMatrix4x2fv = 150,
|
|
161
|
+
ALWebGLOpUniformMatrix3x4fv = 151,
|
|
162
|
+
ALWebGLOpUniformMatrix4x3fv = 152,
|
|
163
|
+
ALWebGLOpUniformBlockBinding = 153,
|
|
164
|
+
ALWebGLOpUseProgram = 154,
|
|
165
|
+
ALWebGLOpValidateProgram = 155,
|
|
166
|
+
ALWebGLOpVertexAttrib4f = 156,
|
|
167
|
+
ALWebGLOpVertexAttribI4i = 157,
|
|
168
|
+
ALWebGLOpVertexAttribI4ui = 158,
|
|
169
|
+
ALWebGLOpVertexAttribDivisor = 159,
|
|
170
|
+
ALWebGLOpVertexAttribIPointer = 160,
|
|
171
|
+
ALWebGLOpVertexAttribPointer = 161,
|
|
172
|
+
ALWebGLOpViewport = 162,
|
|
173
|
+
ALWebGLOpWaitSync = 163,
|
|
174
|
+
ALWebGLOpResize = 164,
|
|
175
|
+
ALWebGLOpPresent = 165,
|
|
176
|
+
ALWebGLOpGetParameter = 200,
|
|
177
|
+
ALWebGLOpGetError = 201,
|
|
178
|
+
ALWebGLOpShaderInfo = 202,
|
|
179
|
+
ALWebGLOpProgramInfo = 203,
|
|
180
|
+
ALWebGLOpGetUniformLocation = 204,
|
|
181
|
+
ALWebGLOpGetAttribLocation = 205,
|
|
182
|
+
ALWebGLOpCheckFramebufferStatus = 206,
|
|
183
|
+
ALWebGLOpGetBufferParameter = 207,
|
|
184
|
+
ALWebGLOpGetFramebufferAttachmentParameter = 208,
|
|
185
|
+
ALWebGLOpGetRenderbufferParameter = 209,
|
|
186
|
+
ALWebGLOpGetTexParameter = 210,
|
|
187
|
+
ALWebGLOpGetSamplerParameter = 211,
|
|
188
|
+
ALWebGLOpGetVertexAttrib = 212,
|
|
189
|
+
ALWebGLOpGetVertexAttribOffset = 213,
|
|
190
|
+
ALWebGLOpGetIndexedParameter = 214,
|
|
191
|
+
ALWebGLOpGetInternalformatParameter = 215,
|
|
192
|
+
ALWebGLOpGetQueryParameter = 216,
|
|
193
|
+
ALWebGLOpGetSyncParameter = 217,
|
|
194
|
+
ALWebGLOpClientWaitSync = 218,
|
|
195
|
+
ALWebGLOpGetUniform = 219,
|
|
196
|
+
ALWebGLOpGetUniformBlockIndex = 220,
|
|
197
|
+
ALWebGLOpGetActiveUniformBlockName = 221,
|
|
198
|
+
ALWebGLOpGetActiveUniformBlockParameter = 222,
|
|
199
|
+
ALWebGLOpGetActiveUniforms = 223,
|
|
200
|
+
ALWebGLOpGetUniformIndices = 224,
|
|
201
|
+
ALWebGLOpGetFragDataLocation = 225,
|
|
202
|
+
ALWebGLOpGetTransformFeedbackVarying = 226,
|
|
203
|
+
ALWebGLOpReadPixels = 227,
|
|
204
|
+
ALWebGLOpGetBufferSubData = 228,
|
|
205
|
+
ALWebGLOpIsEnabled = 229,
|
|
206
|
+
ALWebGLOpGetShaderPrecisionFormat = 230,
|
|
207
|
+
ALWebGLOpGetSupportedExtensions = 231,
|
|
208
|
+
ALWebGLOpGetProgramParameter = 232,
|
|
209
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Lynx
|
|
3
|
+
|
|
4
|
+
/// The `AngularLynxAssets` module: a file the app bundles (`/static/...`),
|
|
5
|
+
/// read for the runtime's main-thread `fetch` and `Image`, which load a
|
|
6
|
+
/// texture or a glTF model the app imports. The app's `dist/` is in the app
|
|
7
|
+
/// bundle, not on a server, so a URL relative to it has nowhere to be
|
|
8
|
+
/// fetched from; BundleResourceFetcher maps it to the file, as it does for
|
|
9
|
+
/// Lynx's own `<image>`.
|
|
10
|
+
///
|
|
11
|
+
/// Called from the main thread, synchronously (`lynx.module(name)`), like
|
|
12
|
+
/// the WebGL module: the runtime turns the answer into a Response.
|
|
13
|
+
final class AssetsModule: NSObject, LynxModule {
|
|
14
|
+
static var name: String { "AngularLynxAssets" }
|
|
15
|
+
|
|
16
|
+
static var methodLookup: [String: String] {
|
|
17
|
+
["read": NSStringFromSelector(#selector(read(_:)))]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override init() {
|
|
21
|
+
super.init()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Swift can't import an optional initializer as optional, so Lynx's
|
|
25
|
+
// initWithParam: is required here.
|
|
26
|
+
init(param: Any) {
|
|
27
|
+
super.init()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// The file's bytes as 32-bit words with the byte count last (see toWords
|
|
31
|
+
/// in the runtime's webgl-bridge.ts: Lynx's bridge carries no binary), or
|
|
32
|
+
/// nil when the app doesn't bundle it.
|
|
33
|
+
@objc func read(_ url: String) -> [NSNumber]? {
|
|
34
|
+
guard let file = BundleResourceFetcher.shared.localFile(for: url),
|
|
35
|
+
let data = try? Data(contentsOf: file)
|
|
36
|
+
else { return nil }
|
|
37
|
+
var words = [NSNumber]()
|
|
38
|
+
words.reserveCapacity(data.count / 4 + 2)
|
|
39
|
+
data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
|
|
40
|
+
var index = 0
|
|
41
|
+
while index < bytes.count {
|
|
42
|
+
var word: UInt32 = 0
|
|
43
|
+
for offset in 0..<min(4, bytes.count - index) {
|
|
44
|
+
word |= UInt32(bytes[index + offset]) << (8 * UInt32(offset))
|
|
45
|
+
}
|
|
46
|
+
words.append(NSNumber(value: word))
|
|
47
|
+
index += 4
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
words.append(NSNumber(value: data.count))
|
|
51
|
+
return words
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -18,8 +18,19 @@ final class LynxViewController: UIViewController {
|
|
|
18
18
|
config.register(WebAuthModule.self)
|
|
19
19
|
config.register(LocalStorageModule.self)
|
|
20
20
|
config.register(SecureStorageModule.self)
|
|
21
|
+
// <canvas>'s WebGL (AngularLynxWebGL.h), which the runtime calls from
|
|
22
|
+
// the main thread. It's Objective-C, which Swift reaches without a
|
|
23
|
+
// bridging header by name.
|
|
24
|
+
if let webGL = NSClassFromString("AngularLynxWebGLModule") as? LynxModule.Type {
|
|
25
|
+
config.register(webGL)
|
|
26
|
+
}
|
|
27
|
+
// Bundled files for the main thread's fetch and Image (AssetsModule).
|
|
28
|
+
config.register(AssetsModule.self)
|
|
21
29
|
let lynxView = LynxView { builder in
|
|
22
30
|
builder.config = config
|
|
31
|
+
// Lets main-thread code, where Angular runs, call the config's modules
|
|
32
|
+
// with lynx.module(name): WebGL needs answers synchronously.
|
|
33
|
+
builder.enableMTSModule = true
|
|
23
34
|
builder.screenSize = screenSize
|
|
24
35
|
builder.fontScale = 1.0
|
|
25
36
|
builder.enableGenericResourceFetcher = .true
|
|
@@ -12,7 +12,8 @@ import XElement
|
|
|
12
12
|
/// (scripts/build-lynx-ios-frameworks.sh) and the shell registers the same
|
|
13
13
|
/// classes under the same names here, before the first LynxConfig or LynxView
|
|
14
14
|
/// exists. `<blur-view>` is XElement's with UIKit's blur materials and glass
|
|
15
|
-
/// transitions added (BlurView).
|
|
15
|
+
/// transitions added (BlurView). `<canvas>` is the shell's own, for WebGL
|
|
16
|
+
/// (AngularLynxWebGL.h).
|
|
16
17
|
enum XElementRegistry {
|
|
17
18
|
static func register() {
|
|
18
19
|
let elements: [(String, AnyClass)] = [
|
|
@@ -36,6 +37,10 @@ enum XElementRegistry {
|
|
|
36
37
|
for (name, ui) in elements {
|
|
37
38
|
LynxComponentRegistry.registerUI(ui, withName: name)
|
|
38
39
|
}
|
|
40
|
+
// The shell's own <canvas> (AngularLynxWebGL.h): Lynx has none.
|
|
41
|
+
if let canvas = NSClassFromString("AngularLynxCanvas") {
|
|
42
|
+
LynxComponentRegistry.registerUI(canvas, withName: "canvas")
|
|
43
|
+
}
|
|
39
44
|
// The elements whose size comes from their content (a text field's
|
|
40
45
|
// text, an overlay's screen, a refresh's header) also measure themselves
|
|
41
46
|
// in layout, through a shadow node.
|